Partial Example of Using OAuth Customized Flow for WSDL, SOAP, and REST
The CustomFlow interface is made available to support customized options or processes so that they can obtain an access token and other parameters.
In OAuthProfileCallback, all required fields are provided in the UI. In each request:
• Construct the OAuthProfileCallback.Request with method info, request URL, request body and headers.
• Handle OAuthProfileCallback.Response to get results.
You might need to call handleAuthResponse several times while interacting with the service side. Because this is a simulation of the browser, it is your responsibility to extract the required information from OAuthProfileCallback.Response.
package com.compositesw.extension.security.oauth;
import java.util.Map;
/**Custom flow used for Extension Grants of OAuth2.0: http://tools.ietf.org/html/rfc6749#section-4.5.
* Any OAuth 2.0 flow with customized request or response that does not conform to RFC 6749 can be
* customized.
* With CustomFlow, a flow step is ignored if the request is NULL, or if no request info is defined
* in OAuthProfileCallback.
*/
public interface CustomFlow {
/**
* Build authorization request. If request info is NULL, the authorization step is ignored. */
public void buildAuthRequest(OAuthProfileCallback callback) throws Exception;
/**
* Handle authorization response. */
public void handleAuthResponse(OAuthProfileCallback callback) throws Exception;
/**
* Build access token request. If request info is NULL, the authorization step is ignored.
* The flow fails if both authorization request and access token request info are NULL.
*/
public void buildAccessTokenRequest(OAuthProfileCallback callback) throws Exception;
/**
* Handle access token response. */
public void handleAccessTokenResponse(OAuthProfileCallback callback) throws Exception;
/**
* Build refresh token request. If request info is NULL, the authorization step is ignored.
*/
public void buildRereshTokenRequest(OAuthProfileCallback callback) throws Exception;
/**
* Handle refresh token response. */
public void handleRefreshTokenResponse(OAuthProfileCallback callback) throws Exception;
/**
* All OAuth elements (access_token, refresh_token, expires_in, token_type, scope, etc.)
* extracted from response can be found in the value map returned by getOAuthElements(). */
public Map<String, Object> getOAuthElements();
/**
* Get access token. */
public String getAccessToken();
/**
* Get refresh token. */
public String getRefreshToken();
}