use of com.sun.identity.console.base.model.AMConsoleException 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.console.base.model.AMConsoleException 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);
}
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class UMUserPasswordResetOptionsViewBean method getQuestions.
private void getQuestions() {
UMUserPasswordResetOptionsModel model = (UMUserPasswordResetOptionsModel) getModel();
String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
try {
List questionAnswers = model.getUserAnswers(userId);
populateTableModel(questionAnswers);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class UMUserResourceOfferingAddViewBean method handleButton1Request.
protected void handleButton1Request(SMDiscoEntryData smData) {
UMUserResourceOfferingViewBean vb = (UMUserResourceOfferingViewBean) getViewBean(UMUserResourceOfferingViewBean.class);
UMUserResourceOfferingModel model = (UMUserResourceOfferingModel) getModel();
DiscoveryDataCache cache = DiscoveryDataCache.getInstance();
String cacheID = (String) getPageSessionAttribute(UMUserResourceOfferingViewBean.DATA_ID);
SMDiscoveryServiceData data = (SMDiscoveryServiceData) cache.getData(model.getUserSSOToken(), cacheID);
data.addResourceData(smData);
String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
try {
model.setUserDiscoEntry(userId, data);
removePageSessionAttribute(UMUserResourceOfferingViewBean.DATA_ID);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class UMUserResourceOfferingEditViewBean method handleButton1Request.
protected void handleButton1Request(SMDiscoEntryData smData) throws AMConsoleException {
UMUserResourceOfferingModel model = (UMUserResourceOfferingModel) getModel();
DiscoveryDataCache cache = DiscoveryDataCache.getInstance();
String cacheID = (String) getPageSessionAttribute(UMUserResourceOfferingViewBean.DATA_ID);
SMDiscoveryServiceData smEntry = cache.getData(model.getUserSSOToken(), cacheID);
int index = Integer.parseInt((String) getPageSessionAttribute(PGATTR_INDEX));
smEntry.replaceResourceData(index, smData);
String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
try {
model.setUserDiscoEntry(userId, smEntry);
removePageSessionAttribute(PG_SESSION_MODIFIED);
removePageSessionAttribute(PGATTR_ORIG_MECH_ID);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
Aggregations