moved back to form variables for auth because rest template is dumb

pull/306/merge
Justin Richer 2013-03-13 17:17:15 -04:00
parent ca40b2fd3e
commit 4dedec76ec
1 changed files with 22 additions and 20 deletions

View File

@ -150,6 +150,8 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
HttpSession session = request.getSession();
String issuer = issuerService.getIssuer(request);
session.setAttribute(ISSUER_SESSION_VARIABLE, issuer);
ServerConfiguration serverConfig = servers.getServerConfiguration(issuer);
ClientDetails clientConfig = clients.getClientConfiguration(issuer);
@ -199,26 +201,6 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
ServerConfiguration serverConfig = servers.getServerConfiguration(issuer);
ClientDetails clientConfig = clients.getClientConfiguration(issuer);
// Handle Token Endpoint interaction
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter("http.socket.timeout", new Integer(httpSocketTimeout));
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(clientConfig.getClientId(), clientConfig.getClientSecret());
httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
/* Alternatively, use form-based auth:
*
form.add("client_id", serverConfig.getClientId());
form.add("client_secret", serverConfig.getClientSecret());
*/
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate restTemplate = new RestTemplate(factory);
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
form.add("grant_type", "authorization_code");
form.add("code", authorizationCode);
@ -228,6 +210,26 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
form.add("redirect_uri", redirectUri);
}
// Handle Token Endpoint interaction
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter("http.socket.timeout", new Integer(httpSocketTimeout));
/* Use these for basic auth:
*
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(clientConfig.getClientId(), clientConfig.getClientSecret());
httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
*/
/* Alternatively, use form-based auth:
*/
form.add("client_id", clientConfig.getClientId());
form.add("client_secret", clientConfig.getClientSecret());
/**/
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate restTemplate = new RestTemplate(factory);
logger.debug("tokenEndpointURI = " + serverConfig.getTokenEndpointUri());
logger.debug("form = " + form);