private UserRealm getRealm() throws ClaimManagementException { try { return AdminServicesUtil.getUserRealm(); } catch (CarbonException e) { throw new ClaimManagementException("Error while trying get User Realm.", e); } }
@SuppressWarnings("deprecation") public static Registry getRegistry() throws IdentityException { try { return AdminServicesUtil.getSystemRegistry(); } catch (CarbonException e) { log.error("Error obtaining a registry instance", e); throw IdentityException.error("Error obtaining a registry instance", e); } }
private UserRealm getRealm() throws ClaimManagementException { try { return AdminServicesUtil.getUserRealm(); } catch (CarbonException e) { throw new ClaimManagementException("Error while trying get User Realm.", e); } }
@SuppressWarnings("deprecation") public static Registry getRegistry() throws IdentityException { try { return AdminServicesUtil.getSystemRegistry(); } catch (CarbonException e) { log.error("Error obtaining a registry instance", e); throw IdentityException.error("Error obtaining a registry instance", e); } }
private static boolean isUsernameEncryptionEnabled() throws CarbonException, UserStoreException { return Boolean.parseBoolean(AdminServicesUtil.getUserRealm().getRealmConfiguration() .getRealmProperties().get(ENCRYPT_USERNAME_IN_URL)); } }
@SuppressWarnings("deprecation") public static Registry getRegistry() throws IdentityException { try { return AdminServicesUtil.getSystemRegistry(); } catch (CarbonException e) { log.error("Error obtaining a registry instance", e); throw IdentityException.error("Error obtaining a registry instance", e); } }
private static boolean isUsernameEncryptionEnabled() throws CarbonException, UserStoreException { return Boolean.parseBoolean(AdminServicesUtil.getUserRealm().getRealmConfiguration() .getRealmProperties().get(ENCRYPT_USERNAME_IN_URL)); } }
public static Registry getRegistry(String domainName, String username) throws IdentityException { HttpSession httpSess = getHttpSession(); if (httpSess != null) { if (httpSess.getAttribute(ServerConstants.USER_LOGGED_IN) != null) { try { return AdminServicesUtil.getSystemRegistry(); } catch (CarbonException e) { log.error("Error obtaining a registry instance", e); throw IdentityException.error( "Error obtaining a registry instance", e); } } } return getRegistryForAnonymousSession(domainName, username); }
private static boolean isUsernameEncryptionEnabled() throws CarbonException, UserStoreException { return Boolean.parseBoolean(AdminServicesUtil.getUserRealm().getRealmConfiguration() .getRealmProperties().get(ENCRYPT_USERNAME_IN_URL)); } /**
public static Registry getRegistry(String domainName, String username) throws IdentityException { HttpSession httpSess = getHttpSession(); if (httpSess != null) { if (httpSess.getAttribute(ServerConstants.USER_LOGGED_IN) != null) { try { return AdminServicesUtil.getSystemRegistry(); } catch (CarbonException e) { log.error("Error obtaining a registry instance", e); throw IdentityException.error( "Error obtaining a registry instance", e); } } } return getRegistryForAnonymousSession(domainName, username); }
public void removeOpenID(String openID) { try { IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager(); persistenceManager .removeOpenIDSignUp(IdentityTenantUtil.getRegistry(), AdminServicesUtil.getUserRealm(), openID); } catch (Exception e) { log.error("Error instantiating a Persistence Manager.", e); } }
public static Registry getRegistry(String domainName, String username) throws IdentityException { HttpSession httpSess = getHttpSession(); if (httpSess != null) { if (httpSess.getAttribute(ServerConstants.USER_LOGGED_IN) != null) { try { return AdminServicesUtil.getSystemRegistry(); } catch (CarbonException e) { log.error("Error obtaining a registry instance", e); throw IdentityException.error( "Error obtaining a registry instance", e); } } } return getRegistryForAnonymousSession(domainName, username); }
public void removeOpenID(String openID) { try { IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager(); persistenceManager .removeOpenIDSignUp(IdentityTenantUtil.getRegistry(), AdminServicesUtil.getUserRealm(), openID); } catch (Exception e) { log.error("Error instantiating a Persistence Manager.", e); } }
/** * Check whether the account is attached with account lock bypassable role. * * @param userName user name whos roles needs to be listed * @return true or false based on user roles * @throws CarbonException, UserStoreException */ public static boolean isAccountLockable(String userName) throws CarbonException, UserStoreException { boolean isLockable = true; String[] roleList = AdminServicesUtil.getUserRealm().getUserStoreManager().getRoleListOfUser(userName); if (roleList != null) { for (String roleName : roleList) { if (roleName.equals(bypassRoleName)) { isLockable = false; break; } } } return isLockable; } }
public void addOpenID(String openID) { try { IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager(); String userName = CarbonContext.getThreadLocalCarbonContext().getUsername(); persistenceManager.doOpenIdSignUp(IdentityTenantUtil.getRegistry() , AdminServicesUtil.getUserRealm(), openID, userName); } catch (Exception e) { log.error("Error instantiating a Persistence Manager.", e); } }
public void addOpenID(String openID) { try { IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager(); String userName = CarbonContext.getThreadLocalCarbonContext().getUsername(); persistenceManager.doOpenIdSignUp(IdentityTenantUtil.getRegistry() , AdminServicesUtil.getUserRealm(), openID, userName); } catch (Exception e) { log.error("Error instantiating a Persistence Manager.", e); } }
/** * @param userName * @return * @throws Exception */ public String[] getAllOpenIDs(String userName) throws IdentityProviderException { validateInputParameters(new String[] { userName }, "Invalid parameters provided to getAllOpenIDs"); IdentityPersistenceManager persistenceManager = null; String[] externalOpenIDs = null; try { persistenceManager = IdentityPersistenceManager.getPersistanceManager(); // Get all External OpenIDs of an user externalOpenIDs = persistenceManager.getOpenIDsForUser(IdentityTenantUtil.getRegistry() , AdminServicesUtil.getUserRealm(), userName); } catch (IdentityException | CarbonException e) { throw new IdentityProviderException("Failed to retrieve OpenID for user " + userName, e); } String[] openIDset = new String[externalOpenIDs.length + 1]; // Index zero of the returning array would be the primary OpenID. openIDset[0] = getPrimaryOpenID(userName); // Append all the external OpenIDs to the end of the array. for (int i = 0; i < externalOpenIDs.length; i++) { openIDset[i + 1] = externalOpenIDs[i]; } return openIDset; }
/** * @param userName * @return * @throws Exception */ public String[] getAllOpenIDs(String userName) throws IdentityProviderException { validateInputParameters(new String[] { userName }, "Invalid parameters provided to getAllOpenIDs"); IdentityPersistenceManager persistenceManager = null; String[] externalOpenIDs = null; try { persistenceManager = IdentityPersistenceManager.getPersistanceManager(); // Get all External OpenIDs of an user externalOpenIDs = persistenceManager.getOpenIDsForUser(IdentityTenantUtil.getRegistry() , AdminServicesUtil.getUserRealm(), userName); } catch (IdentityException | CarbonException e) { throw new IdentityProviderException("Failed to retrieve OpenID for user " + userName, e); } String[] openIDset = new String[externalOpenIDs.length + 1]; // Index zero of the returning array would be the primary OpenID. openIDset[0] = getPrimaryOpenID(userName); // Append all the external OpenIDs to the end of the array. for (int i = 0; i < externalOpenIDs.length; i++) { openIDset[i + 1] = externalOpenIDs[i]; } return openIDset; }
public static Permission[] getRoleUIPermissions(String roleName, String[] rawPermissions) throws UserAdminException { Permission[] permissions = new Permission[0]; try { if (rawPermissions == null || rawPermissions.length == 0) { return permissions; } String[] optimizedList = UserCoreUtil.optimizePermissions(rawPermissions); UserRealm realm = AdminServicesUtil.getUserRealm(); AuthorizationManager authMan = realm.getAuthorizationManager(); permissions = new Permission[optimizedList.length]; int i = 0; for (String path : optimizedList) { permissions[i++] = new Permission(path, UserMgtConstants.EXECUTE_ACTION); } } catch (UserStoreException e) { // not logging already logged throw new UserAdminException(e.getMessage(), e); } catch (CarbonException e) { throw new UserAdminException(e.getMessage(), e); } return permissions; }
public static void updateRoleUIPermission(String roleName, String[] rawPermissions) throws UserAdminException { try { String[] optimizedList = UserCoreUtil.optimizePermissions(rawPermissions); UserRealm realm = AdminServicesUtil.getUserRealm(); AuthorizationManager authMan = realm.getAuthorizationManager(); authMan.clearRoleActionOnAllResources(roleName, UserMgtConstants.EXECUTE_ACTION); for (String path : optimizedList) { authMan.authorizeRole(roleName, path, UserMgtConstants.EXECUTE_ACTION); } } catch (UserStoreException e) { // not logging already logged throw new UserAdminException(e.getMessage(), e); } catch (CarbonException e) { throw new UserAdminException(e.getMessage(), e); } }