use of org.wso2.carbon.user.mgt.common.UserStoreInfo in project carbon-identity-framework by wso2.
the class UserRealmProxy method getUserRealmInfo.
public UserRealmInfo getUserRealmInfo() throws UserAdminException {
UserRealmInfo userRealmInfo = new UserRealmInfo();
String userName = CarbonContext.getThreadLocalCarbonContext().getUsername();
try {
RealmConfiguration realmConfig = realm.getRealmConfiguration();
if (realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/manage/identity", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/manage/identity/usermgt/users", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/manage/identity/usermgt/passwords", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/manage/identity/usermgt/view", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/manage/identity/rolemgt/view", CarbonConstants.UI_PERMISSION_ACTION)) {
userRealmInfo.setAdminRole(realmConfig.getAdminRoleName());
userRealmInfo.setAdminUser(realmConfig.getAdminUserName());
userRealmInfo.setEveryOneRole(realmConfig.getEveryOneRoleName());
ClaimMapping[] defaultClaims = realm.getClaimManager().getAllClaimMappings(UserCoreConstants.DEFAULT_CARBON_DIALECT);
if (ArrayUtils.isNotEmpty(defaultClaims)) {
Arrays.sort(defaultClaims, new ClaimMappingsComparator());
}
List<String> fullClaimList = new ArrayList<String>();
List<String> requiredClaimsList = new ArrayList<String>();
List<String> defaultClaimList = new ArrayList<String>();
for (ClaimMapping claimMapping : defaultClaims) {
Claim claim = claimMapping.getClaim();
fullClaimList.add(claim.getClaimUri());
if (claim.isRequired()) {
requiredClaimsList.add(claim.getClaimUri());
}
if (claim.isSupportedByDefault()) {
defaultClaimList.add(claim.getClaimUri());
}
}
userRealmInfo.setUserClaims(fullClaimList.toArray(new String[fullClaimList.size()]));
userRealmInfo.setRequiredUserClaims(requiredClaimsList.toArray(new String[requiredClaimsList.size()]));
userRealmInfo.setDefaultUserClaims(defaultClaimList.toArray(new String[defaultClaimList.size()]));
}
List<UserStoreInfo> storeInfoList = new ArrayList<UserStoreInfo>();
List<String> domainNames = new ArrayList<String>();
RealmConfiguration secondaryConfig = realmConfig;
UserStoreManager secondaryManager = realm.getUserStoreManager();
while (true) {
secondaryConfig = secondaryManager.getRealmConfiguration();
UserStoreInfo userStoreInfo = getUserStoreInfo(secondaryConfig, secondaryManager);
if (secondaryConfig.isPrimary()) {
userRealmInfo.setPrimaryUserStoreInfo(userStoreInfo);
}
storeInfoList.add(userStoreInfo);
userRealmInfo.setBulkImportSupported(secondaryManager.isBulkImportSupported());
String domainName = secondaryConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
if (domainName != null && domainName.trim().length() > 0) {
domainNames.add(domainName.toUpperCase());
}
secondaryManager = secondaryManager.getSecondaryUserStoreManager();
if (secondaryManager == null) {
break;
}
}
if (storeInfoList.size() > 1) {
userRealmInfo.setMultipleUserStore(true);
}
userRealmInfo.setUserStoresInfo(storeInfoList.toArray(new UserStoreInfo[storeInfoList.size()]));
userRealmInfo.setDomainNames(domainNames.toArray(new String[domainNames.size()]));
String itemsPerPageString = realmConfig.getRealmProperty("MaxItemsPerUserMgtUIPage");
int itemsPerPage = 15;
try {
itemsPerPage = Integer.parseInt(itemsPerPageString);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Error parsing number of items per page, using default value", e);
}
}
userRealmInfo.setMaxItemsPerUIPage(itemsPerPage);
String maxPageInCacheString = realmConfig.getRealmProperty("MaxUserMgtUIPagesInCache");
int maxPagesInCache = 6;
try {
maxPagesInCache = Integer.parseInt(maxPageInCacheString);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Error parsing number of maximum pages in cache, using default value", e);
}
}
userRealmInfo.setMaxUIPagesInCache(maxPagesInCache);
String enableUIPageCacheString = realmConfig.getRealmProperty("EnableUserMgtUIPageCache");
boolean enableUIPageCache = true;
if (FALSE.equals(enableUIPageCacheString)) {
enableUIPageCache = false;
}
userRealmInfo.setEnableUIPageCache(enableUIPageCache);
} catch (Exception e) {
// previously logged so logging not needed
throw new UserAdminException(e.getMessage(), e);
}
return userRealmInfo;
}
use of org.wso2.carbon.user.mgt.common.UserStoreInfo in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceClient method getUserStoreDomains.
/**
* Get User Store Domains
*
* @return
* @throws AxisFault
*/
public String[] getUserStoreDomains() throws AxisFault {
try {
List<String> readWriteDomainNames = new ArrayList<String>();
UserStoreInfo[] storesInfo = userAdminStub.getUserRealmInfo().getUserStoresInfo();
for (UserStoreInfo storeInfo : storesInfo) {
if (!storeInfo.getReadOnly()) {
readWriteDomainNames.add(storeInfo.getDomainName());
}
}
return readWriteDomainNames.toArray(new String[readWriteDomainNames.size()]);
} catch (RemoteException | UserAdminUserAdminException e) {
throw new AxisFault("Error occurred while retrieving Read-Write User Store Domain IDs for logged-in" + " user's tenant realm");
}
}
use of org.wso2.carbon.user.mgt.common.UserStoreInfo in project carbon-identity-framework by wso2.
the class UserRealmProxy method getUserStoreInfo.
private UserStoreInfo getUserStoreInfo(RealmConfiguration realmConfig, UserStoreManager manager) throws UserAdminException {
try {
UserStoreInfo info = new UserStoreInfo();
info.setReadOnly(manager.isReadOnly());
boolean readRolesEnabled = Boolean.parseBoolean(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.READ_GROUPS_ENABLED));
info.setReadGroupsEnabled(readRolesEnabled);
boolean writeRolesEnabled = Boolean.parseBoolean(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.WRITE_GROUPS_ENABLED));
info.setWriteGroupsEnabled(!manager.isReadOnly() && readRolesEnabled && writeRolesEnabled);
info.setPasswordsExternallyManaged(realmConfig.isPasswordsExternallyManaged());
info.setPasswordRegEx(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_JS_REG_EX));
info.setPasswordRegExViolationErrorMsg(realmConfig.getUserStoreProperty("PasswordJavaRegExViolationErrorMsg"));
// TODO Need to get value from UserCoreConstants.RealmConfig.PROPERTY_PASSWORD_ERROR_MSG
info.setUsernameRegExViolationErrorMsg(realmConfig.getUserStoreProperty("UsernameJavaRegExViolationErrorMsg"));
// TODO Need to get value from UserCoreConstants.RealmConfig.PROPERTY_PASSWORD_ERROR_MSG
info.setUserNameRegEx(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USER_NAME_JS_REG_EX));
info.setRoleNameRegEx(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_ROLE_NAME_JS_REG_EX));
info.setExternalIdP(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP));
info.setBulkImportSupported(this.isBulkImportSupported(realmConfig));
info.setDomainName(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME));
boolean caseSensitiveUsername = IdentityUtil.isUserStoreCaseSensitive(manager);
info.setCaseSensitiveUsername(caseSensitiveUsername);
return info;
} catch (UserStoreException e) {
// previously logged so logging not needed
String domainName = manager.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
String errorMsg = "Error while getting user realm information for domain '" + domainName + "' : " + e.getMessage();
throw new UserAdminException(errorMsg, e);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new UserAdminException(e.getMessage(), e);
}
}
use of org.wso2.carbon.user.mgt.common.UserStoreInfo in project carbon-identity-framework by wso2.
the class IdentityProviderMgtServiceClient method getUserStoreDomains.
/**
* Retrieve the user store domains.
*
* @return Array of user store domains.
* @throws Exception if an error occurs while retrieving user store domains.
*/
public String[] getUserStoreDomains() throws Exception {
try {
List<String> readWriteDomainNames = new ArrayList<String>();
UserStoreInfo[] storesInfo = userAdminStub.getUserRealmInfo().getUserStoresInfo();
for (UserStoreInfo storeInfo : storesInfo) {
if (!storeInfo.getReadOnly()) {
readWriteDomainNames.add(storeInfo.getDomainName());
}
}
return readWriteDomainNames.toArray(new String[readWriteDomainNames.size()]);
} catch (Exception e) {
log.error("Error in retrieving User Store Domain IDs", e);
throw new Exception("Error occurred while retrieving Read-Write User Store Domain IDs " + "for logged-in user's tenant realm", e);
}
}
use of org.wso2.carbon.user.mgt.common.UserStoreInfo in project product-is by wso2.
the class IdentityProviderMgtServiceClient method getUserStoreDomains.
/**
* @return
* @throws Exception
*/
public String[] getUserStoreDomains() throws Exception {
try {
List<String> readWriteDomainNames = new ArrayList<String>();
UserStoreInfo[] storesInfo = userAdminStub.getUserRealmInfo().getUserStoresInfo();
for (UserStoreInfo storeInfo : storesInfo) {
if (!storeInfo.getReadOnly()) {
readWriteDomainNames.add(storeInfo.getDomainName());
}
}
return readWriteDomainNames.toArray(new String[readWriteDomainNames.size()]);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new Exception("Error occurred while retrieving Read-Write User Store Domain IDs for logged-in user's tenant realm");
}
}
Aggregations