/** * This method will return whether SCIM is enabled or not for a particular userStore. (from SCIMEnabled user * store property) * @param userStoreName user store name * @return whether scim is enabled or not for the particular user store */ private boolean isSCIMEnabled(String userStoreName) { UserStoreManager userStoreManager = carbonUM.getSecondaryUserStoreManager(userStoreName); if (userStoreManager != null) { try { return userStoreManager.isSCIMEnabled(); } catch (UserStoreException e) { log.error("Error while evaluating isSCIMEnalbed for user store " + userStoreName, e); } } return false; }
@Override public boolean doPreSetUserClaimValues(String userName, Map<String, String> claims, String profileName, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || userStoreManager == null || !userStoreManager.isSCIMEnabled() || userStoreManager .isReadOnly()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } Date date = new Date(); String lastModifiedDate = AttributeUtil.formatDateTime(date); claims.put(SCIMConstants.CommonSchemaConstants.LAST_MODIFIED_URI, lastModifiedDate); return true; }
@Override public boolean doPreSetUserClaimValues(String userName, Map<String, String> claims, String profileName, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || !userStoreManager.isSCIMEnabled() || userStoreManager.isReadOnly()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } Date date = new Date(); String lastModifiedDate = AttributeUtil.formatDateTime(date); claims.put(SCIMConstants.META_LAST_MODIFIED_URI, lastModifiedDate); return true; }
@Override public boolean doPreAddUser(String userName, Object credential, String[] roleList, Map<String, String> claims, String profile, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || userStoreManager == null || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } this.populateSCIMAttributes(userName, claims); return true; }
@Override public boolean doPreAddUser(String userName, Object credential, String[] roleList, Map<String, String> claims, String profile, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } this.getSCIMAttributes(userName, claims); return true; }
@Override public boolean doPostUpdateCredentialByAdmin(String userName, Object credential, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || userStoreManager == null || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } // Update last-modified-date. try { Date date = new Date(); String lastModifiedDate = AttributeUtil.formatDateTime(date); userStoreManager.setUserClaimValue( userName, SCIMConstants.CommonSchemaConstants.LAST_MODIFIED_URI, lastModifiedDate, null); } catch (org.wso2.carbon.user.api.UserStoreException e) { if (e.getMessage().contains("UserNotFound")) { if (log.isDebugEnabled()) { log.debug("User " + userName + " doesn't exist"); } } else { throw new UserStoreException("Error updating SCIM metadata in doPostUpdateCredentialByAdmin " + "listener", e); } } return true; }
@Override public boolean doPostUpdateCredentialByAdmin(String userName, Object credential, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } //update last-modified-date try { Date date = new Date(); String lastModifiedDate = AttributeUtil.formatDateTime(date); userStoreManager.setUserClaimValue( userName, SCIMConstants.META_LAST_MODIFIED_URI, lastModifiedDate, null); } catch (org.wso2.carbon.user.api.UserStoreException e) { if (e.getMessage().contains("UserNotFound")) { if (log.isDebugEnabled()) { log.debug("User " + userName + " doesn't exist"); } } else { throw new UserStoreException("Error updating SCIM metadata in doPostUpdateCredentialByAdmin " + "listener", e); } } return true; }
getTenantUserRealm(superTenantId).getUserStoreManager(); if (userStoreManager.isSCIMEnabled()) {
getTenantUserRealm(tenantId).getUserStoreManager(); if (log.isDebugEnabled()) { log.debug("SCIM enable in Userstore level : " + userStoreManager.isSCIMEnabled() + ", for " + "Tenant ID : " + tenantId + ", validating for the existing SCIM ID : " + validateSCIMID); if (userStoreManager.isSCIMEnabled()) { String adminUsername = ClaimsMgtUtil.getAdminUserNameFromTenantId(IdentityTenantUtil.getRealmService(), tenantId);
if (!isEnable() || !userStoreManager.isSCIMEnabled()) { return true;
getTenantUserRealm(tenantId).getUserStoreManager(); if (log.isDebugEnabled()) { log.debug("SCIM enable in Userstore level : " + userStoreManager.isSCIMEnabled() + ", for " + "Tenant ID : " + tenantId + ", validating for the existing SCIM ID : " + validateSCIMID); if (userStoreManager.isSCIMEnabled()) { String adminUsername = ClaimsMgtUtil.getAdminUserNameFromTenantId(IdentityTenantUtil.getRealmService(), tenantId);
getTenantUserRealm(tenantId).getUserStoreManager(); if (log.isDebugEnabled()) { log.debug("SCIM enable in Userstore level : " + userStoreManager.isSCIMEnabled() + ", for " + "Tenant ID : " + tenantId); if (userStoreManager.isSCIMEnabled()) { SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId()); String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration());
getTenantUserRealm(tenantId).getUserStoreManager(); if (log.isDebugEnabled()) { log.debug("SCIM enable in Userstore level : " + userStoreManager.isSCIMEnabled() + ", for " + "Tenant ID : " + tenantId); if (userStoreManager.isSCIMEnabled()) { SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId()); String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration());
@Override public boolean doPostDeleteRole(String roleName, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } try { SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId()); String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); if (domainName == null) { domainName = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME; } String roleNameWithDomain = IdentityUtil.addDomainToName(roleName, domainName); try { //delete group attributes - no need to check existence here, since it is checked in below method. //remove SCIM attributes for the group added via mgt console, not via SCIM endpoint scimGroupHandler.deleteGroupAttributes(roleNameWithDomain); } catch (IdentitySCIMException e) { throw new UserStoreException("Error retrieving group information from SCIM Tables.", e); } return true; } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
@Override public boolean doPreDeleteRole(String roleName, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || userStoreManager == null || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } try { SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId()); String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); if (domainName == null) { domainName = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME; } String roleNameWithDomain = IdentityUtil.addDomainToName(roleName, domainName); try { //delete group attributes - no need to check existence here, //since it is checked in below method. scimGroupHandler.deleteGroupAttributes(roleNameWithDomain); } catch (IdentitySCIMException e) { throw new UserStoreException("Error retrieving group information from SCIM Tables.", e); } return true; } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
@Override public boolean doPostUpdateRoleName(String roleName, String newRoleName, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || userStoreManager == null || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } try { //TODO:set last update date SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId()); String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); if (domainName == null) { domainName = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME; } String roleNameWithDomain = UserCoreUtil.addDomainToName(roleName, domainName); String newRoleNameWithDomain = UserCoreUtil.addDomainToName(newRoleName, domainName); try { scimGroupHandler.updateRoleName(roleNameWithDomain, newRoleNameWithDomain); } catch (IdentitySCIMException e) { throw new UserStoreException("Error updating group information in SCIM Tables.", e); } return true; } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
@Override public boolean doPostUpdateRoleName(String roleName, String newRoleName, UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || !userStoreManager.isSCIMEnabled()) { return true; } } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException("Error while reading isScimEnabled from userstore manager", e); } try { //TODO:set last update date SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId()); String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); if (domainName == null) { domainName = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME; } String roleNameWithDomain = UserCoreUtil.addDomainToName(roleName, domainName); String newRoleNameWithDomain = UserCoreUtil.addDomainToName(newRoleName, domainName); try { scimGroupHandler.updateRoleName(roleNameWithDomain, newRoleNameWithDomain); } catch (IdentitySCIMException e) { throw new UserStoreException("Error updating group information in SCIM Tables.", e); } return true; } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
UserStoreManager userStoreManager) throws UserStoreException { try { if (!isEnable() || userStoreManager == null || !userStoreManager.isSCIMEnabled()) { return true;
if (!isEnable() || !userStoreManager.isSCIMEnabled()) { return true;