Search in sources :

Example 6 with SpnegoCredential

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()));
}
Also used : SpnegoCredential(org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 7 with SpnegoCredential

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());
}
Also used : SpnegoCredential(org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) Test(org.junit.Test)

Example 8 with SpnegoCredential

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());
    }
}
Also used : SpnegoCredential(org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential) GeneralSecurityException(java.security.GeneralSecurityException) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) MockJcifsAuthentication(org.apereo.cas.support.spnego.MockJcifsAuthentication) Test(org.junit.Test)

Aggregations

SpnegoCredential (org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential)8 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)4 MockJcifsAuthentication (org.apereo.cas.support.spnego.MockJcifsAuthentication)4 Test (org.junit.Test)4 GeneralSecurityException (java.security.GeneralSecurityException)2 FailedLoginException (javax.security.auth.login.FailedLoginException)2 BasicCredentialMetaData (org.apereo.cas.authentication.BasicCredentialMetaData)2 DefaultHandlerResult (org.apereo.cas.authentication.DefaultHandlerResult)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 UniAddress (jcifs.UniAddress)1 NbtAddress (jcifs.netbios.NbtAddress)1 Type1Message (jcifs.ntlmssp.Type1Message)1 Type2Message (jcifs.ntlmssp.Type2Message)1 Type3Message (jcifs.ntlmssp.Type3Message)1 NtlmPasswordAuthentication (jcifs.smb.NtlmPasswordAuthentication)1 SmbAuthException (jcifs.smb.SmbAuthException)1 Credential (org.apereo.cas.authentication.Credential)1 PreventedException (org.apereo.cas.authentication.PreventedException)1 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)1