Package org.jboss.resteasy.auth.oauth

Examples of org.jboss.resteasy.auth.oauth.OAuthRequestToken


               
                if (consumerKey != null && !tokenConsumerKey.equals(consumerKey)) {
                    throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED, "No such consumer key "+consumerKey);
                }
               
                OAuthRequestToken newToken = new OAuthRequestToken(token, secret, callback,
                        scopes == null ? null : new String[] {scopes},
                        permissions == null ? null : new String[] {permissions},       
                        -1, getConsumer(tokenConsumerKey));
                newToken.setVerifier(verifier);
                return newToken;
            } else {
                throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED, "No such consumer key "+consumerKey);
            }
        } catch (SQLException ex) {
View Full Code Here


        }
    }

    public OAuthToken makeAccessToken(String consumerKey, String requestTokenKey,
            String verifier) throws OAuthException {
        OAuthRequestToken requestToken = verifyAndRemoveRequestToken(consumerKey, requestTokenKey, verifier);
        try {
            String token = makeRandomString();
            String secret = makeRandomString();
            String[] scopes = requestToken.getScopes();
            String[] permissions = requestToken.getPermissions();
            update("INSERT INTO access_tokens(token,consumer_key,secret,scopes,permissions) "
                    + "VALUES('" + token + "', '" + consumerKey + "', '"
                    + secret + "'"
                    + ", " + (scopes != null ? "'" + scopes[0] + "'" : null)
                    + ", " + (permissions != null ? "'" + permissions[0] + "'" : null)
                    + ")");
        
            return new OAuthToken(token, secret,
                    requestToken.getScopes(), requestToken.getPermissions(), -1, requestToken.getConsumer());
         } catch (SQLException ex) {
             throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED,
                     "Request token for the consumer with key " + consumerKey + " can not be created");
         }
    }
View Full Code Here

                     "Request token for the consumer with key " + consumerKey + " can not be created");
         }
    }

    private OAuthRequestToken verifyAndRemoveRequestToken(String consumerKey, String requestToken, String verifier) throws OAuthException {
        OAuthRequestToken token = getRequestToken(consumerKey, requestToken);
        checkCustomerKey(token, consumerKey);
        // check the verifier, which is only set when the request token was accepted
        if(verifier == null || !verifier.equals(token.getVerifier()))
            throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED, "Invalid verifier code for token "+requestToken);
        try
        {
            update("DELETE FROM request_tokens WHERE token='" + requestToken + "'");
        }
View Full Code Here

                    + secret + "', '" + callback + "'"
                    + ", " + (scopes != null ? "'" + scopes[0] + "'" : null)
                    + ", " + (permissions != null ? "'" + permissions[0] + "'" : null)
                    + ")");
        
            return new OAuthRequestToken(token, secret, callback,
                    scopes, permissions, -1, getConsumer(consumerKey));
         } catch (SQLException ex) {
             throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED,
                     "Request token for the consumer with key " + consumerKey + " can not be created");
         }
View Full Code Here

               
                if (consumerKey != null && !tokenConsumerKey.equals(consumerKey)) {
                    throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED, "No such consumer key "+consumerKey);
                }
               
                OAuthRequestToken newToken = new OAuthRequestToken(token, secret, callback,
                        scopes == null ? null : new String[] {scopes},
                        permissions == null ? null : new String[] {permissions},       
                        -1, getConsumer(tokenConsumerKey));
                newToken.setVerifier(verifier);
                return newToken;
            } else {
                throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED, "No such consumer key "+consumerKey);
            }
        } catch (SQLException ex) {
View Full Code Here

        }
    }

    public OAuthToken makeAccessToken(String consumerKey, String requestTokenKey,
            String verifier) throws OAuthException {
        OAuthRequestToken requestToken = verifyAndRemoveRequestToken(consumerKey, requestTokenKey, verifier);
        try {
            String token = makeRandomString();
            String secret = makeRandomString();
            String[] scopes = requestToken.getScopes();
            String[] permissions = requestToken.getPermissions();
            update("INSERT INTO access_tokens(token,consumer_key,secret,scopes,permissions) "
                    + "VALUES('" + token + "', '" + consumerKey + "', '"
                    + secret + "'"
                    + ", " + (scopes != null ? "'" + scopes[0] + "'" : null)
                    + ", " + (permissions != null ? "'" + permissions[0] + "'" : null)
                    + ")");
        
            return new OAuthToken(token, secret,
                    requestToken.getScopes(), requestToken.getPermissions(), -1, requestToken.getConsumer());
         } catch (SQLException ex) {
             throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED,
                     "Request token for the consumer with key " + consumerKey + " can not be created");
         }
    }
View Full Code Here

                     "Request token for the consumer with key " + consumerKey + " can not be created");
         }
    }

    private OAuthRequestToken verifyAndRemoveRequestToken(String consumerKey, String requestToken, String verifier) throws OAuthException {
        OAuthRequestToken token = getRequestToken(consumerKey, requestToken);
        checkCustomerKey(token, consumerKey);
        // check the verifier, which is only set when the request token was accepted
        if(verifier == null || !verifier.equals(token.getVerifier()))
            throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED, "Invalid verifier code for token "+requestToken);
        try
        {
            update("DELETE FROM request_tokens WHERE token='" + requestToken + "'");
        }
View Full Code Here

                    + secret + "', '" + callback + "'"
                    + ", " + (scopes != null ? "'" + scopes[0] + "'" : null)
                    + ", " + (permissions != null ? "'" + permissions[0] + "'" : null)
                    + ")");
        
            return new OAuthRequestToken(token, secret, callback,
                    scopes, permissions, -1, getConsumer(consumerKey));
         } catch (SQLException ex) {
             throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED,
                     "Request token for the consumer with key " + consumerKey + " can not be created");
         }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.auth.oauth.OAuthRequestToken

Copyright © 2018 www.massapicom. 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.