Search in sources :

Example 11 with PasswordEncoderProperties

use of org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties in project cas by apereo.

the class DefaultPasswordEncoderTests method verifyPasswordEncoderBySHA256.

@Test
public void verifyPasswordEncoderBySHA256() {
    val p = new PasswordEncoderProperties();
    p.setType(PasswordEncoderProperties.PasswordEncoderTypes.DEFAULT.name());
    p.setEncodingAlgorithm("SHA-256");
    p.setCharacterEncoding("UTF-8");
    val e = PasswordEncoderUtils.newPasswordEncoder(p, mock(ApplicationContext.class));
    assertTrue(e.matches("asd123", "54d5cb2d332dbdb4850293caae4559ce88b65163f1ea5d4e4b3ac49d772ded14"));
}
Also used : lombok.val(lombok.val) ApplicationContext(org.springframework.context.ApplicationContext) PasswordEncoderProperties(org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties) Test(org.junit.jupiter.api.Test)

Example 12 with PasswordEncoderProperties

use of org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties in project cas by apereo.

the class DefaultPasswordEncoderTests method verifyPasswordEncoderByCustomClassName.

@Test
public void verifyPasswordEncoderByCustomClassName() {
    val p = new PasswordEncoderProperties();
    p.setType(StandardPasswordEncoder.class.getName());
    p.setSecret("SECRET");
    val e = PasswordEncoderUtils.newPasswordEncoder(p, mock(ApplicationContext.class));
    assertNotNull(e);
}
Also used : lombok.val(lombok.val) StandardPasswordEncoder(org.springframework.security.crypto.password.StandardPasswordEncoder) ApplicationContext(org.springframework.context.ApplicationContext) PasswordEncoderProperties(org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties) Test(org.junit.jupiter.api.Test)

Example 13 with PasswordEncoderProperties

use of org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties in project cas by apereo.

the class DefaultPasswordEncoderTests method verifyPasswordEncoderBySHA1.

@Test
public void verifyPasswordEncoderBySHA1() {
    val p = new PasswordEncoderProperties();
    p.setType(PasswordEncoderProperties.PasswordEncoderTypes.DEFAULT.name());
    p.setEncodingAlgorithm("SHA-1");
    p.setCharacterEncoding("UTF-8");
    val e = PasswordEncoderUtils.newPasswordEncoder(p, mock(ApplicationContext.class));
    assertTrue(e.matches("asd123", "2891baceeef1652ee698294da0e71ba78a2a4064"));
}
Also used : lombok.val(lombok.val) ApplicationContext(org.springframework.context.ApplicationContext) PasswordEncoderProperties(org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties) Test(org.junit.jupiter.api.Test)

Aggregations

PasswordEncoderProperties (org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties)13 lombok.val (lombok.val)11 Test (org.junit.jupiter.api.Test)10 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)6 ApplicationContext (org.springframework.context.ApplicationContext)4 ClassPathResource (org.springframework.core.io.ClassPathResource)2 StandardPasswordEncoder (org.springframework.security.crypto.password.StandardPasswordEncoder)2 SecureRandom (java.security.SecureRandom)1 DefaultPasswordEncoder (org.apereo.cas.util.crypto.DefaultPasswordEncoder)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)1 NoOpPasswordEncoder (org.springframework.security.crypto.password.NoOpPasswordEncoder)1 PasswordEncoder (org.springframework.security.crypto.password.PasswordEncoder)1 Pbkdf2PasswordEncoder (org.springframework.security.crypto.password.Pbkdf2PasswordEncoder)1 SCryptPasswordEncoder (org.springframework.security.crypto.scrypt.SCryptPasswordEncoder)1