|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.spiffyui.client.rest.RESTility
public final class RESTility
A set of utilities for calling REST from GWT.
Nested Class Summary | |
---|---|
class |
RESTility.HTTPMethod
This is a helper type class so we can pass the HTTP method as a type safe object instead of a string. |
Field Summary | |
---|---|
static RESTility.HTTPMethod |
DELETE
This method represents an HTTP DELETE request |
static RESTility.HTTPMethod |
GET
This method represents an HTTP GET request |
static RESTility.HTTPMethod |
POST
This method represents an HTTP POST request |
static RESTility.HTTPMethod |
PUT
This method represents an HTTP PUT request |
Method Summary | |
---|---|
static void |
addLoginListener(RESTLoginCallBack callback)
Add login listeners |
static void |
callREST(java.lang.String url,
RESTCallback callback)
Make a rest call using an HTTP GET to the specified URL. |
static void |
callREST(java.lang.String url,
java.lang.String data,
RESTCallback callback)
Make a rest call using an HTTP GET to the specified URL including the specified data.. |
static void |
callREST(java.lang.String url,
java.lang.String data,
RESTility.HTTPMethod method,
RESTCallback callback)
Make an HTTP call and get the results as a JSON object. |
static void |
callREST(java.lang.String url,
java.lang.String data,
RESTility.HTTPMethod method,
RESTCallback callback,
boolean isLoginRequest,
boolean shouldReplay,
java.lang.String etag)
Make an HTTP call and get the results as a JSON object. |
protected static void |
callREST(java.lang.String url,
java.lang.String data,
RESTility.HTTPMethod method,
RESTCallback callback,
boolean isLoginRequest,
java.lang.String etag)
Make an HTTP call and get the results as a JSON object. |
static void |
callREST(java.lang.String url,
java.lang.String data,
RESTility.HTTPMethod method,
RESTCallback callback,
java.lang.String etag)
Make an HTTP call and get the results as a JSON object. |
static void |
doLocalLogout()
Upon logout, delete cookie and clear out all member variables |
protected static void |
finishRESTCalls()
In some cases, like login, the original REST call returns an error and we need to run it again. |
protected static void |
fireLoginSuccess()
Fire the login success event to all listeners if it hasn't been fired already. |
static RESTAuthProvider |
getAuthProvider()
Gets the current auth provider which will be used for future REST calls. |
protected static java.lang.String |
getBestLocale()
Returns best matched locale |
static java.lang.String |
getFullAuthToken()
Returns user's full authentication token, prefixed with "X-OPAQUE" |
static java.util.List<RESTLoginCallBack> |
getLoginListeners()
|
static java.lang.String |
getSessionCookiePath()
Get the path of the session cookie. |
protected static java.lang.String |
getTokenServerLogoutUrl()
Returns authentication server logout url |
protected static java.lang.String |
getTokenServerUrl()
Returns the authentication server url |
static java.lang.String |
getTokenType()
Returns user's authentication token type |
static java.lang.String |
getUsername()
Returns the name of the currently logged in user or null if the current user is not logged in. |
static java.lang.String |
getUserToken()
Returns user's authentication token |
static boolean |
hasUserLoggedIn()
Returns a boolean flag indicating whether user has logged in or not |
static void |
login(RESTCallback callback,
Response response,
java.lang.String url,
java.lang.String errorCode)
Make a login request using RESTility authentication framework. |
static RESTility.HTTPMethod |
parseString(java.lang.String method)
Returns HTTPMethod corresponding to method name. |
static void |
removeLoginListener(RESTLoginCallBack callback)
Remove login listeners |
static void |
setAuthProvider(RESTAuthProvider authProvider)
Sets the authentication provider used for future REST requests. |
static void |
setBestLocale(java.lang.String locale)
We can't know the best locale until after the user logs in because we need to consider their locale from the identity vault. |
static void |
setSessionCookiePath(java.lang.String newPath)
Set the path for the Spiffy_Session cookie. |
protected static void |
setTokenServerLogoutURL(java.lang.String url)
Set the authentication server logout url in JavaScript memory and and saves it in a cookie. |
protected static void |
setTokenServerURL(java.lang.String url)
Set the authentication server url in JavaScript memory and and saves it in a cookie. |
static void |
setTokenType(java.lang.String type)
Set the type of token RESTility will pass. |
protected static void |
setUsername(java.lang.String username)
Set the user name in JavaScript memory and and saves it in a cookie. |
protected static void |
setUserToken(java.lang.String token)
Set the user token in JavaScript memory and and saves it in a cookie. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final RESTility.HTTPMethod GET
public static final RESTility.HTTPMethod PUT
public static final RESTility.HTTPMethod POST
public static final RESTility.HTTPMethod DELETE
Method Detail |
---|
public static final void setAuthProvider(RESTAuthProvider authProvider)
Sets the authentication provider used for future REST requests.
By default authentication is provided by the AuthUtil class, but this class may be replaced to provide support for custom authentication schemes.
authProvider
- the new authentication providerAuthUtil
public static final RESTAuthProvider getAuthProvider()
public static void login(RESTCallback callback, Response response, java.lang.String url, java.lang.String errorCode) throws RESTException
callback
- the rest callback called when the login is completeresponse
- the response from the server requiring the loginurl
- the URL of the authentication servererrorCode
- the error code from the server returned with the 401
RESTException
- if there was an exception when making the login requestpublic static RESTility.HTTPMethod parseString(java.lang.String method)
method
- a String representation of a http method
public static void doLocalLogout()
protected static void finishRESTCalls()
public static void callREST(java.lang.String url, RESTCallback callback)
callback
- the callback to invokeurl
- the properly encoded REST url to callpublic static void callREST(java.lang.String url, java.lang.String data, RESTCallback callback)
url
- the properly encoded REST url to calldata
- the data to pass to the URLcallback
- the callback to invokeprotected static void setUserToken(java.lang.String token)
token
- user tokenprotected static void setTokenServerURL(java.lang.String url)
url
- authentication server urlprotected static void fireLoginSuccess()
public static void setTokenType(java.lang.String type)
Set the type of token RESTility will pass.
Most of the time the token type is specified by the REST server and the client does not have to specify this value. This method is mostly used for testing.
type
- the token typeprotected static void setUsername(java.lang.String username)
username
- user nameprotected static void setTokenServerLogoutURL(java.lang.String url)
url
- authentication server logout urlpublic static void setBestLocale(java.lang.String locale)
locale
- the localepublic static void setSessionCookiePath(java.lang.String newPath)
Set the path for the Spiffy_Session cookie.
When Spiffy UI uses token based authentication it saves token and user information in a cookie named Spiffy_Session. This cookie allows the user to remain logged in after they refresh the page the reset JavaScript memory.
By default that cookie uses the path of the current page. If an application uses multiple pages it can make sense to use a more general path for this cookie to make it available to other URLs in the application.
The path must be set before the first authentication request. If it is called afterward the cookie path will not change.
newPath
- the new path for the cookie or null if the cookie should use the path of the current pagepublic static java.lang.String getSessionCookiePath()
public static boolean hasUserLoggedIn()
public static java.lang.String getFullAuthToken()
public static java.lang.String getUserToken()
public static java.lang.String getTokenType()
protected static java.lang.String getTokenServerUrl()
protected static java.lang.String getTokenServerLogoutUrl()
public static java.lang.String getUsername()
protected static java.lang.String getBestLocale()
public static java.util.List<RESTLoginCallBack> getLoginListeners()
public static void callREST(java.lang.String url, java.lang.String data, RESTility.HTTPMethod method, RESTCallback callback)
url
- the properly encoded REST url to calldata
- the data to pass to the URLmethod
- the HTTP method, defaults to GETcallback
- the callback object for handling the request resultspublic static void callREST(java.lang.String url, java.lang.String data, RESTility.HTTPMethod method, RESTCallback callback, java.lang.String etag)
url
- the properly encoded REST url to calldata
- the data to pass to the URLmethod
- the HTTP method, defaults to GETcallback
- the callback object for handling the request resultsetag
- the option etag for this requestprotected static void callREST(java.lang.String url, java.lang.String data, RESTility.HTTPMethod method, RESTCallback callback, boolean isLoginRequest, java.lang.String etag)
url
- the properly encoded REST url to calldata
- the data to pass to the URLmethod
- the HTTP method, defaults to GETcallback
- the callback object for handling the request resultsisLoginRequest
- true if this is a request to login and false otherwiseetag
- the option etag for this requestpublic static void callREST(java.lang.String url, java.lang.String data, RESTility.HTTPMethod method, RESTCallback callback, boolean isLoginRequest, boolean shouldReplay, java.lang.String etag)
url
- the properly encoded REST url to calldata
- the data to pass to the URLmethod
- the HTTP method, defaults to GETcallback
- the callback object for handling the request resultsisLoginRequest
- true if this is a request to login and false otherwiseshouldReplay
- true if this request should repeat after a login request
if this request returns a 401etag
- the option etag for this requestpublic static void addLoginListener(RESTLoginCallBack callback)
callback
- listeners to be addedpublic static void removeLoginListener(RESTLoginCallBack callback)
callback
- listeners to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |