org.jets3t.service.security
Class OAuth2Credentials

java.lang.Object
  extended by org.jets3t.service.security.ProviderCredentials
      extended by org.jets3t.service.security.OAuth2Credentials

public class OAuth2Credentials
extends ProviderCredentials

Class to contain OAuth2 client credentials for authenticating against an OAuth end-point, as opposed to authenticating directly with a storage service.

Instead of the typical user access and client keys stored within a ProviderCredentials class, this class stores an OAuth2 Client ID (as the access key) and Client Secret (as the secret key).


Field Summary
 
Fields inherited from class org.jets3t.service.security.ProviderCredentials
accessKey, CREDENTIALS_STORAGE_VERSION, friendlyName, log, secretKey, V2_KEYS_DELIMITER, V3_KEYS_DELIMITER
 
Constructor Summary
OAuth2Credentials(OAuthUtils oauth, java.lang.String friendlyName)
           
OAuth2Credentials(OAuthUtils oauth, java.lang.String friendlyName, java.lang.String refreshToken)
           
OAuth2Credentials(java.lang.String clientId, java.lang.String clientSecret)
          Construct credentials.
OAuth2Credentials(java.lang.String clientId, java.lang.String clientSecret, java.lang.String friendlyName)
          Construct credentials, and associate them with a human-friendly name.
OAuth2Credentials(java.lang.String clientId, java.lang.String clientSecret, java.lang.String friendlyName, java.lang.String refreshToken)
          Construct credentials, and associate them with a human-friendly name.
 
Method Summary
 java.lang.String generateBrowserUrlToAuthorizeNativeApplication(OAuthScope scope)
           
 java.lang.String getClientId()
           
 java.lang.String getClientSecret()
           
 OAuth2Tokens getOAuth2Tokens()
           
protected  java.lang.String getTypeName()
           
 java.lang.String getVersionPrefix()
           
 void retrieveOAuth2TokensFromAuthorization(java.lang.String authorizationCode)
           
 void setOAuth2Tokens(OAuth2Tokens tokens)
           
 
Methods inherited from class org.jets3t.service.security.ProviderCredentials
getAccessKey, getDataToEncrypt, getFriendlyName, getLogString, getSecretKey, hasFriendlyName, load, load, save, save, save, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAuth2Credentials

public OAuth2Credentials(java.lang.String clientId,
                         java.lang.String clientSecret)
Construct credentials.

Parameters:
clientId - Client ID to identify the application to an OAuth2 end-point.
clientSecret - Client Secret for the application to authenticate against an OAuth2 end-point.

OAuth2Credentials

public OAuth2Credentials(java.lang.String clientId,
                         java.lang.String clientSecret,
                         java.lang.String friendlyName)
Construct credentials, and associate them with a human-friendly name.

Parameters:
clientId - Client ID to identify the application to an OAuth2 end-point.
clientSecret - Client Secret for the application to authenticate against an OAuth2 end-point.
friendlyName - a name identifying the owner of the credentials, such as 'James'.

OAuth2Credentials

public OAuth2Credentials(java.lang.String clientId,
                         java.lang.String clientSecret,
                         java.lang.String friendlyName,
                         java.lang.String refreshToken)
Construct credentials, and associate them with a human-friendly name. Start with a valid refresh token

Parameters:
clientId - Client ID to identify the application to an OAuth2 end-point.
clientSecret - Client Secret for the application to authenticate against an OAuth2 end-point.
friendlyName - a name identifying the owner of the credentials, such as 'James'.
refreshToken - a refresh token that was obtained previously.

OAuth2Credentials

public OAuth2Credentials(OAuthUtils oauth,
                         java.lang.String friendlyName)
Parameters:
oauth - Implementation
friendlyName - a name identifying the owner of the credentials, such as 'James'.

OAuth2Credentials

public OAuth2Credentials(OAuthUtils oauth,
                         java.lang.String friendlyName,
                         java.lang.String refreshToken)
Parameters:
oauth - Implementation
friendlyName - a name identifying the owner of the credentials, such as 'James'.
refreshToken - a refresh token that was obtained previously.
Method Detail

setOAuth2Tokens

public void setOAuth2Tokens(OAuth2Tokens tokens)

getOAuth2Tokens

public OAuth2Tokens getOAuth2Tokens()
                             throws java.io.IOException
Throws:
java.io.IOException

generateBrowserUrlToAuthorizeNativeApplication

public java.lang.String generateBrowserUrlToAuthorizeNativeApplication(OAuthScope scope)

retrieveOAuth2TokensFromAuthorization

public void retrieveOAuth2TokensFromAuthorization(java.lang.String authorizationCode)
                                           throws java.io.IOException
Throws:
java.io.IOException

getClientId

public java.lang.String getClientId()
Returns:
the OAuth2 Client ID (stored as access key)

getClientSecret

public java.lang.String getClientSecret()
Returns:
the OAuth2 Client Secret (stored as secret key)

getTypeName

protected java.lang.String getTypeName()
Specified by:
getTypeName in class ProviderCredentials
Returns:
string representing this credential type's name (for serialization)

getVersionPrefix

public java.lang.String getVersionPrefix()
Specified by:
getVersionPrefix in class ProviderCredentials