Search in sources :

Example 6 with PasswordEncoder

use of org.springframework.security.authentication.encoding.PasswordEncoder in project pentaho-platform by pentaho.

the class ProxyPentahoUserRoleHelper method syncUsers.

/**
 * Synchronizes <code>user</code> with fields from <code>proxyUser</code>. The roles set of given
 * <code>user</code> is unmodified.
 */
public static IPentahoUser syncUsers(IPentahoUser user, ProxyPentahoUser proxyUser) {
    IPentahoUser syncedUser = user;
    if (syncedUser == null) {
        syncedUser = new PentahoUser(proxyUser.getName());
    }
    syncedUser.setDescription(proxyUser.getDescription());
    // password is not changed. If the user enters a value, set the password.
    if (!StringUtils.isBlank(proxyUser.getPassword())) {
        PasswordEncoder encoder = // $NON-NLS-1$
        PentahoSystem.get(PasswordEncoder.class, "passwordEncoder", PentahoSessionHolder.getSession());
        syncedUser.setPassword(encoder.encodePassword(proxyUser.getPassword(), null));
    }
    syncedUser.setEnabled(proxyUser.getEnabled());
    return syncedUser;
}
Also used : IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) PentahoUser(org.pentaho.platform.security.userroledao.PentahoUser) PasswordEncoder(org.springframework.security.authentication.encoding.PasswordEncoder) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)

Aggregations

PasswordEncoder (org.springframework.security.authentication.encoding.PasswordEncoder)6 Test (org.junit.Test)3 Node (org.dom4j.Node)2 DefaultPentahoPasswordEncoder (org.pentaho.platform.repository2.userroledao.jackrabbit.security.DefaultPentahoPasswordEncoder)2 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)1 PentahoUser (org.pentaho.platform.security.userroledao.PentahoUser)1 LdapShaPasswordEncoder (org.springframework.security.authentication.encoding.LdapShaPasswordEncoder)1 PlaintextPasswordEncoder (org.springframework.security.authentication.encoding.PlaintextPasswordEncoder)1