private boolean isUserExistsInDomain(UserStoreManager userStoreManager, String userName) throws UserStoreException { boolean isExists = false; if (userStoreManager.isExistingUser(userName)) { isExists = true; } return isExists; }
private UserStoreManager getUserStoreManager() throws UserStoreException { try { UserRealm realm = super.getUserRealm(); if (realm == null) { throw new UserStoreException(NULL_REALM_MESSAGE); } return realm.getUserStoreManager(); } catch (Exception e) { throw new UserStoreException(e); } }
private AuthorizationManager getAuthorizationManager() throws UserStoreException { try { UserRealm realm = super.getUserRealm(); if (realm == null) { throw new UserStoreException(NULL_REALM_MESSAGE); } return realm.getAuthorizationManager(); } catch (Exception e) { throw new UserStoreException(e); } }
/** * Compute the user store which user to be provisioned * * @return * @throws UserStoreException */ private String getUserStoreDomain(String userStoreDomain, UserRealm realm) throws FrameworkException, UserStoreException { // If the any of above value is invalid, keep it empty to use primary userstore if (userStoreDomain != null && realm.getUserStoreManager().getSecondaryUserStoreManager(userStoreDomain) == null) { throw new FrameworkException("Specified user store domain " + userStoreDomain + " is not valid."); } return userStoreDomain; }
private String getSubjectClaimFromUserStore(String subjectClaimUri, AuthenticatedUser authenticatedUser) throws UserStoreException, IdentityException { UserStoreManager userStoreManager = IdentityTenantUtil .getRealm(authenticatedUser.getTenantDomain(), authenticatedUser.toFullQualifiedUsername()) .getUserStoreManager(); return userStoreManager .getSecondaryUserStoreManager(authenticatedUser.getUserStoreDomain()) .getUserClaimValue(authenticatedUser.getUserName(), subjectClaimUri, null); }
public String[] listUsers(String filter, int maxLimit) throws UserAdminException { try { return realm.getUserStoreManager().listUsers(filter, maxLimit); } catch (UserStoreException e) { log.error(e.getMessage(), e); throw new UserAdminException(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); throw new UserAdminException(e.getMessage(), e); } }
public boolean isAddUserEnabled() throws Exception { UserRealm userRealm = IdentityTenantUtil.getRealm(null, null); if (userRealm != null) { UserStoreManager userStoreManager = userRealm.getUserStoreManager(); if (userStoreManager != null) { return !userStoreManager.isReadOnly(); } } return false; }
public static boolean isAuthorized(UserRegistry registry, String resourcePath, String action) throws RegistryException{ UserRealm userRealm = registry.getUserRealm(); String userName = registry.getUserName(); try { if (!userRealm.getAuthorizationManager().isUserAuthorized(userName, resourcePath, action)) { return false; } } catch (UserStoreException e) { throw new RegistryException("Error at Authorizing " + resourcePath + " with user " + userName + ":" + e.getMessage(), e); } return true; }
private ClaimManager getClaimManager() throws UserStoreException { try { UserRealm realm = super.getUserRealm(); if (realm == null) { throw new UserStoreException(NULL_REALM_MESSAGE); } return realm.getClaimManager(); } catch (Exception e) { throw new UserStoreException(e); } } }
public static boolean isUserAuthorizedToConfigureProfile(UserRealm realm, String currentUserName, String targetUser) throws UserStoreException { boolean isAuthrized = false; if (currentUserName == null) { //do nothing } else if (currentUserName.equals(targetUser)) { isAuthrized = true; } else { AuthorizationManager authorizer = realm.getAuthorizationManager(); isAuthrized = authorizer.isUserAuthorized(currentUserName, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION + "/manage/identity/usermgt/profiles", "ui.execute"); } return isAuthrized; }
@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; }
private void addPermission(UserRealm user, String role, String target, String rule) throws UserStoreException { //Do nothing if either the role,target or rule is empty if ((role == null) || (target == null) || (rule == null)) { return; } user.getAuthorizationManager().authorizeRole(role, target, rule); if (log.isDebugEnabled()) { log.debug("Permission " + rule + " ADDED to role: " + role + " for " + target); } }
private ProfileConfigurationManager getProfileConfigurationManager() throws UserStoreException { try { UserRealm realm = super.getUserRealm(); if (realm == null) { throw new UserStoreException(NULL_REALM_MESSAGE); } return realm.getProfileConfigurationManager(); } catch (Exception e) { throw new UserStoreException(e); } }
private void removePermission(UserRealm user, String role, String target, String rule) throws UserStoreException { if ((role == null) || (target == null) || (rule == null)) { return; } user.getAuthorizationManager().denyRole(role, target, rule); if (log.isDebugEnabled()) { log.debug("Permission: " + rule + " REMOVED from role: " + role + " for " + target); } }
public boolean hasMultipleUserStores() throws UserAdminException { try { return realm.getUserStoreManager().getSecondaryUserStoreManager() != null; } catch (UserStoreException e) { log.error(e); throw new UserAdminException("Unable to check for multiple user stores"); } }
public String[] listUsers(String filter, int maxLimit) throws UserAdminException { try { return realm.getUserStoreManager().listUsers(filter, maxLimit); } catch (UserStoreException e) { log.error(e.getMessage(), e); throw new UserAdminException(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); throw new UserAdminException(e.getMessage(), e); } }
public boolean isAddUserEnabled() throws Exception { UserRealm userRealm = IdentityTenantUtil.getRealm(null, null); if (userRealm != null) { UserStoreManager userStoreManager = userRealm.getUserStoreManager(); if (userStoreManager != null) { return !userStoreManager.isReadOnly(); } } return false; }
private boolean isUserExistsInDomain(UserStoreManager userStoreManager, String userName) throws UserStoreException { boolean isExists = false; if (userStoreManager.isExistingUser(userName)) { isExists = true; } return isExists; }
@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; }
public boolean hasMultipleUserStores() throws UserAdminException { try { return realm.getUserStoreManager().getSecondaryUserStoreManager() != null; } catch (UserStoreException e) { log.error(e); throw new UserAdminException("Unable to check for multiple user stores"); } }