Examples of OAuthAccessResourceRequest


Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

    public Response get(@Context HttpServletRequest request) throws OAuthSystemException {

        try {

            // Make the OAuth Request out of this request
            OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request,
                ParameterStyle.HEADER);

            // Get the access token
            String accessToken = oauthRequest.getAccessToken();

            // Validate the access token
            if (!Common.ACCESS_TOKEN_VALID.equals(accessToken)) {

                // Return the OAuth error message
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

    public Response get(@Context HttpServletRequest request) throws OAuthSystemException {

        try {

            // Make the OAuth Request out of this request
            OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request,
                ParameterStyle.QUERY);

            // Get the access token
            String accessToken = oauthRequest.getAccessToken();

            // Validate the access token
            if (!Common.ACCESS_TOKEN_VALID.equals(accessToken)) {

                // Return the OAuth error message
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

    public Response get(@Context HttpServletRequest request) throws OAuthSystemException {

        try {

            // Make the OAuth Request out of this request and validate it
            OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request,
                ParameterStyle.BODY);

            // Get the access token
            String accessToken = oauthRequest.getAccessToken();

            // Check if the token is valid
            if (Common.ACCESS_TOKEN_VALID.equals(accessToken)) {

                // Return the resource
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        HttpServletResponse res = (HttpServletResponse)response;

        try {

            // Make an OAuth Request out of this servlet request
            OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(req,
                parameterStyles);

            // Get the access token
            String accessToken = oauthRequest.getAccessToken();

            final OAuthDecision decision = provider.validateRequest(realm, accessToken, req);

            final Principal principal = decision.getPrincipal();
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
        expect(request.getContentType()).andStubReturn(OAuth.ContentType.JSON);
        expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn(null);
        replay(request);

        OAuthAccessResourceRequest req = null;
        try {
            new OAuthAccessResourceRequest(request);
            fail("Exception expected");
        } catch (OAuthProblemException e) {
            Assert.assertEquals("Missing authorization header.", e.getDescription());
        }
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        expect(request.getContentType()).andStubReturn(OAuth.ContentType.JSON);
        expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Basic assdafasfd");
        replay(request);

        try {
            new OAuthAccessResourceRequest(request);
            fail("Exception expected");
        } catch (OAuthProblemException e) {
            Assert.assertEquals("Incorrect authorization method.", e.getDescription());
        }
        verify(request);
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        expect(request.getContentType()).andStubReturn(OAuth.ContentType.JSON);
        expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Bearer ");
        replay(request);

        try {
            new OAuthAccessResourceRequest(request);
            fail("Exception expected");
        } catch (OAuthProblemException e) {
            Assert.assertTrue(OAuthError.TokenResponse.INVALID_REQUEST.equals(e.getError()));
        }
        verify(request);
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION))
            .andStubReturn("Bearer sadfasfd,oauth_signature_method=\"HMAC-SHA1\"");
        replay(request);

        try {
            new OAuthAccessResourceRequest(request);
            fail("Exception expected");
        } catch (OAuthProblemException e) {
            Assert.assertTrue(OAuthError.TokenResponse.INVALID_REQUEST.equals(e.getError()));
        }
        verify(request);
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
        expect(request.getContentType()).andStubReturn(OAuth.ContentType.JSON);
        expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Bearer token");
        replay(request);
        try {
            new OAuthAccessResourceRequest(request);
        } catch (OAuthProblemException e) {
            fail("Exception not expected");
        }
        verify(request);
View Full Code Here

Examples of org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest

        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[] {"sometoken"});
        expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
        replay(request);

        try {
            new OAuthAccessResourceRequest(request, ParameterStyle.BODY);
            fail("Exception expeted");
        } catch (OAuthProblemException e) {
            Assert.assertTrue(OAuthError.TokenResponse.INVALID_REQUEST.equals(e.getError()));
        }
        verify(request);
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.