Class FSServiceUtils
- java.lang.Object
-
- com.sun.identity.federation.services.util.FSServiceUtils
-
public class FSServiceUtils extends Object
Util class to provide methods to manage ID-FF service.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddMetaAlias(String url, String metaAlias)Appends meta alias to the URL.static jakarta.xml.soap.SOAPMessageconvertDOMToSOAP(Document doc)ConvertsDOMdocument toSOAPmessage.static NodecreateSOAPDOM(jakarta.xml.soap.SOAPMessage message)ConvertsSOAPmessage toDOMelement.static StringgetAffiliationID(String realm, String entityID)Gets the Affiliation ID for the provider that it belongs.static StringgetAssertionConsumerServiceURL(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType spDescriptor, String id)Finds approriate assertion consumer service URL.static StringgetBaseURL()static StringgetBaseURL(jakarta.servlet.http.HttpServletRequest request)Returns base url of a request.static StringgetCommonLoginPageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)Returns common login page URL.static StringgetCommonLoginPageURL(String metaAlias, String resourceUrl, String requestId, jakarta.servlet.http.HttpServletRequest request, String baseURL)Returns common login page URL based on the deployment descriptor and the meta alias associated with the hosted provider.static StringgetConsentPageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)Returns the list of circle of trusts page URL.static StringgetDefaultPageURL(jakarta.servlet.http.HttpServletRequest request, String pageName)Returns default page URL.static StringgetDoFederatePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)Returns do federate page URL.static StringgetErrorPageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)Returns error page URL.static StringgetFederationDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)Returns federation done page URL.static StringgetFirstProtocolProfile(List profiles)Returns the first profile from the list.static StringgetLocale(jakarta.servlet.http.HttpServletRequest request)Retrieves locale of a http request.static StringgetLogoutDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)Returns logout done page URL.static StringgetMetaAlias(jakarta.servlet.http.HttpServletRequest request)Retrieves meta alias of a provider from http request.static intgetMinorVersion(List protocolEnum)Returns the minor version of supported protocol.static StringgetRegistrationDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)Returns registration done page URL.static StringgetServicesBaseURL(jakarta.servlet.http.HttpServletRequest request)Returns the base URL for OpenAM services deployment.static FederationSPAdaptergetSPAdapter(String hostEntityID, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostSPConfig)static MapgetSPAuthContextInfo(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostConfig)Returns service provider's authentication context mappings.static StringgetTerminationDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)Returns termination done page URL.static booleanisLECPProfile(jakarta.servlet.http.HttpServletRequest request)Determines whether the request contains LECP header or not.static booleanisRegisProfileSOAP(String userID, String remoteEntityId, com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType remoteDescriptor, String metaAlias, com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType hostedDescriptor)Determines if the registration profile is SOAP or not.static booleanisSigningOn()Returnstrueif signing is enabled; otherwise, it will return false.static booleanisSigningOptional()Returnstrueif signing is optional else it will returnfalse.static MapparseAttributeConfig(List list)Parses the attribute map configuration and returns as javajava.util.Map.static StringprintDocument(Node root)Outputs the DOM representation given as root as XML string.static voidredirectForAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String hostedProviderAlias)Redirects the HTTP request to the Authentication module.static voidreturnLocallyAfterOperation(jakarta.servlet.http.HttpServletResponse response, String opDoneURL, boolean isSuccess, String successString, String failureString)Invoked at the end when an operation is done.static voidreturnToSource(jakarta.servlet.http.HttpServletResponse response, String retURL, String commonErrorPage, String errorLocaleString, String remarkLocaleString)Determines the return location and redirects based on federation termination Return URL of the provider that sent the termination requeststatic voidshowErrorPage(jakarta.servlet.http.HttpServletResponse response, String commonErrorPage, String errorLocaleString, String remarkLocaleString)Displays error page.
-
-
-
Method Detail
-
isSigningOn
public static boolean isSigningOn()
Returnstrueif signing is enabled; otherwise, it will return false. If signing is enabled, all the liberty requests/responses must be signed/verfied.- Returns:
trueif signing is on; otherwise, returnfalse
-
isSigningOptional
public static boolean isSigningOptional()
Returnstrueif signing is optional else it will returnfalse. If signing is optional, sign/verfyResponse/Assertiononly if it is required by the specification.- Returns:
trueif signing is optional; otherwise returnfalse
-
getCommonLoginPageURL
public static String getCommonLoginPageURL(String metaAlias, String resourceUrl, String requestId, jakarta.servlet.http.HttpServletRequest request, String baseURL)
Returns common login page URL based on the deployment descriptor and the meta alias associated with the hosted provider.- Parameters:
metaAlias- the meta alias of the hosted providerresourceUrl- resource URL to redirect torequestId- theAuthnRequestIdrequest-HttpServletRequestobjectbaseURL- deployment base URL- Returns:
- the common login page URL; or
nullif an error occurred during the process.
-
getBaseURL
public static String getBaseURL()
-
getMetaAlias
public static String getMetaAlias(jakarta.servlet.http.HttpServletRequest request)
Retrieves meta alias of a provider from http request.- Parameters:
request-HttpServletRequestobject- Returns:
- meta alias of a provider embeded in the request url
-
getLocale
public static String getLocale(jakarta.servlet.http.HttpServletRequest request)
Retrieves locale of a http request.- Parameters:
request-HttpServletRequestobject- Returns:
- locale of the request; or
nullif locale cannot be retrieved.
-
getServicesBaseURL
public static String getServicesBaseURL(jakarta.servlet.http.HttpServletRequest request)
Returns the base URL for OpenAM services deployment.- Parameters:
request- HttpServletRequest- Returns:
- service base url
-
getBaseURL
public static String getBaseURL(jakarta.servlet.http.HttpServletRequest request)
Returns base url of a request.- Parameters:
request-HttpServletRequestobject- Returns:
- base url
-
printDocument
public static String printDocument(Node root) throws TransformerException, TransformerConfigurationException, FileNotFoundException
Outputs the DOM representation given as root as XML string.- Parameters:
root- TheDOMrepresentation to be outputted- Returns:
- string representation of
DOMnode. - Throws:
TransformerExceptionTransformerConfigurationExceptionFileNotFoundException
-
createSOAPDOM
public static Node createSOAPDOM(jakarta.xml.soap.SOAPMessage message)
ConvertsSOAPmessage toDOMelement.- Parameters:
message-SOAPmessage- Returns:
DOMelement
-
convertDOMToSOAP
public static jakarta.xml.soap.SOAPMessage convertDOMToSOAP(Document doc)
ConvertsDOMdocument toSOAPmessage.- Parameters:
doc-DOMdocument- Returns:
SOAPmessage
-
isLECPProfile
public static boolean isLECPProfile(jakarta.servlet.http.HttpServletRequest request)
Determines whether the request contains LECP header or not.- Parameters:
request-HttpServletRequestobject- Returns:
trueif the request contains LECP header;falseotherwise.
-
getAffiliationID
public static String getAffiliationID(String realm, String entityID)
Gets the Affiliation ID for the provider that it belongs.- Parameters:
realm- The realm under which the entity resides.entityID- provider's entity ID.- Returns:
- Affiliation ID.
-
parseAttributeConfig
public static Map parseAttributeConfig(List list)
Parses the attribute map configuration and returns as javajava.util.Map.- Parameters:
list- attribute configuration.- Returns:
- configured attribute mapping with key as the SAML attribute and the value being the local attribute.
-
showErrorPage
public static void showErrorPage(jakarta.servlet.http.HttpServletResponse response, String commonErrorPage, String errorLocaleString, String remarkLocaleString)Displays error page.- Parameters:
response-HttpServletResponseobjectcommonErrorPage- redirect url for error pageerrorLocaleString- locale string for the error messageremarkLocaleString- locale string for the error remark
-
redirectForAuthentication
public static void redirectForAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String hostedProviderAlias) throws IOExceptionRedirects the HTTP request to the Authentication module. The authentication URL is built based on the organization that is associated with the provider- Parameters:
request-HttpServletRequestobject that contains the request the client has made of the servlet.response-HttpServletResponseobject that contains the response the servlet sends to the client.hostedProviderAlias- meta alias that identifies the local hosted provider- Throws:
IOException- If an input or output exception occurs
-
returnLocallyAfterOperation
public static void returnLocallyAfterOperation(jakarta.servlet.http.HttpServletResponse response, String opDoneURL, boolean isSuccess, String successString, String failureString)Invoked at the end when an operation is done. The isSuccess determines if success message or failure message is displayed.- Parameters:
response- theHttpServletResponseobjectopDoneURL- where to go when an operation is doneisSuccess- determines the content of the operation-done.jspsuccessString- success string to be appended to url ifisSuccessis true.failureString- failure string to be appended to url ifisSuccessis false.
-
returnToSource
public static void returnToSource(jakarta.servlet.http.HttpServletResponse response, String retURL, String commonErrorPage, String errorLocaleString, String remarkLocaleString)Determines the return location and redirects based on federation termination Return URL of the provider that sent the termination request- Parameters:
response- http response objectretURL- operation return urlcommonErrorPage- where to go if error occurserrorLocaleString- locale string for federation errorremarkLocaleString- locale string for federation remark
-
getConsentPageURL
public static String getConsentPageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
Returns the list of circle of trusts page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended meta- Returns:
- the list of circle of trusts page URL.
-
getCommonLoginPageURL
public static String getCommonLoginPageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
Returns common login page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended meta- Returns:
- common login page URL.
-
getErrorPageURL
public static String getErrorPageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
Returns error page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended metametaAlias- hosted provider's meta alias- Returns:
- error page URL.
-
getTerminationDonePageURL
public static String getTerminationDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
Returns termination done page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended metametaAlias- hosted provider's meta alias- Returns:
- termination done page URL.
-
getRegistrationDonePageURL
public static String getRegistrationDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
Returns registration done page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended metametaAlias- hosted provider's meta alias- Returns:
- registration done page URL.
-
getLogoutDonePageURL
public static String getLogoutDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
Returns logout done page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended metametaAlias- hosted provider's meta alias- Returns:
- logout done page URL.
-
getFederationDonePageURL
public static String getFederationDonePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
Returns federation done page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended metametaAlias- hosted provider's meta alias- Returns:
- federation done page URL.
-
getDoFederatePageURL
public static String getDoFederatePageURL(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
Returns do federate page URL.- Parameters:
request-HttpServletRequestobjecthostedConfig- hosted provider's extended meta- Returns:
- do federate page URL.
-
getDefaultPageURL
public static String getDefaultPageURL(jakarta.servlet.http.HttpServletRequest request, String pageName)
Returns default page URL.- Parameters:
request- HTTP Servlet Request.pageName- the page name whose url to be retrieved- Returns:
- String the Page URL.
-
addMetaAlias
public static String addMetaAlias(String url, String metaAlias)
Appends meta alias to the URL.- Parameters:
url- string urlmetaAlias- meta alias to be appended- Returns:
- the url with meta alias added
-
getAssertionConsumerServiceURL
public static String getAssertionConsumerServiceURL(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType spDescriptor, String id)
Finds approriate assertion consumer service URL.- Parameters:
spDescriptor- sevice provider's meta descriptorid- requested assertion consumer service url id. It could benull.- Returns:
- assertion consumer server URL.
-
getFirstProtocolProfile
public static String getFirstProtocolProfile(List profiles)
Returns the first profile from the list.- Parameters:
profiles- list of profiles- Returns:
- the first profile of the list
-
getSPAuthContextInfo
public static Map getSPAuthContextInfo(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostConfig)
Returns service provider's authentication context mappings.- Parameters:
hostConfig- hosted provider' setended meta- Returns:
- authentication context mapping
-
isRegisProfileSOAP
public static boolean isRegisProfileSOAP(String userID, String remoteEntityId, com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType remoteDescriptor, String metaAlias, com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType hostedDescriptor)
Determines if the registration profile is SOAP or not.- Parameters:
userID- id of the user subject to registrationremoteEntityId- remote provider's entity IDremoteDescriptor- remote provider's meta descriptormetaAlias- hosted provider's meta aliashostedDescriptor- hosted provider's meta descriptor- Returns:
trueif the registration profile is SOAP;falseotherwise.
-
getMinorVersion
public static int getMinorVersion(List protocolEnum)
Returns the minor version of supported protocol.- Parameters:
protocolEnum- list of supported protocols- Returns:
- minor version of first supported protocol
-
getSPAdapter
public static FederationSPAdapter getSPAdapter(String hostEntityID, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostSPConfig)
-
-