use of org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential in project cas by apereo.
the class JcifsSpnegoAuthenticationHandlerTests method verifySupports.
@Test
public void verifySupports() {
final AuthenticationHandler authenticationHandler = new JcifsSpnegoAuthenticationHandler("", null, null, new MockJcifsAuthentication(true), true, true);
assertFalse(authenticationHandler.supports(null));
assertTrue(authenticationHandler.supports(new SpnegoCredential(new byte[] { 0, 1, 2 })));
assertFalse(authenticationHandler.supports(new UsernamePasswordCredential()));
}
use of org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential in project cas by apereo.
the class JcifsSpnegoAuthenticationHandlerTests method verifySuccessfulAuthenticationWithDomainName.
@Test
public void verifySuccessfulAuthenticationWithDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] { 0, 1, 2 });
final AuthenticationHandler authenticationHandler = new JcifsSpnegoAuthenticationHandler("", null, null, new MockJcifsAuthentication(true), true, true);
assertNotNull(authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
use of org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential in project cas by apereo.
the class JcifsSpnegoAuthenticationHandlerTests method verifyUnsuccessfulAuthentication.
@Test
public void verifyUnsuccessfulAuthentication() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] { 0, 1, 2 });
final AuthenticationHandler authenticationHandler = new JcifsSpnegoAuthenticationHandler("", null, null, new MockJcifsAuthentication(false), true, true);
try {
authenticationHandler.authenticate(credentials);
fail("An AbstractAuthenticationException should have been thrown");
} catch (final GeneralSecurityException e) {
assertNull(credentials.getNextToken());
assertNull(credentials.getPrincipal());
}
}
Aggregations