|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sakaiproject.hybrid.util.XSakaiToken
public class XSakaiToken
Utility class for dealing with x-sakai-token semantics. Note: Class is thread safe.
| Field Summary | |
|---|---|
protected org.sakaiproject.component.api.ComponentManager |
componentManager
|
static String |
CONFIG_PREFIX
|
static String |
CONFIG_SHARED_SECRET_SUFFIX
|
protected org.sakaiproject.component.api.ServerConfigurationService |
serverConfigurationService
|
protected org.sakaiproject.tool.api.SessionManager |
sessionManager
|
protected Signature |
signature
|
static String |
TOKEN_SEPARATOR
|
static String |
X_SAKAI_TOKEN_HEADER
|
| Constructor Summary | |
|---|---|
XSakaiToken(org.sakaiproject.component.api.ComponentManager componentManager)
|
|
| Method Summary | |
|---|---|
String |
createToken(String hostname)
This is the preferred signature for the createToken methods as it looks up the current userId from the current session. |
String |
createToken(String hostname,
String eid)
Perform sharedSecret lookup from getSharedSecret(String),
compute hash based on eid and return token. |
String |
getSharedSecret(String hostname)
Look up a sharedSecret from sakai.properties. |
String |
getToken(javax.servlet.http.HttpServletRequest request)
Simply grab the x-sakai-token from the request. |
String |
getValidatedEid(javax.servlet.http.HttpServletRequest request,
String sharedSecret)
Validate the token using the passed sharedSecret and return username. |
String |
getValidatedEid(String token,
String sharedSecret)
Validate the token using the passed sharedSecret and return username. |
String |
signMessage(String sharedSecret,
String eid)
Compute hash based on sharedSecret and eid. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String X_SAKAI_TOKEN_HEADER
public static final String CONFIG_PREFIX
public static final String CONFIG_SHARED_SECRET_SUFFIX
public static final String TOKEN_SEPARATOR
protected transient Signature signature
protected transient org.sakaiproject.component.api.ComponentManager componentManager
protected transient org.sakaiproject.component.api.ServerConfigurationService serverConfigurationService
protected transient org.sakaiproject.tool.api.SessionManager sessionManager
| Constructor Detail |
|---|
public XSakaiToken(org.sakaiproject.component.api.ComponentManager componentManager)
componentManager - Used to obtain references to
ServerConfigurationService, and SessionManager
IllegalArgumentException
IllegalStateException| Method Detail |
|---|
public String getToken(javax.servlet.http.HttpServletRequest request)
request -
IllegalArgumentException
public String getValidatedEid(javax.servlet.http.HttpServletRequest request,
String sharedSecret)
request - sharedSecret -
IllegalArgumentException
public String getValidatedEid(String token,
String sharedSecret)
token - null values are acceptable.sharedSecret -
IllegalArgumentExceptionpublic String createToken(String hostname)
hostname - Fully qualified domain name or an IP address. See:
getSharedSecret(String).
IllegalArgumentException
public String createToken(String hostname,
String eid)
throws Error
getSharedSecret(String),
compute hash based on eid and return token. If possible, you should use
the createToken(String) method signature as it is less error
prone.
hostname - Fully qualified domain name or an IP address. See:
getSharedSecret(String).eid - Enterprise user id; usually a username.
Error - Wrapped exception if there is any unexpected trouble.
IllegalArgumentException
public String signMessage(String sharedSecret,
String eid)
sharedSecret - eid - Enterprise user id; usually a username.
Error - Wrapped exception if there is any unexpected trouble.
IllegalArgumentException
IllegalStateException - Wraps SignatureException into a
RuntimeException.public String getSharedSecret(String hostname)
x.sakai.token.server.domain.name.sharedSecret=yourSecret or x.sakai.token.127.0.0.1.sharedSecret=yourSecret
hostname - Fully qualified domain name or an IP address.
IllegalArgumentException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||