Search in sources :

Example 41 with PasswordEncoder

use of org.springframework.security.crypto.password.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.encode(proxyUser.getPassword()));
    }
    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.crypto.password.PasswordEncoder) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)

Example 42 with PasswordEncoder

use of org.springframework.security.crypto.password.PasswordEncoder in project pentaho-platform by pentaho.

the class SpringSecurityHibernateConfigTest method testGetPasswordEncoder_ClassNotFound.

@Test
public void testGetPasswordEncoder_ClassNotFound() throws Exception {
    config = new SpringSecurityHibernateConfig(document);
    Node node = mock(Node.class);
    when(node.getText()).thenReturn("org.pentaho.ClassNotFoundEncoder");
    when(document.selectSingleNode(nullable(String.class))).thenReturn(node);
    PasswordEncoder passwordEncoder = config.getPasswordEncoder();
    assertNull(passwordEncoder);
}
Also used : PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) DefaultPentahoPasswordEncoder(org.pentaho.platform.repository2.userroledao.jackrabbit.security.DefaultPentahoPasswordEncoder) Node(org.dom4j.Node) Test(org.junit.Test)

Example 43 with PasswordEncoder

use of org.springframework.security.crypto.password.PasswordEncoder in project pentaho-platform by pentaho.

the class SpringSecurityHibernateConfigTest method testGetPasswordEncoder.

@Test
public void testGetPasswordEncoder() throws Exception {
    config = new SpringSecurityHibernateConfig(document);
    Node node = mock(Node.class);
    when(node.getText()).thenReturn(DefaultPentahoPasswordEncoder.class.getName());
    when(document.selectSingleNode(nullable(String.class))).thenReturn(node);
    PasswordEncoder passwordEncoder = config.getPasswordEncoder();
    assertTrue(passwordEncoder instanceof DefaultPentahoPasswordEncoder);
}
Also used : PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) DefaultPentahoPasswordEncoder(org.pentaho.platform.repository2.userroledao.jackrabbit.security.DefaultPentahoPasswordEncoder) Node(org.dom4j.Node) DefaultPentahoPasswordEncoder(org.pentaho.platform.repository2.userroledao.jackrabbit.security.DefaultPentahoPasswordEncoder) Test(org.junit.Test)

Example 44 with PasswordEncoder

use of org.springframework.security.crypto.password.PasswordEncoder in project pentaho-platform by pentaho.

the class AppConfigPropertiesTest method testGetPasswordEncoder.

@Test
public void testGetPasswordEncoder() throws Exception {
    SpringSecurityHibernateConfig springSecurityConfig = mock(SpringSecurityHibernateConfig.class);
    doReturn(springSecurityConfig).when(spyAppConfigProperties).getSpringSecurityHibernateConfig();
    PasswordEncoder pwdEncoder = mock(PasswordEncoder.class);
    when(springSecurityConfig.getPasswordEncoder()).thenReturn(pwdEncoder);
    PasswordEncoder passwordEncoder = spyAppConfigProperties.getPasswordEncoder();
    verify(springSecurityConfig).getPasswordEncoder();
    assertEquals(pwdEncoder, passwordEncoder);
}
Also used : PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) Test(org.junit.Test)

Aggregations

PasswordEncoder (org.springframework.security.crypto.password.PasswordEncoder)44 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)24 NoOpPasswordEncoder (org.springframework.security.crypto.password.NoOpPasswordEncoder)10 Test (org.junit.jupiter.api.Test)9 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)7 KeystorePasswordHolder (won.owner.model.KeystorePasswordHolder)7 User (won.owner.model.User)7 SCryptPasswordEncoder (org.springframework.security.crypto.scrypt.SCryptPasswordEncoder)5 HashMap (java.util.HashMap)4 KeystoreHolder (won.owner.model.KeystoreHolder)4 ExpensiveSecureRandomString (won.protocol.util.ExpensiveSecureRandomString)4 IOException (java.io.IOException)3 Test (org.junit.Test)3 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)3 UserDetails (org.springframework.security.core.userdetails.UserDetails)3 UserDetailsPasswordService (org.springframework.security.core.userdetails.UserDetailsPasswordService)3 UserDetailsService (org.springframework.security.core.userdetails.UserDetailsService)3 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)3 Pbkdf2PasswordEncoder (org.springframework.security.crypto.password.Pbkdf2PasswordEncoder)3 UserEntity (com.zavada.entity.UserEntity)2