Package org.apache.amber.oauth2.client.validator

Examples of org.apache.amber.oauth2.client.validator.TokenValidator


            .setUsername(Common.USERNAME)
            .setPassword(Common.PASSWORD)
            .buildBodyMessage();

        OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
        OAuthClientResponse response = null;

        try {
            oAuthClient.accessToken(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
View Full Code Here


    @GET
    @Path("/redirect")
    public Response callback(@Context HttpServletRequest request) throws Exception {

        OAuthClientResponse resp = null;
        try {
            OAuthAuthzResponse.oauthCodeAuthzResponse(request);
            fail("exception expected");
        } catch (OAuthProblemException e) {
            assertEquals(OAuthError.CodeResponse.INVALID_REQUEST, e.getError());
View Full Code Here

    @GET
    @Path("/redirect1")
    public Response callback1(@Context HttpServletRequest request) throws Exception {

        OAuthClientResponse resp = null;
        try {
            OAuthAuthzResponse.oauthCodeAuthzResponse(request);
        } catch (OAuthProblemException e) {
            fail("exception not expected");
        }
View Full Code Here

            .setPassword(Common.PASSWORD)
            .buildBodyMessage();

        OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

        OAuthJSONAccessTokenResponse response = oAuthClient.accessToken(request);

        assertNotNull(response.getAccessToken());
    }
View Full Code Here

public class TokenValidatorTest {

    @Test
    public void testValidator() {

        OAuthClientValidator validator = new TokenValidator();
        Assert.assertNotNull(validator.requiredParams);
        Assert.assertEquals(1, validator.requiredParams.size());
        Assert.assertArrayEquals(new String[] {}, validator.requiredParams.get(OAuth.OAUTH_ACCESS_TOKEN));
        Assert.assertNotNull(validator.notAllowedParams);
        Assert.assertEquals(1, validator.notAllowedParams.size());
View Full Code Here

        return body;
    }

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

        return response;
    }

    public static OAuthAuthzResponse oauthTokenAuthzResponse(HttpServletRequest request)
        throws OAuthProblemException {
        OAuthAuthzResponse response = new OAuthAuthzResponse(request, new TokenValidator());
        response.validate();
        return response;
    }
View Full Code Here

    public static final Long ISSUED_AT = 2L;

    @Test
    public void testNewClientInfo() throws Exception {

        BasicClientInfo basicClientInfo = BasicClientInfoBuilder.clientInfo()
            .setClientId(CLIENT_ID)
            .setClientSecret(CLIENT_SECRET)
            .setRedirectUri(REDIRECT_URI)
            .setName(NAME)
            .setIconUri(ICON_URI)
            .setExpiresIn(EXPIRES_IN)
            .setIssuedAt(ISSUED_AT)
            .build();

        Assert.assertNotNull(basicClientInfo);

        Assert.assertEquals(CLIENT_ID, basicClientInfo.getClientId());
        Assert.assertEquals(CLIENT_SECRET, basicClientInfo.getClientSecret());
        Assert.assertEquals(REDIRECT_URI, basicClientInfo.getRedirectUri());
        Assert.assertEquals(NAME, basicClientInfo.getName());
        Assert.assertEquals(ICON_URI, basicClientInfo.getIconUri());
        Assert.assertEquals(EXPIRES_IN, basicClientInfo.getExpiresIn());
        Assert.assertEquals(ISSUED_AT, basicClientInfo.getIssuedAt());
    }
View Full Code Here

    }

    @Test
    public void testErrorResponse() throws Exception {

        OAuthProblemException ex = OAuthProblemException
            .error(OAuthError.CodeResponse.ACCESS_DENIED, "Access denied")
            .setParameter("testparameter", "testparameter_value")
            .scope("album")
            .uri("http://www.example.com/error");
View Full Code Here

            oAuthResponse.getLocationUri());
    }

    @Test
    public void testErrorResponse2() throws Exception {
        OAuthProblemException ex = OAuthProblemException
            .error(OAuthError.CodeResponse.ACCESS_DENIED, "Access denied")
            .setParameter("testparameter", "testparameter_value")
            .scope("album")
            .uri("http://www.example.com/error");
View Full Code Here

TOP

Related Classes of org.apache.amber.oauth2.client.validator.TokenValidator

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.