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());
}
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));
}
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()));
}
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()));
}
Aggregations