throw new OAuthSystemException(e);
private OAuthClientResponse getOauthResponse(OAuthClient oAuthClient, OAuthClientRequest accessRequest) throws AuthenticationFailedException { OAuthClientResponse oAuthResponse = null; try { oAuthResponse = oAuthClient.accessToken(accessRequest); } catch (OAuthSystemException e) { if (log.isDebugEnabled()) { log.debug("Exception while requesting access token", e); } throw new AuthenticationFailedException(e.getMessage(), e); } catch (OAuthProblemException e) { if (log.isDebugEnabled()) { log.debug("Exception while requesting access token", e); } } return oAuthResponse; }
e1.printStackTrace(); e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace();
public static <T> T instantiateClassWithParameters(Class<T> clazz, Class<?>[] paramsTypes, Object[] paramValues) throws OAuthSystemException { try { if (paramsTypes != null && paramValues != null) { if (!(paramsTypes.length == paramValues.length)) { throw new IllegalArgumentException("Number of types and values must be equal"); } if (paramsTypes.length == 0 && paramValues.length == 0) { return clazz.newInstance(); } Constructor<T> clazzConstructor = clazz.getConstructor(paramsTypes); return clazzConstructor.newInstance(paramValues); } return clazz.newInstance(); } catch (NoSuchMethodException e) { throw new OAuthSystemException(e); } catch (InstantiationException e) { throw new OAuthSystemException(e); } catch (IllegalAccessException e) { throw new OAuthSystemException(e); } catch (InvocationTargetException e) { throw new OAuthSystemException(e); } }
private OAuthClientRequest getAccessRequest(String tokenEndPoint, String clientId, String code, String clientSecret, String callbackurl) throws AuthenticationFailedException { OAuthClientRequest accessRequest = null; try { accessRequest = OAuthClientRequest.tokenLocation(tokenEndPoint) .setGrantType(GrantType.AUTHORIZATION_CODE).setClientId(clientId) .setClientSecret(clientSecret).setRedirectURI(callbackurl).setCode(code) .buildBodyMessage(); } catch (OAuthSystemException e) { if (log.isDebugEnabled()) { log.debug("Exception while building request for request access token", e); } throw new AuthenticationFailedException(e.getMessage(), e); } return accessRequest; }
httpResponse.getWriter().write(response.getBody()); } catch (OAuthSystemException e1) { e1.printStackTrace(); e.printStackTrace();
public static <T> T instantiateClassWithParameters(Class<T> clazz, Class<?>[] paramsTypes, Object[] paramValues) throws OAuthSystemException { try { if (paramsTypes != null && paramValues != null) { if (!(paramsTypes.length == paramValues.length)) { throw new IllegalArgumentException("Number of types and values must be equal"); } if (paramsTypes.length == 0 && paramValues.length == 0) { return clazz.newInstance(); } Constructor<T> clazzConstructor = clazz.getConstructor(paramsTypes); return clazzConstructor.newInstance(paramValues); } return clazz.newInstance(); } catch (NoSuchMethodException e) { throw new OAuthSystemException(e); } catch (InstantiationException e) { throw new OAuthSystemException(e); } catch (IllegalAccessException e) { throw new OAuthSystemException(e); } catch (InvocationTargetException e) { throw new OAuthSystemException(e); } }
} catch (OAuthSystemException e) { log.error("Exception while building authorization code request.", e); throw new AuthenticationFailedException(e.getMessage(), e);
public static void main(String[] args) { OAuthIssuerImpl oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator()); try { String authorizationCode = oauthIssuerImpl.authorizationCode(); System.out.println(authorizationCode); System.out.println(authorizationCode.length()); } catch (OAuthSystemException e) { e.printStackTrace(); } } }
public static ResourceServer instantiateResourceServer(TokenType tokenType) throws OAuthSystemException { Class clazz = tokens.get(tokenType); if (clazz == null) { throw new OAuthSystemException("Cannot instantiate a resource server."); } return (ResourceServer)OAuthUtils.instantiateClass(clazz); }
} catch (OAuthSystemException e) { log.error("Exception while building authorization code request.", e); throw new AuthenticationFailedException(e.getMessage(), e);
public static ResourceServer instantiateResourceServer(TokenType tokenType) throws OAuthSystemException { Class clazz = tokens.get(tokenType); if (clazz == null) { throw new OAuthSystemException("Cannot instantiate a resource server."); } return (ResourceServer)OAuthUtils.instantiateClass(clazz); }
log.warn( "Caught Exception while validating JWT signature: {}. Rethrowing as AccessTokenOAuthException", e.getMessage(), e );
public TokenExtractor instantiateExtractor(ParameterStyle ps) throws OAuthSystemException { Class clazz = extractors.get(ps); if (clazz == null) { throw new OAuthSystemException("Cannot instantiate a token extractor."); } return (TokenExtractor)OAuthUtils.instantiateClass(clazz); }
throw new AuthenticationFailedException(e.getMessage(), e);
public TokenExtractor instantiateExtractor(ParameterStyle ps) throws OAuthSystemException { Class clazz = extractors.get(ps); if (clazz == null) { throw new OAuthSystemException("Cannot instantiate a token extractor."); } return (TokenExtractor)OAuthUtils.instantiateClass(clazz); }
} catch (OAuthSystemException e) { log.error("Exception while building authorization code request.", e); throw new AuthenticationFailedException(e.getMessage(), e);
public OAuthValidator instantiateValidator(ParameterStyle ps) throws OAuthSystemException { Class clazz = validators.get(ps); if (clazz == null) { throw new OAuthSystemException("Cannot instantiate a message validator."); } return (OAuthValidator)OAuthUtils.instantiateClass(clazz); }
log.warn( "Caught Exception while validating JWT signature: {}. Rethrowing as AccessTokenOAuthException", e.getMessage(), e );
@Override public String generateValue(String param) throws OAuthSystemException { try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(param.getBytes()); byte[] messageDigest = algorithm.digest(); return toHexString(messageDigest); } catch (Exception e) { throw new OAuthSystemException("OAuth Token cannot be generated.", e); } } }