Examples of OAuthServiceException


Examples of org.apache.cxf.rs.security.oauth.provider.OAuthServiceException

            tokenService.replaceHeader("Authorization", header);
            Form form = tokenService.post(null, Form.class);
            return new Token(form.getData().getFirst("oauth_token"),
                    form.getData().getFirst("oauth_token_secret"));
        } catch (WebApplicationException ex) {
            throw new OAuthServiceException(ex);
        }
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth.provider.OAuthServiceException

            tokenService.replaceHeader("Authorization", header);
            Form form = tokenService.post(null, Form.class);
            return new Token(form.getData().getFirst("oauth_token"),
                    form.getData().getFirst("oauth_token_secret"));
        } catch (ServerWebApplicationException ex) {
            throw new OAuthServiceException(ex);
        }
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth.provider.OAuthServiceException

    public RequestToken getRequestToken(String tokenString) throws OAuthServiceException {

        Token token = oauthTokens.get(tokenString);
        if (token == null || (!RequestToken.class.isAssignableFrom(token.getClass()))) {
            throw new OAuthServiceException(new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED));
        }
        return (RequestToken) token;
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth.provider.OAuthServiceException

    protected String generateToken() throws OAuthServiceException {
        String token;
        try {
            token = tokenGenerator.generate(UUID.randomUUID().toString().getBytes("UTF-8"));
        } catch (Exception e) {
            throw new OAuthServiceException("Unable to create token ", e.getCause());
        }
        return token;
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth.provider.OAuthServiceException

    protected String generateToken() throws OAuthServiceException {
        String token;
        try {
            token = tokenGenerator.generate(UUID.randomUUID().toString().getBytes("UTF-8"));
        } catch (Exception e) {
            throw new OAuthServiceException("Unable to create token ", e.getCause());
        }
        return token;
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth.provider.OAuthServiceException

            tokenService.replaceHeader("Authorization", header);
            Form form = tokenService.post(null, Form.class);
            return new Token(form.getData().getFirst("oauth_token"),
                    form.getData().getFirst("oauth_token_secret"));
        } catch (ServerWebApplicationException ex) {
            throw new OAuthServiceException(ex);
        }
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException

   
    private String algorithm = ALGO_MD5;
       
    public String generate(byte[] input) throws OAuthServiceException {
        if (input == null) {
            throw new OAuthServiceException("You have to pass input to Token Generator");
        }

        try {
            byte[] messageDigest = createDigest(input, algorithm);
            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++) {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }

            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new OAuthServiceException("server_error", e);
        }
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException

    public byte[] createDigest(String input, String algo) {
        try {
            return createDigest(input.getBytes("UTF-8"), algo);
        } catch (UnsupportedEncodingException e) {
            throw new OAuthServiceException("server_error", e);
        } catch (NoSuchAlgorithmException e) {
            throw new OAuthServiceException("server_error", e);
        }  
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException

            return;
        }
       
        String audienceParam = params.getFirst(OAuthConstants.CLIENT_AUDIENCE);
        if (audienceParam == null) {
            throw new OAuthServiceException(new OAuthError(OAuthConstants.INVALID_REQUEST));
        }
        // must be URL
        try {
            new URL(audienceParam);
        } catch (MalformedURLException ex) {
            throw new OAuthServiceException(new OAuthError(OAuthConstants.INVALID_REQUEST));
        }
       
        if (!audiences.contains(audienceParam)) {
            throw new OAuthServiceException(new OAuthError(OAuthConstants.ACCESS_DENIED));
        }
       
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException

    public ServerAccessToken createAccessToken(Client client, MultivaluedMap<String, String> params)
        throws OAuthServiceException {
       
        String assertion = params.getFirst(Constants.CLIENT_GRANT_ASSERTION_PARAM);
        if (assertion == null) {
            throw new OAuthServiceException(OAuthConstants.INVALID_GRANT);
        }
        try {  
            InputStream tokenStream = decodeAssertion(assertion);
            Element token = readToken(tokenStream);
            AssertionWrapper assertionWrapper = new AssertionWrapper(token);
           
            Message message = PhaseInterceptorChain.getCurrentMessage();
   
            validateToken(message, assertionWrapper);
            UserSubject grantSubject = getGrantSubject(message, assertionWrapper);
           
            return doCreateAccessToken(client,
                                       grantSubject,
                                       Constants.SAML2_BEARER_GRANT,
                                       OAuthUtils.parseScope(params.getFirst(OAuthConstants.SCOPE)));
        } catch (OAuthServiceException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new OAuthServiceException(OAuthConstants.INVALID_GRANT, ex);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.