Examples of OauthToken


Examples of com.cloudbees.api.oauth.OauthToken

            return null;
    }

    public OauthToken validateToken(String token) throws OauthClientException {
        try{
            OauthToken oauthToken = bees.jsonPOJORequest(gcUrl+"/oauth/tokens/"+token,null,OauthToken.class,"GET");

            if(oauthToken.isExpired()){
                return null;
            }
            return oauthToken;
        }catch (IOException e){
            logger.log(Level.WARNING, "Failed to get token details",e);
View Full Code Here

Examples of com.cloudbees.api.oauth.OauthToken

            params.put("grant_type", singletonList("authorization_code"));
            params.put("code", singletonList(authorizationCode));
            if (redirectUri!=null)
                params.put("redirect_uri", singletonList(redirectUri));

            OauthToken resp = bees.formUrlEncoded(gcUrl+"/oauth/token", null, params).bind(OauthToken.class,bees);
            return resp;
        } catch (IOException e) {
            throw new OauthClientException("Failed to exchange authorization code to access token",e);
        }
    }
View Full Code Here

Examples of com.cloudbees.api.oauth.OauthToken

            params.put("grant_type", singletonList("refresh_token"));
            params.put("refresh_token", singletonList(refreshToken));
            if (scopes!=null)
                params.put("scope", singletonList(join(Arrays.asList(scopes)," ")));

            OauthToken resp = bees.formUrlEncoded(gcUrl+"/oauth/token", null, params).bind(OauthToken.class,bees);
            return resp;
        } catch (IOException e) {
            throw new OauthClientException("Failed to exchange authorization code to access token",e);
        }
    }
View Full Code Here

Examples of com.cloudbees.api.oauth.OauthToken

            throw new OauthClientException("Failed to create token. "+e.getMessage(), e);
        }
    }

    private OauthToken toToken(OauthTokenDetail resp) {
        OauthToken token = new OauthToken();
        token.owner = this;
        token.refreshToken = resp.refreshToken != null ? resp.refreshToken.token : null;
        token.accessToken = resp.accessToken.token;
        token.setAccount(resp.account);
        token.scope = join(resp.accessToken.scopes,",");
        token.tokenType = resp.accessToken.tokenType;
        token.uid = resp.uid;
        token.email = resp.email;
        token.setExpiresIn(resp.accessToken.expiresIn);
        token.id = resp.id;
        return token;
    }
View Full Code Here

Examples of com.cloudbees.api.oauth.OauthToken

            throw new OauthClientException("Failed to delete OAuth token",e);
        }
    }

    public OauthToken validateToken(String token, String... scopes) throws OauthClientException {
        OauthToken oauthToken = validateToken(token);
        if (oauthToken==null)   return null;

        if (oauthToken.validateScopes(scopes))
            return oauthToken;
        else
            return null;
    }
View Full Code Here

Examples of com.cloudbees.api.oauth.OauthToken

            return null;
    }

    public OauthToken validateToken(String token) throws OauthClientException {
        try{
            OauthToken oauthToken = bees.jsonPOJORequest(gcUrl+"/oauth/tokens/"+token,null,OauthToken.class,"GET");

            if(oauthToken.isExpired()){
                return null;
            }
            return oauthToken;
        }catch (IOException e){
            logger.log(Level.WARNING, "Failed to get token details",e);
View Full Code Here

Examples of com.sun.jersey.oauth.server.spi.OAuthToken

                throw newUnauthorizedException();
            }
            nonceKey = "c:" + consumerKey;
            sc = new OAuthSecurityContext(consumer, request.isSecure());
        } else {
            OAuthToken accessToken = provider.getAccessToken(token);
            if (accessToken == null) {
                throw newUnauthorizedException();
            }

            OAuthConsumer atConsumer = accessToken.getConsumer();
            if (atConsumer == null || !consumerKey.equals(atConsumer.getKey())) {
                throw newUnauthorizedException();
            }

            nonceKey = "t:" + token;
            secrets.tokenSecret(accessToken.getSecret());
            sc = new OAuthSecurityContext(accessToken, request.isSecure());
        }

        if (!verifySignature(osr, params, secrets)) {
            throw newUnauthorizedException();
View Full Code Here

Examples of com.sun.jersey.oauth.server.spi.OAuthToken

            String consKey = params.getConsumerKey();
            if (consKey == null) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            OAuthToken rt = provider.getRequestToken(params.getToken());
            if (rt == null) {
                // token invalid
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            OAuthConsumer consumer = rt.getConsumer();
            if (consumer == null || !consKey.equals(consumer.getKey())) {
                // token invalid
                throw new OAuthException(Response.Status.BAD_REQUEST, null);

            }

            OAuthSecrets secrets = new OAuthSecrets().consumerSecret(consumer.getSecret()).tokenSecret(rt.getSecret());
            try {
                sigIsOk = OAuthSignature.verify(request, params, secrets);
            } catch (OAuthSignatureException ex) {
                Logger.getLogger(AccessTokenRequest.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (!sigIsOk) {
                // signature invalid
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            // We're good to go.
            OAuthToken at = provider.newAccessToken(rt, params.getVerifier());
           
            if(at == null) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            // Preparing the response.
            Form resp = new Form();
            resp.putSingle(OAuthParameters.TOKEN, at.getToken());
            resp.putSingle(OAuthParameters.TOKEN_SECRET, at.getSecret());
            resp.putAll(at.getAttributes());
            return Response.ok(resp).build();
        } catch (OAuthException e) {
            // map the exception to avoid having to add the mapper to the providers
            return e.toResponse();
        }
View Full Code Here

Examples of com.sun.jersey.oauth.server.spi.OAuthToken

            MultivaluedMap<String, String> parameters = new MultivaluedMapImpl();
            for (String n : request.getParameterNames()) {
                parameters.put(n, request.getParameterValues(n));
            }

            OAuthToken rt = provider.newRequestToken(consKey, params.getCallback(), parameters);

            Form resp = new Form();
            resp.putSingle(OAuthParameters.TOKEN, rt.getToken());
            resp.putSingle(OAuthParameters.TOKEN_SECRET, rt.getSecret());
            resp.putSingle(OAuthParameters.CALLBACK_CONFIRMED, "true");
            return Response.ok(resp).build();
        } catch (OAuthException e) {
            return e.toResponse();
        }
View Full Code Here

Examples of org.agorava.core.api.oauth.OAuthToken

            user = new User(profile.getScreenName());
        }
        user.setName(profile.getFullName());
        user.setBio(profile.getDescription());
        user.setAvatarUrl(profile.getProfileImageUrl());
        OAuthToken token = event.getToken();
        user.setAccessToken(token.getSecret() + "|" + token.getToken());
        if(user.getApiToken() == null) {
            user.setApiToken(UUID.randomUUID().toString());
        }

        repository.store(user);
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.