Package org.apache.amber.oauth2.as.response

Examples of org.apache.amber.oauth2.as.response.OAuthASResponseTest


            .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 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

    private void validate() throws OAuthSystemException, OAuthProblemException {

        int foundValidStyles = 0;
        boolean lackAuthInfo = false;
        OAuthProblemException ex = null;
        String lackAuthReason = "OAuth parameters were not found";
        for (TokenType tokenType : tokenTypes) {
          ResourceServer resourceServer=instantiateResourceServer(tokenType);
          for (ParameterStyle style : parameterStyles) {
            try {
View Full Code Here

            return OAuthClientResponseFactory
                .createCustomResponse(responseBody, contentType, response.getStatusLine().getStatusCode(),
                    responseClass);
        } catch (Exception e) {
            throw new OAuthSystemException(e);
        }

    }
View Full Code Here

                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }

            return hexString.toString();
        } catch (Exception e) {
            throw new OAuthSystemException("OAuth Token cannot be generated.", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.amber.oauth2.as.response.OAuthASResponseTest

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.