use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class JsClaims method hasLocalClaim.
/**
* Check if there is a local claim by given name.
*
* @param claimUri The local claim URI
* @return Claim value of the user authenticated by the indicated IdP
*/
protected boolean hasLocalClaim(String claimUri) {
int usersTenantId = IdentityTenantUtil.getTenantId(authenticatedUser.getTenantDomain());
RealmService realmService = FrameworkServiceDataHolder.getInstance().getRealmService();
try {
UserRealm userRealm = realmService.getTenantUserRealm(usersTenantId);
Claim[] supportedClaims = IdentityClaimManager.getInstance().getAllSupportedClaims((org.wso2.carbon.user.core.UserRealm) userRealm);
for (Claim claim : supportedClaims) {
if (claim.getClaimUri().equals(claimUri)) {
return true;
}
}
} catch (UserStoreException e) {
LOG.error("Error when retrieving user realm for tenant : " + usersTenantId, e);
} catch (IdentityException e) {
LOG.error("Error when initializing identity claim manager.", e);
}
return false;
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class UserIdentityManagementUtil method updateUserIdentityClaims.
/**
* Updates users recovery data such as the phone number, email etc
*
* @param userStoreManager
* @param userIdentityRecoveryData
* @throws IdentityException
*/
public static void updateUserIdentityClaims(String userName, UserStoreManager userStoreManager, UserIdentityClaimDTO[] userIdentityRecoveryData) throws IdentityException {
UserIdentityDataStore store = IdentityMgtConfig.getInstance().getIdentityDataStore();
UserIdentityClaimsDO userIdentityDO = store.load(userName, userStoreManager);
if (userIdentityDO != null) {
userIdentityDO.updateUserIdentityRecoveryData(userIdentityRecoveryData);
store.store(userIdentityDO, userStoreManager);
} else {
throw IdentityException.error("No user account found for user " + userName);
}
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class UserIdentityManagementUtil method invalidateUserIdentityMetadata.
/**
* Invalidates the identity metadata
*
* @param userName
* @param tenantId
* @param metadataType
* @param metadata
* @throws IdentityException
*/
public static void invalidateUserIdentityMetadata(String userName, int tenantId, String metadataType, String metadata) throws IdentityException {
JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
UserRecoveryDataDO metadataDO = new UserRecoveryDataDO(userName, tenantId, metadataType, metadata);
store.invalidate(metadataDO);
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class UserIdentityManagementUtil method getPrimaryQuestions.
/**
* Returns an array of primary security questions
*
* @param tenantId
* @return
* @throws IdentityException
*/
public static String[] getPrimaryQuestions(int tenantId) throws IdentityException {
JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
UserRecoveryDataDO[] metadata = store.load("TENANT", tenantId);
if (metadata.length < 1) {
return new String[0];
}
List<String> validSecurityQuestions = new ArrayList<String>();
String[] questionsList = new String[validSecurityQuestions.size()];
return validSecurityQuestions.toArray(questionsList);
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class UserIdentityManagementUtil method removePrimaryQuestions.
/**
* Remove primary security questions
*
* @param tenantId
* @throws IdentityException
*/
public static void removePrimaryQuestions(String[] primarySecurityQuestion, int tenantId) throws IdentityException {
UserRecoveryDataDO[] metadata = new UserRecoveryDataDO[primarySecurityQuestion.length];
int i = 0;
for (String secQuestion : primarySecurityQuestion) {
if (!secQuestion.contains(UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI)) {
throw IdentityException.error("One or more security questions does not contain the namespace " + UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI);
}
metadata[i++] = new UserRecoveryDataDO("TENANT", tenantId, UserRecoveryDataDO.METADATA_PRIMARAY_SECURITY_QUESTION, secQuestion);
}
}
Aggregations