org.wso2.carbon.user.core.UserStoreConfigConstants Java Examples
The following examples show how to use
org.wso2.carbon.user.core.UserStoreConfigConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecondaryUserStoreConfigurationUtil.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
private static Document getDocument(UserStoreDTO userStoreDTO, boolean editSecondaryUserStore, DocumentBuilder documentBuilder, String existingDomainName) throws IdentityUserStoreMgtException { Document doc = documentBuilder.newDocument(); //create UserStoreManager element Element userStoreElement = doc.createElement(UserCoreConstants.RealmConfig.LOCAL_NAME_USER_STORE_MANAGER); doc.appendChild(userStoreElement); Attr attrClass = doc.createAttribute("class"); if (userStoreDTO != null) { attrClass.setValue(userStoreDTO.getClassName()); userStoreElement.setAttributeNode(attrClass); if (userStoreDTO.getClassName() != null) { addProperties(existingDomainName, userStoreDTO.getClassName(), userStoreDTO.getProperties(), doc, userStoreElement, editSecondaryUserStore); } addProperty(UserStoreConfigConstants.DOMAIN_NAME, userStoreDTO.getDomainId(), doc, userStoreElement, false); addProperty(UserStoreConfigurationConstant.DESCRIPTION, userStoreDTO.getDescription(), doc, userStoreElement, false); } return doc; }
Example #2
Source File: UserIdtoUser.java From identity-api-server with Apache License 2.0 | 5 votes |
private User extractUser(String userId, String tenantDomain) { try { String decodedUsername = new String(Base64.getDecoder().decode(userId), StandardCharsets.UTF_8); if (StringUtils.isBlank(userId)) { throw new WebApplicationException("UserID is empty."); } String[] strComponent = decodedUsername.split("/"); String username; String realm = UserStoreConfigConstants.PRIMARY; if (strComponent.length == 1) { username = strComponent[0]; } else if (strComponent.length == 2) { realm = strComponent[0]; username = strComponent[1]; } else { throw new WebApplicationException("Provided UserID is " + "not in the correct format."); } User user = new User(); user.setUserName(username); user.setUserStoreDomain(realm); user.setTenantDomain(tenantDomain); return user; } catch (Exception e) { throw new APIError(Response.Status.BAD_REQUEST, new ErrorResponse.Builder().withCode(Constants.ErrorMessages.ERROR_CODE_INVALID_USERNAME.getCode()) .withMessage(Constants.ErrorMessages.ERROR_CODE_INVALID_USERNAME.getMessage()) .withDescription(Constants.ErrorMessages.ERROR_CODE_INVALID_USERNAME.getDescription()) .build(log, e, "Invalid userId: " + userId)); } }
Example #3
Source File: DatabaseBasedUserStoreDAOImpl.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
private UserStoreDTO getUserStoreDTO(RealmConfiguration secondaryRealmConfiguration, Map<String, String> userStoreProperties) { UserStoreDTO userStoreDTO = new UserStoreDTO(); userStoreDTO.setClassName(secondaryRealmConfiguration.getUserStoreClass()); userStoreDTO.setDescription(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigurationConstant .DESCRIPTION)); userStoreDTO.setDomainId(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigConstants .DOMAIN_NAME)); userStoreDTO.setRepositoryClass(DATABASE_BASED); if (userStoreProperties.get(DISABLED) != null) { userStoreDTO.setDisabled(Boolean.valueOf(userStoreProperties.get(DISABLED))); } return userStoreDTO; }
Example #4
Source File: FileBasedUserStoreDAOImpl.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
private UserStoreDTO getUserStoreDTO(RealmConfiguration secondaryRealmConfiguration, Map<String, String> userStoreProperties) { UserStoreDTO userStoreDTO = new UserStoreDTO(); userStoreDTO.setClassName(secondaryRealmConfiguration.getUserStoreClass()); userStoreDTO.setDescription(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigurationConstant .DESCRIPTION)); userStoreDTO.setDomainId(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigConstants .DOMAIN_NAME)); userStoreDTO.setRepositoryClass(FILE_BASED); if (userStoreProperties.get(DISABLED) != null) { userStoreDTO.setDisabled(Boolean.valueOf(userStoreProperties.get(DISABLED))); } return userStoreDTO; }
Example #5
Source File: CarbonRemoteUserStoreManger.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * @param realmConfig * @param properties * @throws Exception */ public CarbonRemoteUserStoreManger(RealmConfiguration realmConfig, Map properties) throws Exception { ConfigurationContext configurationContext = ConfigurationContextFactory .createDefaultConfigurationContext(); Map<String, TransportOutDescription> transportsOut = configurationContext .getAxisConfiguration().getTransportsOut(); for (TransportOutDescription transportOutDescription : transportsOut.values()) { transportOutDescription.getSender().init(configurationContext, transportOutDescription); } String[] serverUrls = realmConfig.getUserStoreProperty(SERVER_URLS).split(","); for (int i = 0; i < serverUrls.length; i++) { remoteUserStore = new WSUserStoreManager( realmConfig.getUserStoreProperty(REMOTE_USER_NAME), realmConfig.getUserStoreProperty(PASSWORD), serverUrls[i], configurationContext); if (log.isDebugEnabled()) { log.debug("Remote Servers for User Management : " + serverUrls[i]); } remoteServers.put(serverUrls[i], remoteUserStore); } this.realmConfig = realmConfig; domainName = realmConfig.getUserStoreProperty(UserStoreConfigConstants.DOMAIN_NAME); }
Example #6
Source File: CarbonRemoteUserStoreManger.java From carbon-identity with Apache License 2.0 | 4 votes |
/** * */ @Override public Properties getDefaultUserStoreProperties() { Properties properties = new Properties(); Property[] mandatoryProperties = null; Property[] optionalProperties = null; Property remoteServerUserName = new Property( REMOTE_USER_NAME, "", "Remote Sever Username#Name of a user from the remote server, having enough privileges for user management", null); Property password = new Property(PASSWORD, "", "Remote Server Password#The password correspoing to the remote server " + "username#encrypt", null); Property serverUrls = new Property( SERVER_URLS, "", "Remote Server URL(s)#Remote server URLs. e.g.: https://ca-datacenter/services,https://va-datacenter/services", null); Property disabled = new Property("Disabled", "false", "Disabled#Check to disable the user store", null); Property passwordJavaScriptRegEx = new Property( UserStoreConfigConstants.passwordJavaScriptRegEx, "^[\\S]{5,30}$", "Password RegEx (Javascript)#" + UserStoreConfigConstants.passwordJavaScriptRegExDescription, null); Property usernameJavaScriptRegEx = new Property( UserStoreConfigConstants.usernameJavaScriptRegEx, "^[\\S]{3,30}$", "Username RegEx (Javascript)#" + UserStoreConfigConstants.usernameJavaRegExDescription, null); Property roleNameJavaScriptRegEx = new Property( UserStoreConfigConstants.roleNameJavaScriptRegEx, "^[\\S]{3,30}$", "Role Name RegEx (Javascript)#" + UserStoreConfigConstants.roleNameJavaScriptRegExDescription, null); mandatoryProperties = new Property[] {remoteServerUserName, password, serverUrls, passwordJavaScriptRegEx, usernameJavaScriptRegEx, roleNameJavaScriptRegEx}; optionalProperties = new Property[] {disabled}; properties.setOptionalProperties(optionalProperties); properties.setMandatoryProperties(mandatoryProperties); return properties; }
Example #7
Source File: UserStoreConfigAdminService.java From carbon-identity with Apache License 2.0 | 4 votes |
/** * Get details of current secondary user store configurations * * @return : Details of all the configured secondary user stores * @throws UserStoreException */ public UserStoreDTO[] getSecondaryRealmConfigurations() throws IdentityUserStoreMgtException { ArrayList<UserStoreDTO> domains = new ArrayList<UserStoreDTO>(); RealmConfiguration secondaryRealmConfiguration = null; try { secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm(). getRealmConfiguration().getSecondaryRealmConfig(); } catch (UserStoreException e) { String errorMessage = "Error while retrieving user store configurations"; log.error(errorMessage, e); throw new IdentityUserStoreMgtException(errorMessage); } //not editing primary store if (secondaryRealmConfiguration == null) { return null; } else { do { Map<String, String> userStoreProperties = secondaryRealmConfiguration.getUserStoreProperties(); UserStoreDTO userStoreDTO = new UserStoreDTO(); String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT); if (uuid == null) { uuid = UUID.randomUUID().toString(); } String randomPhrase = UserStoreConfigurationConstant.RANDOM_PHRASE_PREFIX + uuid; String className = secondaryRealmConfiguration.getUserStoreClass(); userStoreDTO.setClassName(secondaryRealmConfiguration.getUserStoreClass()); userStoreDTO.setDescription(secondaryRealmConfiguration.getUserStoreProperty(DESCRIPTION)); userStoreDTO.setDomainId(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigConstants.DOMAIN_NAME)); if (userStoreProperties.get(DISABLED) != null) { userStoreDTO.setDisabled(Boolean.valueOf(userStoreProperties.get(DISABLED))); } userStoreProperties.put("Class", className); userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid); RandomPassword[] randomPasswords = getRandomPasswordProperties(className, randomPhrase, secondaryRealmConfiguration); if (randomPasswords != null) { updatePasswordContainer(randomPasswords, uuid); } String originalPassword = null; if (userStoreProperties.containsKey(UserStoreConfigConstants.connectionPassword)) { originalPassword = userStoreProperties.get(UserStoreConfigConstants.connectionPassword); userStoreProperties.put(UserStoreConfigConstants.connectionPassword, randomPhrase); } if (userStoreProperties.containsKey(JDBCRealmConstants.PASSWORD)) { originalPassword = userStoreProperties.get(JDBCRealmConstants.PASSWORD); userStoreProperties.put(JDBCRealmConstants.PASSWORD, randomPhrase); } userStoreDTO.setProperties(convertMapToArray(userStoreProperties)); //Now revert back to original password if (userStoreProperties.containsKey(UserStoreConfigConstants.connectionPassword)) { if (originalPassword != null) { userStoreProperties.put(UserStoreConfigConstants.connectionPassword, originalPassword); } } if (userStoreProperties.containsKey(JDBCRealmConstants.PASSWORD)) { if (originalPassword != null) { userStoreProperties.put(JDBCRealmConstants.PASSWORD, originalPassword); } } domains.add(userStoreDTO); secondaryRealmConfiguration = secondaryRealmConfiguration.getSecondaryRealmConfig(); } while (secondaryRealmConfiguration != null); } return domains.toArray(new UserStoreDTO[domains.size()]); }