Search in sources :

Example 1 with PWResetException

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;
}
Also used : PWResetException(com.sun.identity.password.ui.model.PWResetException) PasswordGenerator(com.sun.identity.password.plugins.PasswordGenerator) RandomPasswordGenerator(com.sun.identity.password.plugins.RandomPasswordGenerator) RandomPasswordGenerator(com.sun.identity.password.plugins.RandomPasswordGenerator)

Example 2 with PWResetException

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();
        }
    }
}
Also used : PWResetException(com.sun.identity.password.ui.model.PWResetException) RequestContext(com.iplanet.jato.RequestContext) ISLocaleContext(com.sun.identity.common.ISLocaleContext) Map(java.util.Map) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 3 with PWResetException

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());
    }
}
Also used : PWResetException(com.sun.identity.password.ui.model.PWResetException) JarInputStream(java.util.jar.JarInputStream) JarOutputStream(java.util.jar.JarOutputStream) IOException(java.io.IOException) JarEntry(java.util.jar.JarEntry)

Example 4 with PWResetException

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);
    }
}
Also used : SendFailedException(javax.mail.SendFailedException) PWResetException(com.sun.identity.password.ui.model.PWResetException) MessagingException(javax.mail.MessagingException) IdRepoException(com.sun.identity.idm.IdRepoException) ResourceBundle(java.util.ResourceBundle) SSOException(com.iplanet.sso.SSOException)

Aggregations

PWResetException (com.sun.identity.password.ui.model.PWResetException)4 RequestContext (com.iplanet.jato.RequestContext)1 SSOException (com.iplanet.sso.SSOException)1 ISLocaleContext (com.sun.identity.common.ISLocaleContext)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 PasswordGenerator (com.sun.identity.password.plugins.PasswordGenerator)1 RandomPasswordGenerator (com.sun.identity.password.plugins.RandomPasswordGenerator)1 PWResetQuestionModel (com.sun.identity.password.ui.model.PWResetQuestionModel)1 IOException (java.io.IOException)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 JarEntry (java.util.jar.JarEntry)1 JarInputStream (java.util.jar.JarInputStream)1 JarOutputStream (java.util.jar.JarOutputStream)1 MessagingException (javax.mail.MessagingException)1 SendFailedException (javax.mail.SendFailedException)1