Search in sources :

Example 6 with QueryEncodeJdbcAuthenticationProperties

use of org.apereo.cas.configuration.model.support.jdbc.authn.QueryEncodeJdbcAuthenticationProperties in project cas by apereo.

the class QueryAndEncodeDatabaseAuthenticationHandlerTests method verifyAuthenticationMultipleAccounts.

@Test
public void verifyAuthenticationMultipleAccounts() {
    val properties = new QueryEncodeJdbcAuthenticationProperties().setAlgorithmName(ALG_NAME).setSql(buildSql()).setPasswordFieldName(PASSWORD_FIELD_NAME).setSaltFieldName("salt").setDisabledFieldName("ops");
    val q = new QueryAndEncodeDatabaseAuthenticationHandler(properties, null, PrincipalFactoryUtils.newPrincipalFactory(), dataSource);
    assertThrows(FailedLoginException.class, () -> q.authenticate(CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("user0", "password0")));
}
Also used : lombok.val(lombok.val) QueryEncodeJdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.authn.QueryEncodeJdbcAuthenticationProperties) Test(org.junit.jupiter.api.Test)

Example 7 with QueryEncodeJdbcAuthenticationProperties

use of org.apereo.cas.configuration.model.support.jdbc.authn.QueryEncodeJdbcAuthenticationProperties in project cas by apereo.

the class QueryAndEncodeDatabaseAuthenticationHandlerTests method verifyAuthenticationFailsToFindUser.

@Test
public void verifyAuthenticationFailsToFindUser() {
    val properties = new QueryEncodeJdbcAuthenticationProperties().setAlgorithmName(ALG_NAME).setSql(buildSql()).setPasswordFieldName(PASSWORD_FIELD_NAME).setSaltFieldName("salt").setDisabledFieldName("ops");
    val q = new QueryAndEncodeDatabaseAuthenticationHandler(properties, null, PrincipalFactoryUtils.newPrincipalFactory(), dataSource);
    assertThrows(AccountNotFoundException.class, () -> q.authenticate(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword()));
}
Also used : lombok.val(lombok.val) QueryEncodeJdbcAuthenticationProperties(org.apereo.cas.configuration.model.support.jdbc.authn.QueryEncodeJdbcAuthenticationProperties) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)7 QueryEncodeJdbcAuthenticationProperties (org.apereo.cas.configuration.model.support.jdbc.authn.QueryEncodeJdbcAuthenticationProperties)7 Test (org.junit.jupiter.api.Test)7 PrefixSuffixPrincipalNameTransformer (org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer)1 PasswordEncoder (org.springframework.security.crypto.password.PasswordEncoder)1