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