Search in sources :

Example 1 with MockJcifsAuthentication

use of org.apereo.cas.support.spnego.MockJcifsAuthentication in project cas by apereo.

the class JcifsSpnegoAuthenticationHandlerTests method verifySuccessfulAuthenticationWithoutDomainName.

@Test
public void verifySuccessfulAuthenticationWithoutDomainName() throws Exception {
    val credentials = new SpnegoCredential(new byte[] { 0, 1, 2 });
    val authenticationHandler = new JcifsSpnegoAuthenticationHandler(StringUtils.EMPTY, null, null, CollectionUtils.wrapList(new MockJcifsAuthentication()), false, true, null);
    assertNotNull(authenticationHandler.authenticate(credentials));
    assertEquals("test", credentials.getPrincipal().getId());
    assertNotNull(credentials.getNextToken());
}
Also used : lombok.val(lombok.val) SpnegoCredential(org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) Test(org.junit.jupiter.api.Test)

Example 2 with MockJcifsAuthentication

use of org.apereo.cas.support.spnego.MockJcifsAuthentication in project cas by apereo.

the class JcifsSpnegoAuthenticationHandlerTests method verifyGetSimpleCredentials.

@Test
public void verifyGetSimpleCredentials() {
    val myNtlmUser = "DOMAIN\\Username";
    val myNtlmUserWithNoDomain = USERNAME;
    val myKerberosUser = "Username@DOMAIN.COM";
    val factory = PrincipalFactoryUtils.newPrincipalFactory();
    val authenticationHandler = new JcifsSpnegoAuthenticationHandler(StringUtils.EMPTY, null, null, CollectionUtils.wrapList(new MockJcifsAuthentication()), true, true, null);
    assertEquals(factory.createPrincipal(myNtlmUser), authenticationHandler.getPrincipal(myNtlmUser, true));
    assertEquals(factory.createPrincipal(myNtlmUserWithNoDomain), authenticationHandler.getPrincipal(myNtlmUserWithNoDomain, false));
    assertEquals(factory.createPrincipal(myKerberosUser), authenticationHandler.getPrincipal(myKerberosUser, false));
    val handlerNoDomain = new JcifsSpnegoAuthenticationHandler(StringUtils.EMPTY, mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), CollectionUtils.wrapList(new MockJcifsAuthentication()), false, true, null);
    assertEquals(factory.createPrincipal(USERNAME), handlerNoDomain.getPrincipal(myNtlmUser, true));
    assertEquals(factory.createPrincipal(USERNAME), handlerNoDomain.getPrincipal(myNtlmUserWithNoDomain, true));
    assertEquals(factory.createPrincipal(USERNAME), handlerNoDomain.getPrincipal(myKerberosUser, false));
}
Also used : lombok.val(lombok.val) ServicesManager(org.apereo.cas.services.ServicesManager) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) Test(org.junit.jupiter.api.Test)

Example 3 with MockJcifsAuthentication

use of org.apereo.cas.support.spnego.MockJcifsAuthentication in project cas by apereo.

the class JcifsSpnegoAuthenticationHandlerTests method verifySupports.

@Test
public void verifySupports() {
    val authenticationHandler = new JcifsSpnegoAuthenticationHandler(StringUtils.EMPTY, null, null, CollectionUtils.wrapList(new MockJcifsAuthentication()), true, true, null);
    assertFalse(authenticationHandler.supports((SpnegoCredential) null));
    assertTrue(authenticationHandler.supports(new SpnegoCredential(new byte[] { 0, 1, 2 })));
    assertFalse(authenticationHandler.supports(new UsernamePasswordCredential()));
}
Also used : lombok.val(lombok.val) SpnegoCredential(org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 4 with MockJcifsAuthentication

use of org.apereo.cas.support.spnego.MockJcifsAuthentication in project cas by apereo.

the class JcifsSpnegoAuthenticationHandlerTests method verifySuccessfulAuthenticationWithDomainName.

@Test
public void verifySuccessfulAuthenticationWithDomainName() throws Exception {
    val credentials = new SpnegoCredential(new byte[] { 0, 1, 2 });
    val authenticationHandler = new JcifsSpnegoAuthenticationHandler(StringUtils.EMPTY, null, null, CollectionUtils.wrapList(new MockJcifsAuthentication()), true, true, null);
    assertNotNull(authenticationHandler.authenticate(credentials));
    assertEquals("test", credentials.getPrincipal().getId());
    assertNotNull(credentials.getNextToken());
    assertTrue(authenticationHandler.supports(credentials.getClass()));
}
Also used : lombok.val(lombok.val) SpnegoCredential(org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)4 MockJcifsAuthentication (org.apereo.cas.support.spnego.MockJcifsAuthentication)4 Test (org.junit.jupiter.api.Test)4 SpnegoCredential (org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential)3 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)1 ServicesManager (org.apereo.cas.services.ServicesManager)1