Package org.apache.amber.oauth2.client.request

Examples of org.apache.amber.oauth2.client.request.OAuthClientRequest$OAuthRequestBuilder


        }
    }

    @Test
    public void testInvalidGrantType() throws Exception {
        OAuthClientRequest request = OAuthClientRequest
            .tokenLocation(Common.ACCESS_TOKEN_ENDPOINT)
            .setParameter(OAuth.OAUTH_GRANT_TYPE, "unknown_grant_type")
            .setCode(Common.AUTHORIZATION_CODE)
            .setRedirectURI(Common.REDIRECT_URL)
            .setClientId(Common.CLIENT_ID)
View Full Code Here


    }

    @Test
    public void testInvalidCode() throws Exception {
        OAuthClientRequest request = OAuthClientRequest
            .tokenLocation(Common.ACCESS_TOKEN_ENDPOINT)
            .setGrantType(GrantType.AUTHORIZATION_CODE)
            .setRedirectURI(Common.REDIRECT_URL)
            .setCode("unknown_code")
            .setClientId(Common.CLIENT_ID)
View Full Code Here

public class ClientRegistrationTest extends ClientServerOAuthTest {

    @Test
    public void testPushMetadataRegistration() throws Exception {

        OAuthClientRequest request = OAuthClientRegistrationRequest
            .location(CommonExt.REGISTRATION_ENDPOINT, OAuthRegistration.Type.PUSH)
            .setName(CommonExt.APP_NAME)
            .setUrl(CommonExt.APP_URL)
            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
View Full Code Here

    }

    @Test
    public void testInvalidType() throws Exception {

        OAuthClientRequest request = OAuthClientRegistrationRequest
            .location(CommonExt.REGISTRATION_ENDPOINT, "unknown_type")
            .setName(CommonExt.APP_NAME)
            .setUrl(CommonExt.APP_URL)
            .setDescription(CommonExt.APP_DESCRIPTION)
            .setIcon(CommonExt.APP_ICON)
View Full Code Here

public class OAuthClientTest {

    public static void main(String[] args) throws OAuthSystemException, IOException {

        try {
            OAuthClientRequest request = OAuthClientRequest
                .authorizationLocation("https://graph.facebook.com/oauth/authorize")
                .setClientId("131804060198305")
                .setRedirectURI("http://localhost:8080/")
                .buildQueryMessage();

            //in web application you make redirection to uri:
            System.out.println("Visit: " + request.getLocationUri() + "\nand grant permission");

            System.out.print("Now enter the OAuth code you have received in redirect uri ");
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String code = br.readLine();
View Full Code Here

            this.parameters.put(OAuthRegistration.Request.REDIRECT_URL, uri);
            return this;
        }

        public OAuthClientRequest buildJSONMessage() throws OAuthSystemException {
            OAuthClientRequest request = new OAuthClientRegistrationRequest(url);
            this.applier = new JSONBodyParametersApplier();
            return (OAuthClientRequest)applier.applyOAuthParameters(request, parameters);
        }
View Full Code Here

            res.addCookie(new Cookie("tokenEndpoint", oauthParams.getTokenEndpoint()));
            res.addCookie(new Cookie("redirectUri", oauthParams.getRedirectUri()));
            res.addCookie(new Cookie("scope", oauthParams.getScope()));
            res.addCookie(new Cookie("app", oauthParams.getApplication()));

            OAuthClientRequest request = OAuthClientRequest
                .authorizationLocation(oauthParams.getAuthzEndpoint())
                .setClientId(oauthParams.getClientId())
                .setRedirectURI(oauthParams.getRedirectUri())
                .setResponseType(ResponseType.CODE.toString())
                .setScope(oauthParams.getScope())
                .buildQueryMessage();

            return new ModelAndView(new RedirectView(request.getLocationUri()));

        } catch (ApplicationException e) {
            oauthParams.setErrorMessage(e.getMessage());
            return new ModelAndView("get_authz");
        }
View Full Code Here

        try {

            Utils.validateRegistrationParams(oauthRegParams);

            OAuthClientRequest request = null;
            if (Utils.REG_TYPE_PULL.equals(oauthRegParams.getRegistrationType())) {
                request = OAuthClientRegistrationRequest
                    .location(oauthRegParams.getRegistrationEndpoint(), OAuthRegistration.Type.PULL)
                    .setUrl(oauthRegParams.getUrl())
                    .buildBodyMessage();
View Full Code Here

        try {

            Utils.validateTokenParams(oauthParams);

            OAuthClientRequest request = OAuthClientRequest
                .tokenLocation(oauthParams.getTokenEndpoint())
                .setClientId(oauthParams.getClientId())
                .setClientSecret(oauthParams.getClientSecret())
                .setRedirectURI(oauthParams.getRedirectUri())
                .setCode(oauthParams.getAuthzCode())
View Full Code Here

            .setGrantType(GrantType.PASSWORD)
            .setClientId(Common.CLIENT_ID)
            .buildBodyMessage();

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

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

TOP

Related Classes of org.apache.amber.oauth2.client.request.OAuthClientRequest$OAuthRequestBuilder

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.