Search in sources :

Example 1 with PrincipalBearingCredential

use of org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential in project cas by apereo.

the class PrincipalBearingCredentialsAuthenticationHandlerTests method verifySupports.

@Test
public void verifySupports() {
    final PrincipalBearingCredential credentials = new PrincipalBearingCredential(new DefaultPrincipalFactory().createPrincipal("scott"));
    assertTrue(this.handler.supports(credentials));
    assertFalse(this.handler.supports(new UsernamePasswordCredential()));
}
Also used : PrincipalBearingCredential(org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential) DefaultPrincipalFactory(org.apereo.cas.authentication.principal.DefaultPrincipalFactory) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 2 with PrincipalBearingCredential

use of org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential in project cas by apereo.

the class PrincipalBearingCredentialsAuthenticationHandlerTests method verifyNonNullPrincipal.

/**
     * When the credentials bear a Principal, succeed the authentication.
     */
@Test
public void verifyNonNullPrincipal() throws Exception {
    final PrincipalBearingCredential credentials = new PrincipalBearingCredential(new DefaultPrincipalFactory().createPrincipal("scott"));
    assertNotNull(this.handler.authenticate(credentials));
}
Also used : PrincipalBearingCredential(org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential) DefaultPrincipalFactory(org.apereo.cas.authentication.principal.DefaultPrincipalFactory) Test(org.junit.Test)

Example 3 with PrincipalBearingCredential

use of org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential in project cas by apereo.

the class PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction method constructCredentialsFromRequest.

@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final Principal principal = request.getUserPrincipal();
    if (principal != null) {
        LOGGER.debug("UserPrincipal [{}] found in HttpServletRequest", principal.getName());
        return new PrincipalBearingCredential(this.principalFactory.createPrincipal(principal.getName()));
    }
    LOGGER.debug("UserPrincipal not found in HttpServletRequest.");
    return null;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PrincipalBearingCredential(org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential) Principal(java.security.Principal)

Example 4 with PrincipalBearingCredential

use of org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential in project cas by apereo.

the class PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction method constructCredentialsFromRequest.

@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final String remoteUser = request.getRemoteUser();
    if (StringUtils.hasText(remoteUser)) {
        LOGGER.debug("Remote User [{}] found in HttpServletRequest", remoteUser);
        return new PrincipalBearingCredential(this.principalFactory.createPrincipal(remoteUser));
    }
    return null;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PrincipalBearingCredential(org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential)

Aggregations

PrincipalBearingCredential (org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 DefaultPrincipalFactory (org.apereo.cas.authentication.principal.DefaultPrincipalFactory)2 Test (org.junit.Test)2 Principal (java.security.Principal)1 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)1