use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests method verifyRemoteUserExists.
@Test
public void verifyRemoteUserExists() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteUser("test");
final MockRequestContext context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals("success", this.action.execute(context).getId());
}
use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class PrincipalFromRequestUserPrincipalNonInteractiveCredentialsActionTests method verifyRemoteUserExists.
@Test
public void verifyRemoteUserExists() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setUserPrincipal(() -> "test");
final MockRequestContext context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
Assert.assertEquals("success", this.action.execute(context).getId());
}
use of org.springframework.webflow.context.servlet.ServletExternalContext in project oxTrust by GluuFederation.
the class ClientAuthenticationHandler method doAuthentication.
/**
* {@InheritDoc}
*/
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
final ClientCredential clientCredentials = (ClientCredential) credential;
final OpenIdCredentials openIdCredentials = clientCredentials.getOpenIdCredentials();
logger.debug("Client credentials : '{}'", clientCredentials);
final String clientName = openIdCredentials.getClientName();
logger.debug("Client name : '{}'", clientName);
// Web context
final ServletExternalContext servletExternalContext = (ServletExternalContext) ExternalContextHolder.getExternalContext();
final HttpServletRequest request = (HttpServletRequest) servletExternalContext.getNativeRequest();
final HttpServletResponse response = (HttpServletResponse) servletExternalContext.getNativeResponse();
final WebContext webContext = new J2EContext(request, response);
// Get user profile
final UserProfile userProfile = this.client.getUserProfile(openIdCredentials, webContext);
logger.debug("userProfile : {}", userProfile);
if (userProfile != null) {
final String id = userProfile.getId();
if (StringHelper.isNotEmpty(id)) {
openIdCredentials.setUserProfile(userProfile);
return new HandlerResult(this, clientCredentials, new SimplePrincipal(id, userProfile.getAttributes()));
}
}
throw new FailedLoginException("Provider did not produce profile for " + clientCredentials);
}
Aggregations