use of com.sun.identity.password.ui.model.PWResetException in project OpenAM by OpenRock.
the class UpgradeServices method generateBackupPassword.
private String generateBackupPassword() {
PasswordGenerator passwordGenerator = new RandomPasswordGenerator();
String password = null;
try {
password = passwordGenerator.generatePassword(null);
} catch (PWResetException pre) {
// default implementation will not do this
password = DEFAULT_PASSWORD;
}
return password;
}
use of com.sun.identity.password.ui.model.PWResetException in project OpenAM by OpenRock.
the class PWResetQuestionViewBean method handleBtnOKRequest.
/**
* Handles form submission request for next button. It will
* forward to <code>PWResetSuccessViewBean</code> if the answers
* are correct for the questions.
*
* @param event request invocation event
*/
public void handleBtnOKRequest(RequestInvocationEvent event) {
PWResetQuestionModel model = (PWResetQuestionModel) getModel();
String orgDN = (String) getPageSessionAttribute(ORG_DN);
String userDN = (String) getPageSessionAttribute(USER_DN);
RequestContext reqContext = event.getRequestContext();
ISLocaleContext localeContext = new ISLocaleContext();
localeContext.setLocale(reqContext.getRequest());
java.util.Locale localeObj = localeContext.getLocale();
String locale = localeObj.toString();
model.setUserLocale(locale);
PWResetQuestionTiledView tView = (PWResetQuestionTiledView) getChild(PASSWORD_RESET_TILEDVIEW);
Map map = tView.getAnswers();
if (tView.isAnswerBlank()) {
setErrorMessage(model.getErrorTitle(), model.getMissingAnswerMessage());
forwardTo();
} else {
try {
model.resetPassword(userDN, orgDN, map);
PWResetSuccessViewBean vb = (PWResetSuccessViewBean) getViewBean(PWResetSuccessViewBean.class);
vb.setResetMessage(model.getPasswordResetMessage());
vb.setPageSessionAttribute(URL_LOCALE, locale);
vb.forwardTo(getRequestContext());
} catch (PWResetException pwe) {
if (!model.isUserLockout(userDN, orgDN)) {
setErrorMessage(model.getErrorTitle(), pwe.getMessage());
}
forwardTo();
}
}
}
use of com.sun.identity.password.ui.model.PWResetException in project OpenAM by OpenRock.
the class CreateSoapSTSDeployment method processFileContents.
/*
This method will read jar entries from the soapSTSServerJar file and write them to the modifiedSoapSTSServerJar file,
updating the config.properties file with user-specified values, and adding any custom wsdl files or keystore files.
*/
@SuppressWarnings("unchecked")
private void processFileContents(JarInputStream soapSTSServerWar, JarOutputStream modifiedSoapSTSServerWar, Map mapParams) throws WorkflowException {
try (JarInputStream in = soapSTSServerWar;
JarOutputStream out = modifiedSoapSTSServerWar) {
final byte[] buffer = new byte[4096];
final String agentPasswordEncryptionKey = getAgentPasswordEncryptionKey();
final String encryptedAgentPassword = encryptAgentPassword(agentPasswordEncryptionKey, getStringParam(mapParams, SOAP_AGENT_PASSWORD_PARAM));
JarEntry currentEntry = in.getNextJarEntry();
while (currentEntry != null) {
//if we are dealing with the property file, it needs to be updated with user-specified state, not just copied
if (SOAP_PROPERTY_FILE_JAR_ENTRY_NAME.equals(currentEntry.getName())) {
updatePropertyFile(in, out, mapParams, encryptedAgentPassword);
} else {
writeBitsToModifiedWar(in, out, currentEntry, buffer);
}
currentEntry = in.getNextJarEntry();
}
//now add any custom wsdl and keystore files
processUserSpecifiedKeystoreAndCustomWsdlFiles(out, mapParams);
//careful about calling this not as the last modification done to the .war. KeyStores write themselves to the
//OutputStream, and close the stream itself. Seems to have to be the last thing done to the JarOutputStream.
addAgentPasswordKeystore(out, agentPasswordEncryptionKey);
} catch (IOException | PWResetException e) {
throw new WorkflowException("soap.sts.deployment.workflow.error.exception.transferring.jar.file.contents", e.toString());
}
}
use of com.sun.identity.password.ui.model.PWResetException in project OpenAM by OpenRock.
the class EmailPassword method notifyPassword.
/**
* Notifies user when password is changed.
*
* @param user <code>AMIdentity</code> object
* @param password new password
* @param locale user locale
* @throws PWResetException if password cannot be notified
*/
public void notifyPassword(AMIdentity user, String password, Locale locale) throws PWResetException {
ResourceBundle rb = null;
try {
Set<String> set = user.getAttribute(model.getMailAttribute(user.getRealm()));
Set<String> localeSet = user.getAttribute(Constants.USER_LOCALE_ATTR);
if (localeSet == null || localeSet.isEmpty()) {
userLocale = locale;
} else {
String localeStr = localeSet.iterator().next();
userLocale = com.sun.identity.shared.locale.Locale.getLocale(localeStr);
}
rb = PWResetResBundleCacher.getBundle(bundleName, userLocale);
if (set == null || set.isEmpty()) {
model.debugWarning("There is no email address for this user.");
throw new PWResetException(rb.getString("noEmail.message"));
} else {
String emailAddress = set.iterator().next();
sendEmailToUser(emailAddress, password);
}
} catch (SSOException e) {
model.debugWarning("EmailPassword.notifyPassword", e);
throw new PWResetException(e);
} catch (IdRepoException e) {
model.debugWarning("EmailPassword.notifyPassword", e);
throw new PWResetException(e);
} catch (SendFailedException e) {
model.debugWarning("EmailPassword.notifyPassword", e);
throw new PWResetException(rb.getString("sendEmailFailed.message"));
} catch (MessagingException e) {
model.debugWarning("EmailPassword.notifyPassword", e);
throw new PWResetException(e);
}
}
Aggregations