com.google.api.client.auth.oauth2
Class AuthorizationRequestUrl

java.lang.Object
  extended by java.util.AbstractMap<String,Object>
      extended by com.google.api.client.util.GenericData
          extended by com.google.api.client.http.GenericUrl
              extended by com.google.api.client.auth.oauth2.AuthorizationRequestUrl
All Implemented Interfaces:
Cloneable, Map<String,Object>
Direct Known Subclasses:
AuthorizationCodeRequestUrl, BrowserClientRequestUrl

public class AuthorizationRequestUrl
extends GenericUrl

OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the application to access their protected resources, as specified in Authorization Endpoint.

Sample usage for a web application:

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String url = new AuthorizationRequestUrl(
        "https://server.example.com/authorize", "s6BhdRkqt3", Arrays.asList("code")).setState("xyz")
        .setRedirectUri("https://client.example.com/rd").build();
    response.sendRedirect(url);
  }
 

Implementation is not thread-safe.

Since:
1.7
Author:
Yaniv Inbar

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
AuthorizationRequestUrl(String authorizationServerEncodedUrl, String clientId, Iterable<String> responseTypes)
           
 
Method Summary
 String getClientId()
          Returns the client identifier.
 String getRedirectUri()
          Returns the URI that the authorization server directs the resource owner's user-agent back to the client after a successful authorization grant (as specified in Redirection Endpoint) or null for none.
 String getResponseTypes()
          Returns the space-separated list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).
 String getScopes()
          Returns the space-separated list of scopes (as specified in Access Token Scope) or null for none.
 String getState()
          Returns the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) or null for none.
 AuthorizationRequestUrl setClientId(String clientId)
          Sets the client identifier.
 AuthorizationRequestUrl setRedirectUri(String redirectUri)
          Sets the URI that the authorization server directs the resource owner's user-agent back to the client after a successful authorization grant (as specified in Redirection Endpoint) or null for none.
 AuthorizationRequestUrl setResponseTypes(Iterable<String> responseTypes)
          Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).
 AuthorizationRequestUrl setResponseTypes(String... responseTypes)
          Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).
 AuthorizationRequestUrl setScopes(Iterable<String> scopes)
          Sets the list of scopes (as specified in Access Token Scope) or null for none.
 AuthorizationRequestUrl setScopes(String... scopes)
          Sets the list of scopes (as specified in Access Token Scope) or null for none.
 AuthorizationRequestUrl setState(String state)
          Sets the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) or null for none.
 
Methods inherited from class com.google.api.client.http.GenericUrl
appendRawPath, build, clone, equals, getAll, getFirst, getFragment, getHost, getPathParts, getPort, getRawPath, getScheme, hashCode, setFragment, setHost, setPathParts, setPort, setRawPath, setScheme, toPathParts, toString
 
Methods inherited from class com.google.api.client.util.GenericData
entrySet, get, getUnknownKeys, put, putAll, remove, set, setUnknownKeys
 
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, isEmpty, keySet, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AuthorizationRequestUrl

public AuthorizationRequestUrl(String authorizationServerEncodedUrl,
                               String clientId,
                               Iterable<String> responseTypes)
Parameters:
authorizationServerEncodedUrl - authorization server encoded URL
clientId - client identifier
responseTypes - space-separated list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type)
Method Detail

getResponseTypes

public final String getResponseTypes()
Returns the space-separated list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).


setResponseTypes

public AuthorizationRequestUrl setResponseTypes(String... responseTypes)
Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameters:
responseTypes - response types to be joined by a space separator (or a single value containing multiple space-separated scopes)

setResponseTypes

public AuthorizationRequestUrl setResponseTypes(Iterable<String> responseTypes)
Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameters:
responseTypes - response types to be joined by a space separator (or a single value containing multiple space-separated scopes)

getRedirectUri

public final String getRedirectUri()
Returns the URI that the authorization server directs the resource owner's user-agent back to the client after a successful authorization grant (as specified in Redirection Endpoint) or null for none.


setRedirectUri

public AuthorizationRequestUrl setRedirectUri(String redirectUri)
Sets the URI that the authorization server directs the resource owner's user-agent back to the client after a successful authorization grant (as specified in Redirection Endpoint) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.


getScopes

public final String getScopes()
Returns the space-separated list of scopes (as specified in Access Token Scope) or null for none.


setScopes

public AuthorizationRequestUrl setScopes(String... scopes)
Sets the list of scopes (as specified in Access Token Scope) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameters:
scopes - list of scopes to be joined by a space separator (or a single value containing multiple space-separated scopes) or null for none

setScopes

public AuthorizationRequestUrl setScopes(Iterable<String> scopes)
Sets the list of scopes (as specified in Access Token Scope) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameters:
scopes - list of scopes to be joined by a space separator (or a single value containing multiple space-separated scopes) or null for none

getClientId

public final String getClientId()
Returns the client identifier.


setClientId

public AuthorizationRequestUrl setClientId(String clientId)
Sets the client identifier.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.


getState

public final String getState()
Returns the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) or null for none.


setState

public AuthorizationRequestUrl setState(String state)
Sets the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.



Copyright © 2011-2012 Google. All Rights Reserved.