Class OAuthUtils
- java.lang.Object
-
- org.apache.synapse.endpoints.auth.oauth.OAuthUtils
-
public class OAuthUtils extends Object
Helper class to build OAuth handlers using the synapse configuration of the endpoints.
-
-
Constructor Summary
Constructors Constructor Description OAuthUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
append401HTTPSC(MessageContext synCtx)
Method to append 401 status code to NON_ERROR_HTTP_STATUS_CODES property.static org.apache.axiom.om.OMElement
createOMElementWithValue(org.apache.axiom.om.OMFactory omFactory, String elementName, String elementValue)
This method returns an OMElement containing the elementValue encapsulated by the elementName.static org.apache.axiom.om.OMElement
createOMRequestParams(org.apache.axiom.om.OMFactory omFactory, Map<String,String> requestParametersMap)
Create an OMElement for request parameter map.static String
getChildValue(org.apache.axiom.om.OMElement parentElement, String childName)
Method to get the value inside a child element.static int
getOauthTimeouts(org.apache.axiom.om.OMElement parentElement, String childName)
static String
getRandomOAuthHandlerID()
Method to generate a random id for each OAuth handler.static OAuthHandler
getSpecificOAuthHandler(org.apache.axiom.om.OMElement oauthElement)
This method will return an OAuthHandler instance depending on the oauth configs.static String
resolveExpression(String value, MessageContext messageContext)
This method evaluate the value as an expression or return the value.static boolean
retryOnOAuthFailure(OAuthConfiguredHTTPEndpoint httpEndpoint, MessageContext synapseInMsgCtx, MessageContext synapseOutMsgCtx)
Method to check whether retry is needed.
-
-
-
Method Detail
-
getSpecificOAuthHandler
public static OAuthHandler getSpecificOAuthHandler(org.apache.axiom.om.OMElement oauthElement)
This method will return an OAuthHandler instance depending on the oauth configs.- Parameters:
oauthElement
- Element containing OAuth configs- Returns:
- OAuthHandler object
-
getChildValue
public static String getChildValue(org.apache.axiom.om.OMElement parentElement, String childName)
Method to get the value inside a child element.- Parameters:
parentElement
- Parent OMElementchildName
- name of the child- Returns:
- String containing the value of the child
-
getOauthTimeouts
public static int getOauthTimeouts(org.apache.axiom.om.OMElement parentElement, String childName)
-
getRandomOAuthHandlerID
public static String getRandomOAuthHandlerID()
Method to generate a random id for each OAuth handler.- Returns:
- String containing random id
-
retryOnOAuthFailure
public static boolean retryOnOAuthFailure(OAuthConfiguredHTTPEndpoint httpEndpoint, MessageContext synapseInMsgCtx, MessageContext synapseOutMsgCtx)
Method to check whether retry is needed.- Parameters:
httpEndpoint
- OAuth Configured HTTP Endpoint related to the message contextsynapseInMsgCtx
- MessageContext that has been receivedsynapseOutMsgCtx
- Corresponding outgoing Synapse MessageContext for the above received MessageContext- Returns:
- true if the call needs to be retried
-
resolveExpression
public static String resolveExpression(String value, MessageContext messageContext) throws AuthException
This method evaluate the value as an expression or return the value.- Parameters:
value
- String parameter valuemessageContext
- MessageContext of the request- Returns:
- evaluated String value or the passed value itself
- Throws:
AuthException
-
append401HTTPSC
public static void append401HTTPSC(MessageContext synCtx)
Method to append 401 status code to NON_ERROR_HTTP_STATUS_CODES property.- Parameters:
synCtx
- MessageContext of the request
-
createOMElementWithValue
public static org.apache.axiom.om.OMElement createOMElementWithValue(org.apache.axiom.om.OMFactory omFactory, String elementName, String elementValue)
This method returns an OMElement containing the elementValue encapsulated by the elementName.- Parameters:
elementName
- Name of the OMElementelementValue
- Value of the OMElement- Returns:
- OMElement containing the value encapsulated by the elementName
-
createOMRequestParams
public static org.apache.axiom.om.OMElement createOMRequestParams(org.apache.axiom.om.OMFactory omFactory, Map<String,String> requestParametersMap)
Create an OMElement for request parameter map.- Parameters:
requestParametersMap
- input parameter map.- Returns:
- OMElement of parameter map.
-
-