Search in sources :

Example 66 with Credential

use of org.apereo.cas.authentication.Credential in project cas by apereo.

the class SurrogateSelectionAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    final Credential credential = WebUtils.getCredential(requestContext);
    if (credential instanceof UsernamePasswordCredential) {
        final UsernamePasswordCredential upc = UsernamePasswordCredential.class.cast(credential);
        final String target = requestContext.getExternalContext().getRequestParameterMap().get("surrogateTarget");
        if (StringUtils.isNotBlank(target)) {
            upc.setUsername(target + this.separator + upc.getUsername());
        }
    }
    return success();
}
Also used : UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential)

Example 67 with Credential

use of org.apereo.cas.authentication.Credential in project cas by apereo.

the class X509CertificateCredentialsRequestHeaderAction method constructCredentialsFromRequest.

@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final Credential x509Credential = super.constructCredentialsFromRequest(context);
    if (x509Credential != null) {
        return x509Credential;
    }
    final X509Certificate[] certFromHeader = x509CertificateExtractor.extract((HttpServletRequest) context.getExternalContext().getNativeRequest());
    if (certFromHeader != null) {
        LOGGER.debug("Certificate found in HTTP request via {}", x509CertificateExtractor.getClass().getName());
        return new X509CertificateCredential(certFromHeader);
    }
    LOGGER.debug("Certificates not found in request header.");
    return null;
}
Also used : X509CertificateCredential(org.apereo.cas.adaptors.x509.authentication.principal.X509CertificateCredential) Credential(org.apereo.cas.authentication.Credential) X509CertificateCredential(org.apereo.cas.adaptors.x509.authentication.principal.X509CertificateCredential) X509Certificate(java.security.cert.X509Certificate)

Aggregations

Credential (org.apereo.cas.authentication.Credential)67 Test (org.junit.Test)39 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)29 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)26 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)18 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)13 Service (org.apereo.cas.authentication.principal.Service)13 HttpBasedServiceCredential (org.apereo.cas.authentication.HttpBasedServiceCredential)11 HashMap (java.util.HashMap)10 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)10 CachedData (net.spy.memcached.CachedData)9 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)9 LinkedHashMap (java.util.LinkedHashMap)8 RegisteredService (org.apereo.cas.services.RegisteredService)8 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)7 MockServletContext (org.springframework.mock.web.MockServletContext)7 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)7 MockRequestContext (org.springframework.webflow.test.MockRequestContext)7