Examples of OAuthProvider


Examples of com.k42b3.neodym.oauth.OauthProvider

      if(access == null)
      {
        throw new Exception("Could not find access service");
      }

      OauthProvider provider = new OauthProvider(request.getUri(), authorization.getUri(), access.getUri(), Configuration.getInstance().getConsumerKey(), Configuration.getInstance().getConsumerSecret());
      oauth = new Oauth(http, provider);
    }
    catch(Exception e)
    {
      Zubat.handleException(e);
View Full Code Here

Examples of com.k42b3.neodym.oauth.OauthProvider

    // authentication
    String requestUrl = availableServices.getItem("http://oauth.net/core/1.0/endpoint/request").getUri();
    String authorizationUrl = availableServices.getItem("http://oauth.net/core/1.0/endpoint/authorize").getUri();
    String accessUrl = availableServices.getItem("http://oauth.net/core/1.0/endpoint/access").getUri();

    OauthProvider provider = new OauthProvider(requestUrl, authorizationUrl, accessUrl, Configuration.getInstance().getConsumerKey(), Configuration.getInstance().getConsumerSecret());
    Oauth oauth = new Oauth(http, provider);

    if(!Configuration.getInstance().getToken().isEmpty() && !Configuration.getInstance().getTokenSecret().isEmpty())
    {
      oauth.auth(Configuration.getInstance().getToken(), Configuration.getInstance().getTokenSecret());
View Full Code Here

Examples of helpers.oauth.OAuthProvider

        if (provider == null) {
            flash.error("Mauvaise requète, le provider d'authentification n'est pas indiqué");
            index(null);
        }
       
        OAuthProvider oauthProvider = OAuthProviderFactory.getProvider(provider);
        OAuthService oauthService = oauthProvider.getService();

        if (OAuth.isVerifierResponse()) {
            // We got the verifier;
            // now get the access tokens using the request tokens
            final Token requestToken = new Token(flash.get(TOKEN_KEY), flash.get(SECRET_KEY));
            final String verifier = params.get("oauth_verifier");
            try {
                Token accessToken = oauthService.getAccessToken(requestToken, new Verifier(verifier));

                // Fetch user oAuthAccount
                OAuthAccount oAuthAccount = oauthProvider.getUserAccount(accessToken.getToken(), accessToken.getSecret());
                // Retrieve existing oAuthAccount from profile
                AuthAccount account = AuthAccount.find(provider, oAuthAccount.getOAuthLogin());

                if (account != null) {
                    onSuccessfulAuthentication(account.member.login);
View Full Code Here

Examples of oauth.signpost.OAuthProvider

               
                // get the request token credentials
                Credentials request_credentials = Credentials.getCredentials(request, provider, Credentials.Type.REQUEST);

                OAuthConsumer consumer = OAuthUtilities.getConsumer(request_credentials, provider);
                OAuthProvider pp = provider.getProvider();
               
                if (request_credentials == null) {
                    // no credentials were found, so let's start the dance

                    // get the request token

                    String url = pp.retrieveRequestToken(consumer, callbackURL);
                   
                    request_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider);

                    // and set them to that we can retrieve them later in the second part of the dance
                    Credentials.setCredentials(request, response, request_credentials, Credentials.Type.REQUEST, 3600);
                   
                    // now redirect the user to the Authorize URL where she can authenticate against the
                    // service provider and authorize us.
                    // The provider will bounce the user back here for us to continue the dance.
                   
                    response.sendRedirect(url);
                } else {
                    // we are at the second stage of the dance, so we need need to obtain the access credentials now
                   
                    // if we got here, it means that the user performed a valid authentication against the
                    // service provider and authorized us, so now we can request more permanent credentials
                    // to the service provider and save those as well for later use.

                    // this is set only for OAuth 1.0a 
                    String verificationCode = request.getParameter(OAUTH_VERIFIER_PARAM);
                   
                    pp.retrieveAccessToken(consumer, verificationCode);

                    access_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider);

                    // no matter the result, we need to remove the request token
                    Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST);
View Full Code Here

Examples of oauth.signpost.OAuthProvider

            "http://twitter.com/oauth/authorize");
    }

    public String getAuthURL()
    {
        OAuthProvider provider = getDefaultProvider();
        OAuthConsumer consumer = getDefaultConsumer();

        String authURL = null;
        try
        {
            authURL = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
            pinToken = consumer.getToken();
            pinTokenSecret = consumer.getTokenSecret();
        } catch (OAuthException e)
        {
            // Auth exception
View Full Code Here

Examples of oauth.signpost.OAuthProvider

    }

    public void acquireAccessTokens(String pin)
        throws OAuthException
    {
        OAuthProvider provider = getDefaultProvider();
        OAuthConsumer consumer = getDefaultConsumer();

        consumer.setTokenWithSecret(pinToken, pinTokenSecret);

        pinToken = null;
        pinTokenSecret = null;

        provider.retrieveAccessToken(consumer, pin);

        setAccessToken(consumer.getToken());
        setTokenSecret(consumer.getTokenSecret());
        setScreenName(provider.getResponseParameters().get("screen_name").first());
    }
View Full Code Here

Examples of oauth.signpost.OAuthProvider

    System.setProperty("debug", "true");
   
    OAuthConsumer consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);

    // Note: we have to add the consumer key in the authorization URL to make it work
    OAuthProvider provider = new CommonsHttpOAuthProvider(REQUEST_TOKEN_URL,
                               ACCESS_TOKEN_URL,
                              AUTHORIZATION_URL + "&client_id=" + consumerKey);
    /*
     *  This has to be done once to get request token
     */
    provider.setOAuth10a(true);
    // for some reason, SignPost does not append oauth_callback so I
    // added it directly into the AUTHORIZATION_URL
    String requestUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
    System.out.println("Copy/Paste the following URL in your browser: " + requestUrl);
    System.out.print("Enter your token: ");
    // read authorization code
    Scanner scanner = new Scanner(System.in);
    String authorizationCode = scanner.nextLine().trim();

    provider.retrieveAccessToken(consumer, authorizationCode);
       
    String accessToken = consumer.getToken();
    String tokenSecret = consumer.getTokenSecret();
    System.out.println("Token: " + accessToken + ". Secret: " + tokenSecret);

View Full Code Here

Examples of oauth.signpost.OAuthProvider

    additionalParameter.put("api_key", apiKey);
    consumer.setAdditionalParameters(additionalParameter);

    HttpClient httpClient = env.getHttpClient();

    OAuthProvider provider = new CommonsHttpOAuthProvider(
        "https://api.bodymedia.com/oauth/request_token?api_key="+apiKey,
        "https://api.bodymedia.com/oauth/access_token?api_key="+apiKey,
        "https://api.bodymedia.com/oauth/authorize?api_key="+apiKey, httpClient);

    request.getSession().setAttribute(BODYMEDIA_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(BODYMEDIA_OAUTH_PROVIDER, provider);

        String approvalPageUrl = null;
        try {
            approvalPageUrl = provider.retrieveRequestToken(consumer,
                    oauthCallback);
        } catch (Throwable t) {
            logger.error("Couldn't retrieve BodyMedia request token.");
            t.printStackTrace();
            notificationsService.addNamedNotification(AuthHelper.getGuestId(),
View Full Code Here

Examples of oauth.signpost.OAuthProvider

      OAuthNotAuthorizedException, OAuthExpectationFailedException,
      OAuthCommunicationException {

    OAuthConsumer consumer = (OAuthConsumer) request.getSession()
        .getAttribute(BODYMEDIA_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession()
        .getAttribute(BODYMEDIA_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();

        ApiKey apiKey;
        if (request.getParameter("apiKeyId")!=null) {
            long apiKeyId = Long.valueOf(request.getParameter("apiKeyId"));
            apiKey = guestService.getApiKey(apiKeyId);
        } else
            apiKey = guestService.createApiKey(guest.getId(), connector());

        guestService.setApiKeyAttribute(apiKey, "api_key", env.get("bodymediaConsumerKey"));
    guestService.setApiKeyAttribute(apiKey,
        "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey,
        "tokenSecret", consumer.getTokenSecret());
        guestService.setApiKeyAttribute(apiKey,
                "tokenExpiration", provider.getResponseParameters().get("xoauth_token_expiration_time").first());

        // Store the OAuth server keys used for the token upgrade, which are the ones currently in oauth.properties
        // into ApiKeyAttributes.  The values in oauth.properties may change over time, so we need to preserve
        // the values used for the token creation with the ApiKey itself.
        guestService.setApiKeyAttribute(apiKey, "bodymediaConsumerKey", env.get("bodymediaConsumerKey"));
View Full Code Here

Examples of oauth.signpost.OAuthProvider

                                accessToken);
        consumer.setAdditionalParameters(additionalParameter);

        HttpClient httpClient = env.getHttpClient();

        OAuthProvider provider = new CommonsHttpOAuthProvider(
                "https://api.bodymedia.com/oauth/request_token?api_key="+bodymediaConsumerKey,
                "https://api.bodymedia.com/oauth/access_token?api_key="+bodymediaConsumerKey,
                "https://api.bodymedia.com/oauth/authorize?api_key="+bodymediaConsumerKey, httpClient);

        try {
            provider.retrieveAccessToken(consumer, null);

            guestService.setApiKeyAttribute(updateInfo.apiKey,
                                            "accessToken", consumer.getToken());
            guestService.setApiKeyAttribute(updateInfo.apiKey,
                                            "tokenSecret", consumer.getTokenSecret());
            guestService.setApiKeyAttribute(updateInfo.apiKey,
                                            "tokenExpiration", provider.getResponseParameters().get("xoauth_token_expiration_time").first());

            // Record this connector as having status up
            guestService.setApiKeyStatus(updateInfo.apiKey.getId(), ApiKey.Status.STATUS_UP, null, null);
            // Schedule an update for this connector
            connectorUpdateService.updateConnector(updateInfo.apiKey, false);
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.