|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.pingidentity.opentoken.Agent
public class Agent
Provides the methods necessary for generating and consuming a valid OpenToken cookie or query parameter.
Field Summary | |
---|---|
static String |
OPENTOKEN_SYSTEM_DEBUG
Debug flag for bypassing encryption for test purposes |
static String |
TOKEN_NOT_BEFORE
Key into token values collection for not-before value |
static String |
TOKEN_NOT_ON_OR_AFTER
Key into token values collection for not-on-or-after value |
static String |
TOKEN_RENEW_UNTIL
Key into token values collection for renew-until value |
static String |
TOKEN_SUBJECT
Key into token values collection for subject value |
Constructor Summary | |
---|---|
Agent()
Constructs an Agent with default values. |
|
Agent(AgentConfiguration configuration)
Constructs an Agent using configuration from the provided AgentConfiguration. |
|
Agent(boolean loadDefaultConfigurationFile)
Constructs an Agent using configuration file on CLASSPATH. |
|
Agent(InputStream configStream)
Constructs an Agent using the configuration from the provided InputStream. |
|
Agent(String file)
Constructs an Agent using a configuration file on CLASSPATH. |
Method Summary | |
---|---|
static Map |
convertFromMultiMap(org.apache.commons.collections.MultiMap attributes)
|
static org.apache.commons.collections.MultiMap |
convertToMultiMap(Map attributes)
|
void |
deleteToken(javax.servlet.http.HttpServletResponse response)
Deletes the token from the provided response; applicable only when AgentConfiguration.isUseCookie() is true. |
AgentConfiguration |
getAgentConfiguration()
Returns a copy of Agent configuration. |
String |
getLastError()
This function should be used to generate log messages when the Agent encounters an error. |
void |
loadConfiguration(InputStream is)
Deprecated. as of version 1.3 |
Map |
readToken(javax.servlet.http.HttpServletRequest request)
Reads key/value pairs stored in a token on the provided request. |
Map |
readToken(String token)
Reads key/value pairs stored in a token string. |
org.apache.commons.collections.MultiMap |
readTokenToMultiMap(javax.servlet.http.HttpServletRequest request)
Reads key/value(s) pairs stored in a token on the provided request. |
org.apache.commons.collections.MultiMap |
readTokenToMultiMap(String token)
Reads key/value(s) pairs stored in a token string. |
String |
writeToken(Map ids)
Writes map of key/value pairs to a new token, returns token as a string. |
void |
writeToken(Map ids,
javax.servlet.http.HttpServletResponse response,
String targetUrl)
Writes map of key/value pairs to a new token, then redirects to targetUrl. |
void |
writeToken(Map ids,
javax.servlet.http.HttpServletResponse response,
UrlHelper targetUrl)
Writes map of key/value pairs to a new token, then redirects to targetUrl. |
void |
writeToken(Map ids,
javax.servlet.http.HttpServletResponse response,
UrlHelper targetUrl,
boolean doRedirect)
Writes map of key/value pairs to a new token, then optionally redirects to targetUrl. |
String |
writeToken(org.apache.commons.collections.MultiMap ids)
Writes map of key/value(s) pairs to a new token, returns token as a string. |
void |
writeToken(org.apache.commons.collections.MultiMap ids,
javax.servlet.http.HttpServletResponse response,
String targetUrl)
Writes map key/value(s) pairs to a new token, then redirects to targetUrl. |
void |
writeToken(org.apache.commons.collections.MultiMap ids,
javax.servlet.http.HttpServletResponse response,
UrlHelper targetUrl)
Writes map of key/value(s) pairs to a new token, then redirects to targetUrl. |
void |
writeToken(org.apache.commons.collections.MultiMap ids,
javax.servlet.http.HttpServletResponse response,
UrlHelper targetUrl,
boolean doRedirect)
Writes map of key/value(s) pairs to a new token, then optionally redirects to targetUrl. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TOKEN_SUBJECT
public static final String TOKEN_NOT_BEFORE
public static final String TOKEN_NOT_ON_OR_AFTER
public static final String TOKEN_RENEW_UNTIL
public static final String OPENTOKEN_SYSTEM_DEBUG
Constructor Detail |
---|
public Agent()
public Agent(boolean loadDefaultConfigurationFile)
AgentConfiguration.AGENT_CONFIG_FILE_DEFALUT
. If the file is not found,
an Agent is constructed using default values.
loadDefaultConfigurationFile
- if true, loads the configuration file with name AgentConfiguration.AGENT_CONFIG_FILE_DEFALUT
located on the CLASSPATH if available; if false, an Agent is constructed using default valuespublic Agent(InputStream configStream) throws IOException
configStream
- an InputStream containing agent configuration
IOException
- when the configuration is invalid or the configStream generates an errorpublic Agent(AgentConfiguration configuration)
<bean id='agent' class='com.pingidentity.opentoken.Agent'> <constructor-arg type='com.pingidentity.opentoken.AgentConfiguration'> <bean class='com.pingidentity.opentoken.AgentConfiguration'> <property name='cookieDomain' value='.example.com' /> <property name='cookiePath' value='/' /> <property name='notBeforeTolerance' value='120' /> <property name='password' value='welcome1'/> <property name='cipherSuite' value="3"/> <property name='renewUntilLifetime' value='43200' /> <property name='tokenLifetime' value='900' /> <property name='tokenName' value='opentoken' /> <property name='useCookie' value='true' /> <property name='sessionCookie' value='true' /> <property name='secureCookie' value='true' /> </bean> </constructor-arg> </bean>
configuration
- an AgentConfiguration
containing agent configuration:
copy of AgentConfiguration is made to prevent mutabilitypublic Agent(String file) throws IOException
file
- filename on CLASSPATH or fully qualified path to the file on disk
IOException
Method Detail |
---|
public String getLastError()
public AgentConfiguration getAgentConfiguration()
public Map readToken(String token) throws TokenException
getLastError()
will
provide an error message describing the problem.
token
- as String
TokenException
- when the token is present but invalid, or decoding errors are encounteredpublic org.apache.commons.collections.MultiMap readTokenToMultiMap(String token) throws TokenException
getLastError()
will
provide an error message describing the problem.
token
- as String
TokenException
- when the token is present but invalid, or decoding errors are encounteredpublic Map readToken(javax.servlet.http.HttpServletRequest request) throws TokenException
getLastError()
will
provide an error message describing the problem.
request
- HttpServletRequest containing the token in query parameter or cookie with name AgentConfiguration.getTokenName()
TokenException
- when the token is present but invalid, or decoding errors are encounteredpublic org.apache.commons.collections.MultiMap readTokenToMultiMap(javax.servlet.http.HttpServletRequest request) throws TokenException
getLastError()
will
provide an error message describing the problem.
request
- HttpServletRequest containing token in query parameter or cookie with name AgentConfiguration.getTokenName()
TokenException
- when the token is present but invalid, or decoding errors are encounteredpublic void writeToken(Map ids, javax.servlet.http.HttpServletResponse response, String targetUrl) throws MalformedURLException, IOException, TokenException
ids
- map of key/value pairsresponse
- HttpServletResponse to write the token totargetUrl
- the URL to redirect to, once a token is written
MalformedURLException
- if the targetUrl is not a valid URL
IOException
- if errors are encountered when writing the response
TokenException
- if errors are encountered when encoding the tokenpublic void writeToken(org.apache.commons.collections.MultiMap ids, javax.servlet.http.HttpServletResponse response, String targetUrl) throws MalformedURLException, IOException, TokenException
ids
- MultiMap of key/value(s) pairsresponse
- HttpServletResponse to write the token totargetUrl
- the URL to redirect to, once a token is written
MalformedURLException
- if the targetUrl is not a valid URL
IOException
- if errors are encountered when writing the response
TokenException
- if errors are encountered when encoding the tokenpublic void writeToken(Map ids, javax.servlet.http.HttpServletResponse response, UrlHelper targetUrl) throws IOException, TokenException
ids
- map of key/value pairsresponse
- HttpServletResponse to write the token totargetUrl
- the URL to redirect to, once a token is written
IOException
TokenException
public void writeToken(org.apache.commons.collections.MultiMap ids, javax.servlet.http.HttpServletResponse response, UrlHelper targetUrl) throws IOException, TokenException
ids
- MultiMap of key/value(s) pairsresponse
- HttpServletResponse to write the token totargetUrl
- the URL to redirect to, once a token is written
IOException
TokenException
public void writeToken(Map ids, javax.servlet.http.HttpServletResponse response, UrlHelper targetUrl, boolean doRedirect) throws IOException, TokenException
ids
- map of key/value pairsresponse
- HttpServletResponse to write the token totargetUrl
- the URL to redirect to, once a token is writtendoRedirect
- flag indicating if the response should be automatically redirected to targetUrl
IOException
TokenException
public void writeToken(org.apache.commons.collections.MultiMap ids, javax.servlet.http.HttpServletResponse response, UrlHelper targetUrl, boolean doRedirect) throws IOException, TokenException
ids
- map of key/value(s) pairsresponse
- HttpServletResponse to write the token totargetUrl
- the URL to redirect to, once a token is writtendoRedirect
- flag indicating if the response should be automatically redirected to targetUrl
IOException
TokenException
public String writeToken(Map ids) throws TokenException
ids
- map of key/value pairs
TokenException
public String writeToken(org.apache.commons.collections.MultiMap ids) throws TokenException
ids
- map of key/value(s) pairs
TokenException
public void loadConfiguration(InputStream is) throws IOException
is
- source of configuration data
IOException
public void deleteToken(javax.servlet.http.HttpServletResponse response)
AgentConfiguration.isUseCookie()
is true.
response
- the HttpServletResponse from which to delete the tokenpublic static Map convertFromMultiMap(org.apache.commons.collections.MultiMap attributes)
public static org.apache.commons.collections.MultiMap convertToMultiMap(Map attributes)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |