use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntityEditViewBean method getEntitiesID.
protected Set getEntitiesID(Set entities) {
Set ids = new HashSet(entities.size() * 2);
for (Iterator iter = entities.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
ids.add(IdUtils.getUniversalId(entity));
}
return ids;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class EntityEditViewBean method getEntityDisplayNames.
protected List getEntityDisplayNames(Collection entities) {
List displayNames = null;
if ((entities != null) && !entities.isEmpty()) {
EntitiesModel model = (EntitiesModel) getModel();
Set names = new HashSet(entities.size() * 2);
for (Iterator iter = entities.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
names.add(AMFormatUtils.getIdentityDisplayName(model, entity));
}
displayNames = AMFormatUtils.sortItems(names, model.getUserLocale());
}
return (displayNames != null) ? displayNames : Collections.EMPTY_LIST;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class UMChangeUserPasswordModelImpl method getPassword.
/**
* Returns user password.
*
* @param userId Universal ID of user.
* @return user password.
* @throws AMConsoleException if password cannot be obtained.
*/
public String getPassword(String userId) throws AMConsoleException {
String password = "";
String[] params = { userId, AMAdminConstants.ATTR_USER_PASSWORD };
try {
logEvent("ATTEMPT_READ_IDENTITY_ATTRIBUTE_VALUE", params);
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
Set set = amid.getAttribute(AMAdminConstants.ATTR_USER_PASSWORD);
if ((set != null) && !set.isEmpty()) {
password = (String) set.iterator().next();
}
logEvent("SUCCEED_READ_IDENTITY_ATTRIBUTE_VALUE", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
logEvent("SSO_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
logEvent("IDM_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(strError);
}
return password;
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class UMChangeUserPasswordModelImpl method changePassword.
/**
* Modifies user password.
*
* @param userId Universal ID of user.
* @param password New password.
* @throws AMConsoleException if password cannot be modified.
*/
public void changePassword(String userId, String password) throws AMConsoleException {
String[] params = { userId, AMAdminConstants.ATTR_USER_PASSWORD };
try {
logEvent("ATTEMPT_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
Map map = new HashMap(2);
Set set = new HashSet(2);
set.add(password);
map.put(AMAdminConstants.ATTR_USER_PASSWORD, set);
amid.setAttributes(map);
amid.store();
logEvent("SUCCEED_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
logEvent("SSO_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
logEvent("IDM_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
if (e.getErrorCode().equals(IdRepoErrorCode.LDAP_EXCEPTION)) {
throw new AMConsoleException(e.getConstraintViolationDetails());
}
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.
the class UMChangeUserPasswordModelImpl method changePwd.
/**
* Modifies user password after validating old password.
*
* @param userId Universal ID of user.
* @param oldpwd old password.
* @param newpwd New password.
* @throws AMConsoleException if password cannot be modified.
*/
public void changePwd(String userId, String oldpwd, String newpwd) throws AMConsoleException {
String[] params = { userId, AMAdminConstants.ATTR_USER_OLD_PASSWORD };
try {
logEvent("ATTEMPT_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
amid.changePassword(oldpwd, newpwd);
logEvent("SUCCEED_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_OLD_PASSWORD, strError };
logEvent("SSO_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_OLD_PASSWORD, strError };
logEvent("IDM_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(strError);
}
}
Aggregations