Package com.cloudbees.api.oauth

Examples of com.cloudbees.api.oauth.OauthToken


    }

    private OauthToken compute(String p) throws OauthClientException {
        try {

            OauthToken t = getFromCache(p);
            if (t==null) {
                // definitely get a new value
                this.cache.invalidate(p);
                t = this.cache.get(p).get();
            }
View Full Code Here


        CachedToken cache = this.cache.get(p);

        if (cache.isHalfExpired())
            return null;

        OauthToken t = cache.get();
        if(t==null || t.isExpired()){
            return t;
        }
        return t;
    }
View Full Code Here

    }

    @Override
    public OauthToken validateToken(String token) throws OauthClientException {
        try {
            OauthToken t = lhs.validateToken(token);
            if (t!=null)
                return t;
        } catch (OauthClientException e) {
            LOGGER.log(Level.WARNING, "Failed to validate token with "+lhs,e);
        }
View Full Code Here

        return halfExpiration < System.currentTimeMillis();
    }

    public @CheckForNull OauthToken get() {
        if (token==null)    return null;
        OauthToken t = token.clone();
        t.setExpiresIn(round(TimeUnit.MICROSECONDS.toSeconds(expiration - System.currentTimeMillis())));
        return t;
    }
View Full Code Here

    public OauthToken validateToken(String token) throws OauthClientException {
        try {
            if (token==null)    return null;

            CachedToken cache = this.cache.get(token);
            OauthToken t = cache.get();
            if(t==null || t.isExpired()){
                return null;
            }
            return t;
        } catch (ExecutionException e) {
            // not unwrapping an exception to capture the call stack
View Full Code Here

     * @param scopes array of scope that are expected to be granted for this token
     * @return null if the token is invalid such as expired or unknown to the CloudBees OAuth server or the expected
     * scopes are not found.
     */
    public final @CheckForNull 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

            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

            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

            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

            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

TOP

Related Classes of com.cloudbees.api.oauth.OauthToken

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.