public class ConsumerManager extends Object
| Constructor and Description |
|---|
ConsumerManager()
Instantiates a ConsumerManager with default settings.
|
ConsumerManager(RealmVerifierFactory realmFactory,
Discovery discovery,
HttpFetcherFactory httpFetcherFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
allowStateless(boolean allowStateless)
Deprecated.
|
DiscoveryInformation |
associate(List discoveries)
Tries to establish an association with on of the service endpoints in
the list of DiscoveryInformation.
|
AuthRequest |
authenticate(DiscoveryInformation discovered,
String returnToUrl)
Builds a authentication request message for the user specified in the
discovery information provided as a parameter.
|
AuthRequest |
authenticate(DiscoveryInformation discovered,
String returnToUrl,
String realm)
Builds a authentication request message for the user specified in the
discovery information provided as a parameter.
|
AuthRequest |
authenticate(List discoveries,
String returnToUrl)
Builds a authentication request message for the user specified in the
discovery information provided as a parameter.
|
AuthRequest |
authenticate(List discoveries,
String returnToUrl,
String realm)
Builds a authentication request message for the user specified in the
discovery information provided as a parameter.
|
List |
discover(String identifier)
Does discovery on an identifier.
|
String |
extractConsumerNonce(String returnTo,
String opUrl)
Extracts the consumer-side nonce from the return_to parameter in
authentication response from a OpenID 1.1 Provider.
|
Map |
extractQueryParams(URL url)
Returns a Map(key, List(values)) with the URL's query params, or null if
the URL doesn't have a query string.
|
ConsumerAssociationStore |
getAssociations()
Gets the association store that holds established associations with
OpenID providers.
|
DHParameterSpec |
getDHParams()
Gets the Diffie-Hellman base parameters (modulus and generator).
|
Discovery |
getDiscovery()
Returns discovery process manager.
|
int |
getFailedAssocExpire()
Gets the timeout (in seconds) configured for keeping track of failed
association attempts.
|
int |
getMaxAssocAttempts()
Gets the value configured for the maximum number of association attempts
that will be performed for a given OpenID provider.
|
int |
getMaxNonceAge()
Gets the max age (in seconds) configured for keeping track of nonces.
|
AssociationSessionType |
getMinAssocSessEnc()
Gets the minimum level of encryption that will be accepted for
association sessions.
|
NonceVerifier |
getNonceVerifier()
Gets the NonceVerifier implementation used to keep track of the nonces
that have been seen in authentication response messages.
|
int |
getPreExpiryAssocLockInterval()
Gets the interval before the expiration of an association
(in seconds) in which the association should not be used,
in order to avoid the expiration from occurring in the middle
of a authentication transaction.
|
AssociationSessionType |
getPrefAssocSessEnc()
Gets the preferred encryption type for the association sessions.
|
ConsumerAssociationStore |
getPrivateAssociationStore()
Gets the private association store used for signing consumer nonces.
|
RealmVerifier |
getRealmVerifier()
Gets the RealmVerifier used to verify realms against return_to URLs.
|
String |
insertConsumerNonce(String opUrl,
String returnTo)
Inserts a consumer-side nonce as a custom parameter in the return_to
parameter of the authentication request.
|
boolean |
isAllowStateless()
Returns true if the ConsumerManager is configured to fallback to
stateless mode when failing to associate with an OpenID Provider.
|
boolean |
isImmediateAuth()
Returns true if the ConsumerManager is configured to attempt
checkid_immediate authentication requests.
|
void |
setAllowStateless(boolean allowStateless)
Flag used to enable / disable the use of stateless mode.
|
void |
setAssociations(ConsumerAssociationStore associations)
Configures the ConsumerAssociationStore that will be used to store the
associations established with OpenID providers.
|
void |
setConnectTimeout(int connectTimeout) |
void |
setDHParams(DHParameterSpec dhParams)
Sets the Diffie-Hellman base parameters that will be used for encoding
the MAC key exchange.
|
void |
setDiscovery(Discovery discovery)
Sets discovery process manager.
|
void |
setFailedAssocExpire(int _failedAssocExpire)
Sets the expiration timeout (in seconds) for keeping track of failed
association attempts.
|
void |
setImmediateAuth(boolean _immediateAuth)
Configures the authentication request mode:
checkid_immediate (true) or checkid_setup (false).
|
void |
setMaxAssocAttempts(int maxAssocAttempts)
Maximum number of attempts (HTTP calls) the RP is willing to make
for trying to establish an association with the OP.
|
void |
setMaxNonceAge(int ageSeconds)
Sets the max age (in seconds) configured for keeping track of nonces.
|
void |
setMaxRedirects(int maxRedirects) |
void |
setMinAssocSessEnc(AssociationSessionType minAssocSessEnc)
Configures the minimum level of encryption accepted for association
sessions.
|
void |
setNonceVerifier(NonceVerifier nonceVerifier)
Configures the NonceVerifier that will be used to keep track of the
nonces in the authentication response messages.
|
void |
setPreExpiryAssocLockInterval(int preExpiryAssocLockInterval)
Sets the interval before the expiration of an association
(in seconds) in which the association should not be used,
in order to avoid the expiration from occurring in the middle
of a authentication transaction.
|
void |
setPrefAssocSessEnc(AssociationSessionType prefAssocSessEnc)
Sets the preferred encryption type for the association sessions.
|
void |
setPrivateAssociationStore(ConsumerAssociationStore associations)
Configures a private association store for signing consumer nonces.
|
void |
setRealmVerifier(RealmVerifier realmVerifier)
Sets the RealmVerifier used to verify realms against return_to URLs.
|
void |
setSocketTimeout(int socketTimeout) |
boolean |
statelessAllowed()
Deprecated.
|
VerificationResult |
verify(String receivingUrl,
ParameterList response,
DiscoveryInformation discovered)
Performs verification on the Authentication Response (assertion)
received from the OpenID Provider.
|
boolean |
verifyNonce(AuthSuccess authResp,
DiscoveryInformation discovered)
Verifies the nonce in an authentication response.
|
boolean |
verifyReturnTo(String receivingUrl,
AuthSuccess response)
Verifies that the URL where the Consumer (Relying Party) received the
authentication response matches the value of the "openid.return_to"
parameter in the authentication response.
|
public ConsumerManager()
@Inject public ConsumerManager(RealmVerifierFactory realmFactory, Discovery discovery, HttpFetcherFactory httpFetcherFactory)
public Discovery getDiscovery()
public void setDiscovery(Discovery discovery)
discovery - discovery process manager.public ConsumerAssociationStore getAssociations()
ConsumerAssociationStore@Inject public void setAssociations(ConsumerAssociationStore associations)
associations - ConsumerAssociationStore implementationConsumerAssociationStorepublic NonceVerifier getNonceVerifier()
NonceVerifier@Inject public void setNonceVerifier(NonceVerifier nonceVerifier)
nonceVerifier - NonceVerifier implementationNonceVerifierpublic DHParameterSpec getDHParams()
DiffieHellmanSessionpublic void setDHParams(DHParameterSpec dhParams)
dhParams - Object encapsulating modulus and generator numbersDiffieHellmanSessionpublic int getMaxAssocAttempts()
allowStateless(boolean) statelessAllowed()public void setMaxAssocAttempts(int maxAssocAttempts)
public void allowStateless(boolean allowStateless)
setAllowStateless(boolean)public boolean statelessAllowed()
isAllowStateless()public boolean isAllowStateless()
public void setAllowStateless(boolean allowStateless)
public AssociationSessionType getMinAssocSessEnc()
public void setMinAssocSessEnc(AssociationSessionType minAssocSessEnc)
allowStateless(boolean)public AssociationSessionType getPrefAssocSessEnc()
public void setPrefAssocSessEnc(AssociationSessionType prefAssocSessEnc)
public int getFailedAssocExpire()
setFailedAssocExpire(int)public void setFailedAssocExpire(int _failedAssocExpire)
_failedAssocExpire - time in seconds to remember failed
association attemptspublic int getPreExpiryAssocLockInterval()
public void setPreExpiryAssocLockInterval(int preExpiryAssocLockInterval)
preExpiryAssocLockInterval - The number of seconds for the
pre-expiry lock inteval.public boolean isImmediateAuth()
public void setImmediateAuth(boolean _immediateAuth)
public RealmVerifier getRealmVerifier()
public void setRealmVerifier(RealmVerifier realmVerifier)
public int getMaxNonceAge()
public void setMaxNonceAge(int ageSeconds)
public List discover(String identifier) throws DiscoveryException
DiscoveryInformation objects.
The list could be empty if no discovery information can
be retrieved.DiscoveryException - if the discovery process runs into errors.public ConsumerAssociationStore getPrivateAssociationStore()
public void setPrivateAssociationStore(ConsumerAssociationStore associations) throws ConsumerException
associations - The association store to be used for signing consumer nonces;
signing can be deactivated by setting this to null.
Signing is enabled by default.ConsumerExceptionpublic void setConnectTimeout(int connectTimeout)
public void setSocketTimeout(int socketTimeout)
public void setMaxRedirects(int maxRedirects)
public DiscoveryInformation associate(List discoveries)
discoveries - The DiscoveryInformation list obtained by
performing dicovery on the User-supplied OpenID
identifier. Should be ordered by the priority
of the service endpoints.Discovery.discover(org.openid4java.discovery.Identifier)public AuthRequest authenticate(List discoveries, String returnToUrl) throws ConsumerException, MessageException
discoveries - The DiscoveryInformation list obtained by
performing dicovery on the User-supplied OpenID
identifier. Should be ordered by the priority
of the service endpoints.returnToUrl - The URL on the Consumer site where the OpenID
Provider will return the user after generating
the authentication response. ConsumerExceptionMessageExceptionassociate(java.util.List)public AuthRequest authenticate(List discoveries, String returnToUrl, String realm) throws ConsumerException, MessageException
discoveries - The DiscoveryInformation list obtained by
performing dicovery on the User-supplied OpenID
identifier. Should be ordered by the priority
of the service endpoints.returnToUrl - The URL on the Consumer site where the OpenID
Provider will return the user after generating
the authentication response. realm - The URL pattern that will be presented to the
user when he/she will be asked to authorize the
authentication transaction. Must be a super-set
of the @returnToUrl.ConsumerExceptionMessageExceptionassociate(java.util.List)public AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl) throws MessageException, ConsumerException
discovered - A DiscoveryInformation endpoint from the list
obtained by performing dicovery on the
User-supplied OpenID identifier.returnToUrl - The URL on the Consumer site where the OpenID
Provider will return the user after generating
the authentication response. MessageExceptionConsumerExceptionpublic AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl, String realm) throws MessageException, ConsumerException
discovered - A DiscoveryInformation endpoint from the list
obtained by performing dicovery on the
User-supplied OpenID identifier.returnToUrl - The URL on the Consumer site where the OpenID
Provider will return the user after generating
the authentication response. realm - The URL pattern that will be presented to the
user when he/she will be asked to authorize the
authentication transaction. Must be a super-set
of the @returnToUrl.MessageExceptionConsumerExceptionpublic VerificationResult verify(String receivingUrl, ParameterList response, DiscoveryInformation discovered) throws MessageException, DiscoveryException, AssociationException
receivingUrl - The URL where the Consumer (Relying Party) has
accepted the incoming message.response - ParameterList of the authentication response
being verified.discovered - Previously discovered information (which can
therefore be trusted) obtained during the discovery
phase; this should be stored and retrieved by the RP
in the user's session.MessageExceptionDiscoveryExceptionAssociationExceptionpublic boolean verifyReturnTo(String receivingUrl, AuthSuccess response)
receivingUrl - The URL where the Consumer received the
authentication response.response - The authentication response.public Map extractQueryParams(URL url) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic boolean verifyNonce(AuthSuccess authResp, DiscoveryInformation discovered)
authResp - The authentication response containing the nonce
to be verified.discovered - The discovery information associated with the
authentication transaction.public String insertConsumerNonce(String opUrl, String returnTo)
opUrl - The endpoint to be used for private association.returnTo - The return_to URL to which a custom nonce
parameter will be added.public String extractConsumerNonce(String returnTo, String opUrl)
returnTo - return_to URL from the authentication responseopUrl - URL for the appropriate OP endpointCopyright © 2015 WSO2. All rights reserved.