Package org.apache.oltu.oauth2.client

Examples of org.apache.oltu.oauth2.client.OAuthClient


  public String getTokenType() {
    return getParam(OAuth.OAUTH_TOKEN_TYPE);
  }

  public OAuthToken getOAuthToken() {
    return new BasicOAuthToken(getAccessToken(), getExpiresIn(), getRefreshToken(), getScope());
  }
View Full Code Here


            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
            .setRedirectURL(CommonExt.APP_REDIRECT_URI)
            .buildJSONMessage();

        OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new URLConnectionClient());
        OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);

        assertEquals(CommonExt.CLIENT_ID, response.getClientId());
        assertEquals(CommonExt.CLIENT_SECRET, response.getClientSecret());
        assertEquals(CommonExt.EXPIRES_IN, response.getExpiresIn());
        assertEquals(CommonExt.ISSUED_AT, response.getIssuedAt());
View Full Code Here

            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
            .setRedirectURL(CommonExt.APP_REDIRECT_URI)
            .buildBodyMessage();

        OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new URLConnectionClient());
        try {
            OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertNotNull(e.getError());
        }
View Full Code Here

            .setIcon(CommonExt.APP_ICON)
            .setRedirectURL(CommonExt.APP_REDIRECT_URI)
            .buildJSONMessage();

        OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new URLConnectionClient());
        OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);

        assertEquals(CommonExt.CLIENT_ID, response.getClientId());
        assertEquals(CommonExt.CLIENT_SECRET, response.getClientSecret());
        assertEquals(CommonExt.EXPIRES_IN, response.getExpiresIn());
        assertEquals(CommonExt.ISSUED_AT, response.getIssuedAt());

    }
View Full Code Here

            .setRedirectURL(CommonExt.APP_REDIRECT_URI)
            .buildBodyMessage();

        OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new URLConnectionClient());
        try {
            OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertNotNull(e.getError());
        }
View Full Code Here

    public OAuthClientRegistrationResponse() {
    }

    @Override
    protected void init(String body, String contentType, int responseCode) throws OAuthProblemException {
        validator = new RegistrationValidator();
        super.init(body, contentType, responseCode);
    }
View Full Code Here

        assertEquals("RS256", header.getAlgorithm());
    }

    @Test
    public void testClaimsSet() throws Exception {
        ClaimsSet claimsSet = jwt.getClaimsSet();
        assertEquals("788732372078.apps.googleusercontent.com", claimsSet.getAudience());
        assertEquals("accounts.google.com", claimsSet.getIssuer());
        assertEquals("106422453082479998429", claimsSet.getSubject());
        assertEquals(1366730217, claimsSet.getExpirationTime());
        assertEquals(1366726317, claimsSet.getIssuedAt());
    }
View Full Code Here

        assertEquals(JWT, jwt.getRawString());
    }

    @Test
    public void testHeader() throws Exception {
        Header header = jwt.getHeader();
        assertEquals("RS256", header.getAlgorithm());
    }
View Full Code Here

public final class JWTWriterTestCase implements IOTestCaseConstants {

    @Test
    public void write() {
        JWT jwt = new JWT.Builder()
                          // header
                          .setHeaderAlgorithm("RS256")
                          .setHeaderCustomField("kid", "be1da0b3567bd265a25098fbcc2b09f21345b3a2")
                          // claimset
                          .setClaimsSetAudience("788732372078.apps.googleusercontent.com")
View Full Code Here

    @RequestMapping("/userInfo")
    public HttpEntity userInfo(HttpServletRequest request) throws OAuthSystemException {
        try {

            //构建OAuth资源请求
            OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request, ParameterStyle.QUERY);
            //获取Access Token
            String accessToken = oauthRequest.getAccessToken();

            //验证Access Token
            if (!oAuthService.checkAccessToken(accessToken)) {
                // 如果不存在/过期了,返回未验证错误,需重新验证
                OAuthResponse oauthResponse = OAuthRSResponse
View Full Code Here

TOP

Related Classes of org.apache.oltu.oauth2.client.OAuthClient

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.