本文整理汇总了Java中org.wso2.carbon.user.api.RealmConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java RealmConfiguration类的具体用法?Java RealmConfiguration怎么用?Java RealmConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealmConfiguration类属于org.wso2.carbon.user.api包,在下文中一共展示了RealmConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPasswordConformanceRegularExpression
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
/**
* Gets the regular expression which defines the format of the service principle, password.
*
* @return Regular expression.
* @throws DirectoryServerManagerException If unable to get RealmConfiguration.
*/
public String getPasswordConformanceRegularExpression() throws DirectoryServerManagerException {
try {
RealmConfiguration userStoreConfigurations = this.getUserRealm().getRealmConfiguration();
if (userStoreConfigurations != null) {
String passwordRegEx = userStoreConfigurations.getUserStoreProperty(
LDAPServerManagerConstants.SERVICE_PASSWORD_REGEX_PROPERTY);
if (passwordRegEx == null) {
return LDAPServerManagerConstants.DEFAULT_PASSWORD_REGULAR_EXPRESSION;
} else {
log.info("Service password format is " + passwordRegEx);
return passwordRegEx;
}
}
} catch (UserStoreException e) {
log.error("Unable to retrieve service password format.", e);
throw new DirectoryServerManagerException("Unable to retrieve service password format.", e);
}
return LDAPServerManagerConstants.DEFAULT_PASSWORD_REGULAR_EXPRESSION;
}
示例2: getServiceNameConformanceRegularExpression
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
/**
* Gets the regular expression which defines the format of the service principle.
* Current we use following like format,
* ftp/localhost
*
* @return Service principle name format as a regular expression.
* @throws DirectoryServerManagerException If unable to retrieve RealmConfiguration.
*/
public String getServiceNameConformanceRegularExpression() throws DirectoryServerManagerException {
try {
RealmConfiguration userStoreConfigurations = this.getUserRealm().getRealmConfiguration();
if (userStoreConfigurations != null) {
String serviceNameRegEx = userStoreConfigurations.getUserStoreProperty(
LDAPServerManagerConstants.SERVICE_PRINCIPLE_NAME_REGEX_PROPERTY);
if (serviceNameRegEx == null) {
return LDAPServerManagerConstants.DEFAULT_SERVICE_NAME_REGULAR_EXPRESSION;
} else {
log.info("Service name format is " + serviceNameRegEx);
return serviceNameRegEx;
}
}
} catch (UserStoreException e) {
log.error("Unable to retrieve service name format.", e);
throw new DirectoryServerManagerException("Unable to retrieve service name format.", e);
}
return LDAPServerManagerConstants.DEFAULT_SERVICE_NAME_REGULAR_EXPRESSION;
}
示例3: getDBConnection
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
private Connection getDBConnection(RealmConfiguration realmConfiguration) throws SQLException, UserStoreException {
Connection dbConnection = null;
DataSource dataSource = DatabaseUtil.createUserStoreDataSource(realmConfiguration);
if (dataSource != null) {
dbConnection = DatabaseUtil.getDBConnection(dataSource);
}
//if primary user store, DB connection can be same as realm data source.
if (dbConnection == null && realmConfiguration.isPrimary()) {
dbConnection = IdentityDatabaseUtil.getUserDBConnection();
} else if (dbConnection == null) {
throw new UserStoreException("Could not create a database connection to " +
realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME));
} else {
// db connection is present
}
dbConnection.setAutoCommit(false);
dbConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
return dbConnection;
}
示例4: getCountEnabledUserStores
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
/**
* Get the domain names of user stores which has count functionality enabled
*
* @return
*/
public static Set<String> getCountEnabledUserStores() throws UserStoreCounterException {
RealmConfiguration realmConfiguration;
Set<String> userStoreList = new HashSet<>();
try {
realmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration();
while (realmConfiguration != null) {
if (!Boolean.valueOf(realmConfiguration.getUserStoreProperty(
UserCoreConstants.RealmConfig.USER_STORE_DISABLED))) {
if (StringUtils.isNotEmpty(realmConfiguration.getUserStoreProperty(countRetrieverClass))) {
userStoreList.add(realmConfiguration
.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME));
}
}
realmConfiguration = realmConfiguration.getSecondaryRealmConfig();
}
} catch (UserStoreException e) {
throw new UserStoreCounterException("Error while getting the count enabled user stores", e);
}
return userStoreList;
}
示例5: getCounterInstanceForDomain
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
/**
* Create an instance of the given count retriever class
*
* @param domain
* @return
* @throws UserStoreCounterException
*/
public static UserStoreCountRetriever getCounterInstanceForDomain(String domain) throws UserStoreCounterException {
if (StringUtils.isEmpty(domain)) {
domain = IdentityUtil.getPrimaryDomainName();
}
RealmConfiguration realmConfiguration = getUserStoreList().get(domain);
if (realmConfiguration != null && realmConfiguration.getUserStoreProperty(countRetrieverClass) != null) {
String retrieverType = realmConfiguration.getUserStoreProperty(countRetrieverClass);
UserStoreCountRetriever userStoreCountRetriever = UserStoreCountDataHolder.getInstance()
.getCountRetrieverFactories().get(retrieverType).buildCountRetriever(realmConfiguration);
if (userStoreCountRetriever == null) {
throw new UserStoreCounterException(
"Could not create an instance of class: " + retrieverType + " for " +
"the domain: " + domain);
}
return userStoreCountRetriever;
} else {
return null;
}
}
示例6: isUserStoreEnabled
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
public static boolean isUserStoreEnabled(String domain) throws UserStoreCounterException {
RealmConfiguration realmConfiguration;
boolean isEnabled = false;
try {
realmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration();
do {
String userStoreDomain = realmConfiguration.
getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
if (domain.equals(userStoreDomain)) {
isEnabled = !Boolean.valueOf(realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.
USER_STORE_DISABLED));
break;
}
realmConfiguration = realmConfiguration.getSecondaryRealmConfig();
} while (realmConfiguration != null);
} catch (UserStoreException e) {
throw new UserStoreCounterException("Error occurred while getting Secondary Realm Configuration", e);
}
return isEnabled;
}
示例7: getRandomPasswordProperties
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
/**
* Generate the RandomPassword[] from secondaryRealmConfiguration for given userStoreClass
*
* @param userStoreClass Extract the mandatory properties of this class
* @param randomPhrase The randomly generated keyword which will be stored in
* RandomPassword object
* @param secondaryRealmConfiguration RealmConfiguration object consists the properties
* @return RandomPassword[] array for each property
*/
private RandomPassword[] getRandomPasswordProperties(String userStoreClass,
String randomPhrase, RealmConfiguration secondaryRealmConfiguration) {
//First check for mandatory field with #encrypt
Property[] mandatoryProperties = getMandatoryProperties(userStoreClass);
ArrayList<RandomPassword> randomPasswordArrayList = new ArrayList<RandomPassword>();
for (Property property : mandatoryProperties) {
String propertyName = property.getName();
if (property.getDescription().contains(UserStoreConfigurationConstant.ENCRYPT_TEXT)) {
RandomPassword randomPassword = new RandomPassword();
randomPassword.setPropertyName(propertyName);
randomPassword.setPassword(secondaryRealmConfiguration.getUserStoreProperty(propertyName));
randomPassword.setRandomPhrase(randomPhrase);
randomPasswordArrayList.add(randomPassword);
}
}
return randomPasswordArrayList.toArray(new RandomPassword[randomPasswordArrayList.size()]);
}
示例8: terminatingConfigurationContext
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
public void terminatingConfigurationContext(ConfigurationContext context) {
try {
org.wso2.carbon.user.api.UserRealm tenantRealm = CarbonContext
.getThreadLocalCarbonContext().getUserRealm();
RealmConfiguration realmConfig = tenantRealm.getRealmConfiguration();
AbstractUserStoreManager userStoreManager = (AbstractUserStoreManager) tenantRealm
.getUserStoreManager();
userStoreManager.clearAllSecondaryUserStores();
realmConfig.setSecondaryRealmConfig(null);
userStoreManager.setSecondaryUserStoreManager(null);
log.info("Unloaded all secondary user stores for tenant "
+ CarbonContext.getThreadLocalCarbonContext().getTenantId());
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
示例9: isAdminProfileSpoof
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
/**
* Checks whether the given user name is admin user name and the currently logged in user also admin.
* Only admin user is allowed for admin user profile related operations.
*
* @param username Username to be checked.
* @return True only if admin user.
* @throws UserStoreException Error occurred while retrieving realm configuration.
*/
private boolean isAdminProfileSpoof(String username) throws UserStoreException {
if (StringUtils.isEmpty(username)) {
return false;
}
RealmConfiguration realmConfiguration = getUserRealm().getRealmConfiguration();
String adminUsername = IdentityUtil.addDomainToName(realmConfiguration.getAdminUserName(),
IdentityUtil.getPrimaryDomainName());
String targetUsername = IdentityUtil.addDomainToName(username, IdentityUtil.getPrimaryDomainName());
// If the given user name is not the admin username, simply we can allow and return false. Our intention is to
// check whether a non admin user is trying to do operations on an admin profile.
if (!StringUtils.equalsIgnoreCase(targetUsername, adminUsername)) {
return false;
}
String loggedInUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
if (loggedInUsername != null) {
loggedInUsername = IdentityUtil.addDomainToName(loggedInUsername, IdentityUtil.getPrimaryDomainName());
}
// If the currently logged in user is also the admin user this isn't a spoof attempt. Hence returning false.
return !StringUtils.equalsIgnoreCase(loggedInUsername, adminUsername);
}
示例10: getUserStoreCountRetrieverService
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
public static UserStoreCountRetriever getUserStoreCountRetrieverService()
throws UserStoreCounterException {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
List<Object> countRetrieverFactories = ctx.getOSGiServices(AbstractCountRetrieverFactory.class, null);
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
RealmConfiguration realmConfiguration = realmService.getBootstrapRealmConfiguration();
String userStoreType;
//Ignoring Sonar warning as getUserStoreClass() returning string name of the class. So cannot use 'instanceof'.
if (JDBCUserStoreManager.class.getName().equals(realmConfiguration.getUserStoreClass())) {
userStoreType = JDBCCountRetrieverFactory.JDBC;
} else {
userStoreType = InternalCountRetrieverFactory.INTERNAL;
}
AbstractCountRetrieverFactory countRetrieverFactory = null;
for (Object countRetrieverFactoryObj : countRetrieverFactories) {
countRetrieverFactory = (AbstractCountRetrieverFactory) countRetrieverFactoryObj;
if (userStoreType.equals(countRetrieverFactory.getCounterType())) {
break;
}
}
if (countRetrieverFactory == null) {
return null;
}
return countRetrieverFactory.buildCountRetriever(realmConfiguration);
}
示例11: setup
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
@BeforeClass
public void setup() throws UserStoreException {
initMocks(this);
userManagementService = new UserManagementServiceImpl();
userStoreManager = Mockito.mock(UserStoreManager.class, Mockito.RETURNS_MOCKS);
deviceManagementProviderService = Mockito
.mock(DeviceManagementProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS);
userRealm = Mockito.mock(UserRealm.class);
RealmConfiguration realmConfiguration = Mockito.mock(RealmConfiguration.class);
Mockito.doReturn(null).when(realmConfiguration).getSecondaryRealmConfig();
Mockito.doReturn(realmConfiguration).when(userRealm).getRealmConfiguration();
enrollmentInvitation = new EnrollmentInvitation();
List<String> recipients = new ArrayList<>();
recipients.add(TEST_USERNAME);
enrollmentInvitation.setDeviceType("android");
enrollmentInvitation.setRecipients(recipients);
userList = new ArrayList<>();
userList.add(TEST_USERNAME);
}
示例12: getUserStoreCountRetrieverService
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
public static UserStoreCountRetriever getUserStoreCountRetrieverService()
throws UserStoreCounterException, UserStoreException {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
List<Object> countRetrieverFactories = ctx.getOSGiServices(AbstractCountRetrieverFactory.class, null);
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
RealmConfiguration realmConfiguration = realmService.getBootstrapRealmConfiguration();
String userStoreType;
if(DeviceMgtAPIUtils.getUserStoreManager() instanceof JDBCUserStoreManager) {
userStoreType = JDBCCountRetrieverFactory.JDBC;
} else {
userStoreType = InternalCountRetrieverFactory.INTERNAL;
}
AbstractCountRetrieverFactory countRetrieverFactory = null;
for (Object countRetrieverFactoryObj : countRetrieverFactories) {
countRetrieverFactory = (AbstractCountRetrieverFactory) countRetrieverFactoryObj;
if (userStoreType.equals(countRetrieverFactory.getCounterType())) {
break;
}
}
if (countRetrieverFactory == null) {
return null;
}
return countRetrieverFactory.buildCountRetriever(realmConfiguration);
}
示例13: getMultiAttributeSeparator
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
private String getMultiAttributeSeparator(String authenticatedUser, int tenantId) {
String claimSeparator = null;
String userDomain = IdentityUtil.extractDomainFromName(authenticatedUser);
try {
RealmConfiguration realmConfiguration = null;
RealmService realmService = OAuthComponentServiceHolder.getRealmService();
if (realmService != null && tenantId != MultitenantConstants.INVALID_TENANT_ID) {
UserStoreManager userStoreManager = (UserStoreManager) realmService.getTenantUserRealm(tenantId)
.getUserStoreManager();
realmConfiguration = userStoreManager.getSecondaryUserStoreManager(userDomain).getRealmConfiguration();
}
if (realmConfiguration != null) {
claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
if (claimSeparator != null && !claimSeparator.trim().isEmpty()) {
return claimSeparator;
}
}
} catch (UserStoreException e) {
log.error("Error occurred while getting the realm configuration, User store properties might not be " +
"returned", e);
}
return null;
}
示例14: getRealmConfiguration
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
public RealmConfigurationDTO getRealmConfiguration() throws UserStoreException {
UserRealm userRealm = getApplicableUserRealm();
RealmConfiguration realmConfig = userRealm.getRealmConfiguration();
RealmConfigurationDTO realmConfigDTO = new RealmConfigurationDTO();
realmConfigDTO.setRealmClassName(realmConfig.getRealmClassName());
realmConfigDTO.setUserStoreClass(realmConfig.getUserStoreClass());
realmConfigDTO.setAuthorizationManagerClass(realmConfig.getAuthorizationManagerClass());
realmConfigDTO.setAdminRoleName(realmConfig.getAdminRoleName());
realmConfigDTO.setAdminUserName(realmConfig.getAdminUserName());
realmConfigDTO.setAdminPassword(realmConfig.getAdminPassword());
realmConfigDTO.setEveryOneRoleName(realmConfig.getEveryOneRoleName());
realmConfigDTO.setUserStoreProperties(getPropertyValueArray(realmConfig
.getUserStoreProperties()));
realmConfigDTO.setAuthzProperties(getPropertyValueArray(realmConfig.getAuthzProperties()));
realmConfigDTO.setRealmProperties(getPropertyValueArray(realmConfig.getRealmProperties()));
return realmConfigDTO;
}
示例15: convertToRealmConfiguration
import org.wso2.carbon.user.api.RealmConfiguration; //导入依赖的package包/类
public static RealmConfiguration convertToRealmConfiguration(RealmConfigurationDTO realmConfigDTO) {
RealmConfiguration realmConfig = new RealmConfiguration();
realmConfig.setRealmClassName(realmConfigDTO.getRealmClassName());
realmConfig.setUserStoreClass(realmConfigDTO.getUserStoreClass());
realmConfig.setAuthorizationManagerClass(realmConfigDTO.getAuthorizationManagerClass());
realmConfig.setAdminRoleName(realmConfigDTO.getAdminRoleName());
realmConfig.setAdminUserName(realmConfigDTO.getAdminUserName());
realmConfig.setAdminPassword(realmConfigDTO.getAdminPassword());
realmConfig.setEveryOneRoleName(realmConfigDTO.getEveryOneRoleName());
realmConfig.setUserStoreProperties(getPropertyValueMap(realmConfigDTO
.getUserStoreProperties()));
realmConfig.setAuthzProperties(getPropertyValueMap(realmConfigDTO.getAuthzProperties()));
realmConfig.setRealmProperties(getPropertyValueMap(realmConfigDTO.getRealmProperties()));
return realmConfig;
}