|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.client.http.AuthSubUtil
public class AuthSubUtil
Utility functions to support AuthSub (Account Authentication for Web Applications).
Constructor Summary | |
---|---|
AuthSubUtil()
|
Method Summary | |
---|---|
static java.lang.String |
exchangeForSessionToken(java.lang.String onetimeUseToken,
java.security.PrivateKey key)
Exchanges the one time use token returned in the URL for a session token. |
static java.lang.String |
exchangeForSessionToken(java.lang.String protocol,
java.lang.String domain,
java.lang.String onetimeUseToken,
java.security.PrivateKey key)
Exchanges the one time use token returned in the URL for a session token. |
static java.lang.String |
formAuthorizationHeader(java.lang.String token,
java.security.PrivateKey key,
java.net.URL requestUrl,
java.lang.String requestMethod)
Forms the AuthSub authorization header. |
static java.security.PrivateKey |
getPrivateKeyFromKeystore(java.lang.String keystore,
java.lang.String keystorePass,
java.lang.String keyAlias,
java.lang.String keyPass)
Retrieves the private key from the specified keystore. |
static java.lang.String |
getRequestUrl(java.lang.String nextUrl,
java.lang.String scope,
boolean secure,
boolean session)
Creates the request URL to be used to retrieve an AuthSub token. |
static java.lang.String |
getRequestUrl(java.lang.String hostedDomain,
java.lang.String nextUrl,
java.lang.String scope,
boolean secure,
boolean session)
Creates the request URL to be used to retrieve an AuthSub token for hosted applications. |
static java.lang.String |
getRequestUrl(java.lang.String protocol,
java.lang.String domain,
java.lang.String nextUrl,
java.lang.String scope,
boolean secure,
boolean session)
Creates the request URL to be used to retrieve an AuthSub token. |
static java.lang.String |
getRequestUrl(java.lang.String protocol,
java.lang.String domain,
java.lang.String hostedDomain,
java.lang.String nextUrl,
java.lang.String scope,
boolean secure,
boolean session)
Creates the request URL for to be used to retrieve an AuthSub token for hosted applications. |
static java.lang.String |
getTokenFromReply(java.lang.String queryString)
Parses and returns the AuthSub token returned by Google on a successful AuthSub login request. |
static java.lang.String |
getTokenFromReply(java.net.URL url)
Parses and returns the AuthSub token returned by Google on a successful AuthSub login request. |
static java.util.Map<java.lang.String,java.lang.String> |
getTokenInfo(java.lang.String token,
java.security.PrivateKey key)
Retrieves information about the AuthSub token. |
static java.util.Map<java.lang.String,java.lang.String> |
getTokenInfo(java.lang.String protocol,
java.lang.String domain,
java.lang.String token,
java.security.PrivateKey key)
Retrieves information about the AuthSub token. |
static void |
revokeToken(java.lang.String token,
java.security.PrivateKey key)
Revokes the specified token. |
static void |
revokeToken(java.lang.String protocol,
java.lang.String domain,
java.lang.String token,
java.security.PrivateKey key)
Revokes the specified token. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AuthSubUtil()
Method Detail |
---|
public static java.lang.String getRequestUrl(java.lang.String nextUrl, java.lang.String scope, boolean secure, boolean session)
On success, the user will be redirected to the next URL with the
AuthSub token appended to the URL. Use getTokenFromReply(String)
to retrieve the token from the reply.
nextUrl
- the URL to redirect to on successful token retrievalscope
- the scope of the requested AuthSub tokensecure
- true
if the token will be used securelysession
- true
if the token will be exchanged for a
session cookie
public static java.lang.String getRequestUrl(java.lang.String protocol, java.lang.String domain, java.lang.String nextUrl, java.lang.String scope, boolean secure, boolean session)
On success, the user will be redirected to the next URL with the
AuthSub token appended to the URL. Use getTokenFromReply(String)
to retrieve the token from the reply.
protocol
- the protocol to use to communicate with the serverdomain
- the domain at which the authentication server existsnextUrl
- the URL to redirect to on successful token retrievalscope
- the scope of the requested AuthSub tokensecure
- true
if the token will be used securelysession
- true
if the token will be exchanged for a
session cookie
public static java.lang.String getRequestUrl(java.lang.String hostedDomain, java.lang.String nextUrl, java.lang.String scope, boolean secure, boolean session)
On success, the user will be redirected to the next URL with the
AuthSub token appended to the URL. Use getTokenFromReply(String)
to retrieve the token from the reply.
hostedDomain
- hosted domain name, for example
mydomain.example.com
nextUrl
- the URL to redirect to on successful token retrievalscope
- the scope of the requested AuthSub tokensecure
- true
if the token will be used securelysession
- true
if the token will be exchanged for a
session cookie
public static java.lang.String getRequestUrl(java.lang.String protocol, java.lang.String domain, java.lang.String hostedDomain, java.lang.String nextUrl, java.lang.String scope, boolean secure, boolean session)
On success, the user will be redirected to the next URL with the
AuthSub token appended to the URL. Use getTokenFromReply(String)
to retrieve the token from the reply.
protocol
- the protocol to use to communicate with the serverdomain
- the domain at which the authentication server existshostedDomain
- hosted domain name, for example
mydomain.example.com
nextUrl
- the URL to redirect to on successful token retrievalscope
- the scope of the requested AuthSub tokensecure
- true
if the token will be used securelysession
- true
if the token will be exchanged for a
session cookie
public static java.lang.String getTokenFromReply(java.net.URL url)
url
- the redirected-to next URL with the token
public static java.lang.String getTokenFromReply(java.lang.String queryString)
queryString
- the query portion of the redirected-to URL containing
the token (as the server received it; i.e. what
httpServletRequest.getQueryString()
returns)
null
if there is no
token present in queryString
. The token text will have
been run through URLDecoder
already, and will not need any
additional decoding before use; however, the token string will
not contain percent (%
) characters and therefore
additional url-decoding will do no harm.public static java.security.PrivateKey getPrivateKeyFromKeystore(java.lang.String keystore, java.lang.String keystorePass, java.lang.String keyAlias, java.lang.String keyPass) throws java.io.IOException, java.security.GeneralSecurityException
keystore
- the path to the keystore filekeystorePass
- the password that protects the keystore filekeyAlias
- the alias under which the private key is storedkeyPass
- the password protecting the private key
java.security.GeneralSecurityException
- if the keystore cannot be loaded
java.io.IOException
- if the file cannot be accessedpublic static java.lang.String exchangeForSessionToken(java.lang.String onetimeUseToken, java.security.PrivateKey key) throws java.io.IOException, java.security.GeneralSecurityException, AuthenticationException
If the key
is non-null, the token will be used securely
and the request to make the exchange will be signed.
onetimeUseToken
- the one time use token sent by Google in the URLkey
- the private key to sign the request
null
if the request failed
java.io.IOException
- if error in writing/reading the request
java.security.GeneralSecurityException
- if error in signing the request
AuthenticationException
- if one time use token is rejectedpublic static java.lang.String exchangeForSessionToken(java.lang.String protocol, java.lang.String domain, java.lang.String onetimeUseToken, java.security.PrivateKey key) throws java.io.IOException, java.security.GeneralSecurityException, AuthenticationException
If the key
is non-null, the token will be used securely
and the request to make the exchange will be signed.
protocol
- the protocol to use to communicate with the serverdomain
- the domain at which the authentication server existsonetimeUseToken
- the one time use token sent by Google in the URLkey
- the private key to sign the request
null
if the request failed
java.io.IOException
- if error in writing/reading the request
java.security.GeneralSecurityException
- if error in signing the request
AuthenticationException
- if one time use token is rejectedpublic static java.util.Map<java.lang.String,java.lang.String> getTokenInfo(java.lang.String token, java.security.PrivateKey key) throws java.io.IOException, java.security.GeneralSecurityException, AuthenticationException
If the key
is non-null, the token will be used securely
and the request to revoke the token will be signed.
token
- the AuthSub token for which to receive informationkey
- the private key to sign the request
java.io.IOException
- if error in writing/reading the request
java.security.GeneralSecurityException
- if error in signing the request
AuthenticationException
- if the token is rejectedpublic static java.util.Map<java.lang.String,java.lang.String> getTokenInfo(java.lang.String protocol, java.lang.String domain, java.lang.String token, java.security.PrivateKey key) throws java.io.IOException, java.security.GeneralSecurityException, AuthenticationException
If the key
is non-null, the token will be used securely
and the request to revoke the token will be signed.
protocol
- the protocol to use to communicate with the serverdomain
- the domain at which the authentication server existstoken
- the AuthSub token for which to receive informationkey
- the private key to sign the request
java.io.IOException
- if error in writing/reading the request
java.security.GeneralSecurityException
- if error in signing the request
AuthenticationException
- if the token is rejectedpublic static void revokeToken(java.lang.String token, java.security.PrivateKey key) throws java.io.IOException, java.security.GeneralSecurityException, AuthenticationException
If the key
is non-null, the token will be used securely
and the request to revoke the token will be signed.
token
- the AuthSub token to revokekey
- the private key to sign the request
java.io.IOException
- if error in writing/reading the request
java.security.GeneralSecurityException
- if error in signing the request
AuthenticationException
- if the token is rejectedpublic static void revokeToken(java.lang.String protocol, java.lang.String domain, java.lang.String token, java.security.PrivateKey key) throws java.io.IOException, java.security.GeneralSecurityException, AuthenticationException
If the key
is non-null, the token will be used securely
and the request to revoke the token will be signed.
protocol
- the protocol to use to communicate with the serverdomain
- the domain at which the authentication server existstoken
- the AuthSub token to revokekey
- the private key to sign the request
java.io.IOException
- if error in writing/reading the request
java.security.GeneralSecurityException
- if error in signing the request
AuthenticationException
- if the token is rejectedpublic static java.lang.String formAuthorizationHeader(java.lang.String token, java.security.PrivateKey key, java.net.URL requestUrl, java.lang.String requestMethod) throws java.security.GeneralSecurityException
If the key
is null, the token will be used in insecure mode.
If the key
is non-null, the token will be used securely and
the header will contain a signature.
token
- the AuthSub token to use in the headerkey
- the private key used to sign the requestrequestUrl
- the URL of the request being issuedrequestMethod
- the HTTP method being used to issue the request
java.security.GeneralSecurityException
- if error occurs while creating signature
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |