private void setSubject(AuthenticationContext context, Map<String, Object> jsonObject) throws ApplicationAuthenticatorException { String authenticatedUserId = (String) jsonObject.get(FacebookAuthenticatorConstants.DEFAULT_USER_IDENTIFIER); if (StringUtils.isEmpty(authenticatedUserId)) { throw new ApplicationAuthenticatorException("Authenticated user identifier is empty"); } AuthenticatedUser authenticatedUser = AuthenticatedUser.createFederateAuthenticatedUserFromSubjectIdentifier(authenticatedUserId); context.setSubject(authenticatedUser); }
} catch (ApplicationAuthenticatorException e) { log.error("Failed to process Facebook Connect response.", e); throw new AuthenticationFailedException(e.getMessage(), context.getSubject(), e);
} catch (ApplicationAuthenticatorException e) { log.error("Failed to process Facebook Connect response.", e); throw new AuthenticationFailedException(e.getMessage(), context.getSubject(), e);
private void setSubject(AuthenticationContext context, Map<String, Object> jsonObject) throws ApplicationAuthenticatorException { String authenticatedUserId = (String) jsonObject.get(FacebookAuthenticatorConstants.DEFAULT_USER_IDENTIFIER); if (StringUtils.isEmpty(authenticatedUserId)) { throw new ApplicationAuthenticatorException("Authenticated user identifier is empty"); } AuthenticatedUser authenticatedUser = AuthenticatedUser.createFederateAuthenticatedUserFromSubjectIdentifier(authenticatedUserId); context.setSubject(authenticatedUser); }
} catch (ApplicationAuthenticatorException e) { log.error("Failed to process Facebook Connect response.", e); throw new AuthenticationFailedException(e.getMessage(), e);
private String getUserInfoString(String fbAuthUserInfoUrl, String userInfoFields, String token) throws ApplicationAuthenticatorException { String userInfoString; try { if (StringUtils.isBlank(userInfoFields)) { userInfoString = sendRequest(String.format("%s?%s", fbAuthUserInfoUrl, token)); } else { userInfoString = sendRequest(String.format("%s?fields=%s&%s", fbAuthUserInfoUrl, userInfoFields, token)); } } catch (MalformedURLException e) { if (log.isDebugEnabled()) { log.debug("URL : " + fbAuthUserInfoUrl, e); } throw new ApplicationAuthenticatorException( "MalformedURLException while sending user information request.", e); } catch (IOException e) { throw new ApplicationAuthenticatorException( "IOException while sending sending user information request.", e); } return userInfoString; }
protected void setSubject(AuthenticationContext context, Map<String, Object> jsonObject) throws ApplicationAuthenticatorException { String authenticatedUserId = (String) jsonObject.get(FacebookAuthenticatorConstants.DEFAULT_USER_IDENTIFIER); if (StringUtils.isEmpty(authenticatedUserId)) { throw new ApplicationAuthenticatorException("Authenticated user identifier is empty"); } AuthenticatedUser authenticatedUser = AuthenticatedUser.createFederateAuthenticatedUserFromSubjectIdentifier(authenticatedUserId); context.setSubject(authenticatedUser); }
protected String getUserInfoString(String fbAuthUserInfoUrl, String userInfoFields, String token) throws ApplicationAuthenticatorException { String userInfoString; try { if (StringUtils.isBlank(userInfoFields)) { userInfoString = sendRequest(String.format("%s?access_token=%s", fbAuthUserInfoUrl, token)); } else { userInfoString = sendRequest(String.format("%s?fields=%s&access_token=%s", fbAuthUserInfoUrl, userInfoFields, token)); } } catch (MalformedURLException e) { if (log.isDebugEnabled()) { log.debug("URL : " + fbAuthUserInfoUrl, e); } throw new ApplicationAuthenticatorException( "MalformedURLException while sending user information request.", e); } catch (IOException e) { throw new ApplicationAuthenticatorException( "IOException while sending sending user information request.", e); } return userInfoString; }
private String getUserInfoString(String fbAuthUserInfoUrl, String userInfoFields, String token) throws ApplicationAuthenticatorException { String userInfoString; try { if (StringUtils.isBlank(userInfoFields)) { userInfoString = sendRequest(String.format("%s?%s", fbAuthUserInfoUrl, token)); } else { userInfoString = sendRequest(String.format("%s?fields=%s&%s", fbAuthUserInfoUrl, userInfoFields, token)); } } catch (MalformedURLException e) { if (log.isDebugEnabled()) { log.debug("URL : " + fbAuthUserInfoUrl, e); } throw new ApplicationAuthenticatorException( "MalformedURLException while sending user information request.", e); } catch (IOException e) { throw new ApplicationAuthenticatorException( "IOException while sending sending user information request.", e); } return userInfoString; }
private String getAuthorizationCode(HttpServletRequest request) throws ApplicationAuthenticatorException { OAuthAuthzResponse authzResponse; try { authzResponse = OAuthAuthzResponse.oauthCodeAuthzResponse(request); return authzResponse.getCode(); } catch (OAuthProblemException e) { throw new ApplicationAuthenticatorException("Exception while reading authorization code.", e); } }
protected String getAuthorizationCode(HttpServletRequest request) throws ApplicationAuthenticatorException { OAuthAuthzResponse authzResponse; try { authzResponse = OAuthAuthzResponse.oauthCodeAuthzResponse(request); return authzResponse.getCode(); } catch (OAuthProblemException e) { throw new ApplicationAuthenticatorException("Exception while reading authorization code.", e); } }
private String getToken(String tokenEndPoint, String clientId, String clientSecret, String callbackurl, String code) throws ApplicationAuthenticatorException { OAuthClientRequest tokenRequest = null; String token = null; try { tokenRequest = buidTokenRequest(tokenEndPoint, clientId, clientSecret, callbackurl, code); token = sendRequest(tokenRequest.getLocationUri()); if (token.startsWith("{")) { throw new ApplicationAuthenticatorException("Received access token is invalid."); } } catch (MalformedURLException e) { if (log.isDebugEnabled()) { log.debug("URL : " + tokenRequest.getLocationUri()); } throw new ApplicationAuthenticatorException( "MalformedURLException while sending access token request.", e); } catch (IOException e) { throw new ApplicationAuthenticatorException("IOException while sending access token request.", e); } return token; }
private String getToken(String tokenEndPoint, String clientId, String clientSecret, String callbackurl, String code) throws ApplicationAuthenticatorException { OAuthClientRequest tokenRequest = null; String token = null; try { tokenRequest = buidTokenRequest(tokenEndPoint, clientId, clientSecret, callbackurl, code); token = sendRequest(tokenRequest.getLocationUri()); if (token.startsWith("{")) { throw new ApplicationAuthenticatorException("Received access token is invalid."); } } catch (MalformedURLException e) { if (log.isDebugEnabled()) { log.debug("URL : " + tokenRequest.getLocationUri()); } throw new ApplicationAuthenticatorException( "MalformedURLException while sending access token request.", e); } catch (IOException e) { throw new ApplicationAuthenticatorException("IOException while sending access token request.", e); } return token; }
private String getAuthorizationCode(HttpServletRequest request) throws ApplicationAuthenticatorException { OAuthAuthzResponse authzResponse; try { authzResponse = OAuthAuthzResponse.oauthCodeAuthzResponse(request); return authzResponse.getCode(); } catch (OAuthProblemException e) { throw new ApplicationAuthenticatorException("Exception while reading authorization code.", e); } }
protected String getToken(String tokenEndPoint, String clientId, String clientSecret, String callbackurl, String code) throws ApplicationAuthenticatorException { OAuthClientRequest tokenRequest = null; String token = null; try { tokenRequest = buidTokenRequest(tokenEndPoint, clientId, clientSecret, callbackurl, code); String tokenResponse = sendRequest(tokenRequest.getLocationUri()); Map<String, Object> jsonObject = JSONUtils.parseJSON(tokenResponse); token = (String) jsonObject.get(FacebookAuthenticatorConstants.FB_ACCESS_TOKEN); if (StringUtils.isEmpty(token)) { throw new ApplicationAuthenticatorException("Could not receive a valid access token from FB"); } } catch (MalformedURLException e) { if (log.isDebugEnabled()) { log.debug("URL : " + tokenRequest.getLocationUri()); } throw new ApplicationAuthenticatorException( "MalformedURLException while sending access token request.", e); } catch (IOException e) { throw new ApplicationAuthenticatorException("IOException while sending access token request.", e); } return token; }
log.debug("Decoded json object is null"); throw new ApplicationAuthenticatorException("Decoded json object is null");
log.debug("Decoded json object is null"); throw new ApplicationAuthenticatorException("Decoded json object is null");
private OAuthClientRequest buidTokenRequest( String tokenEndPoint, String clientId, String clientSecret, String callbackurl, String code) throws ApplicationAuthenticatorException { OAuthClientRequest tokenRequest = null; try { tokenRequest = OAuthClientRequest.tokenLocation(tokenEndPoint).setClientId(clientId) .setClientSecret(clientSecret) .setRedirectURI(callbackurl).setCode(code) .buildQueryMessage(); } catch (OAuthSystemException e) { throw new ApplicationAuthenticatorException("Exception while building access token request.", e); } return tokenRequest; }
private OAuthClientRequest buidTokenRequest( String tokenEndPoint, String clientId, String clientSecret, String callbackurl, String code) throws ApplicationAuthenticatorException { OAuthClientRequest tokenRequest = null; try { tokenRequest = OAuthClientRequest.tokenLocation(tokenEndPoint).setClientId(clientId) .setClientSecret(clientSecret) .setRedirectURI(callbackurl).setCode(code) .buildQueryMessage(); } catch (OAuthSystemException e) { throw new ApplicationAuthenticatorException("Exception while building access token request.", e); } return tokenRequest; }
log.debug("Decoded json object is null"); throw new ApplicationAuthenticatorException("Decoded json object is null");