Class AuthUtils
- java.lang.Object
-
- com.sun.identity.authentication.client.AuthClientUtils
-
- com.sun.identity.authentication.service.AuthUtils
-
public class AuthUtils extends AuthClientUtils
-
-
Field Summary
Fields Modifier and Type Field Description static StringBUNDLE_NAMEstatic StringFORCE_AUTHName of parameter used to indicate authn process MUST be run.static intMODULEAuthentication type for Module based authentication after Composite Advicesstatic intREALMAuthentication type for Realm based authentication after Composite Advicesstatic intSERVICEAuthentication type for Service based authentication after Composite Advices-
Fields inherited from class com.sun.identity.authentication.client.AuthClientUtils
COMPOSITE_ADVICE, DEFAULT_CLIENT_TYPE, ERROR_MESSAGE, ERROR_TEMPLATE, MSG_DELIMITER, REDIRECT_URL_VALIDATOR, templatePath
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancheckForCookies(jakarta.servlet.http.HttpServletRequest req, AuthContextLocal ac)Returns true if cookies found in the request.static voidclearAllCookies(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)static voidclearAllCookiesByDomain(SessionID sid, String cookieDomain, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)static jakarta.servlet.http.CookiecreatelbCookie(AuthContextLocal authContext, String cookieDomain)static voiddestroySession(AuthContextLocal authContext)static StringencodeURL(String url, AuthContextLocal authContext)static booleanforwardSuccessExists(jakarta.servlet.http.HttpServletRequest req)Returnstrueif the request has theforward=truequery parameter.static AuthContextLocalgetAuthContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SessionID sid, boolean isSessionUpgrade, boolean isBackPost)Returns the authentication context for a request.static AuthContextLocalgetAuthContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SessionID sessionId, boolean isSessionUpgrade, boolean isBackPost, boolean isLogout, boolean isRestAuth)Returns the authentication context for a request.static AuthContextLocalgetAuthContext(jakarta.servlet.http.HttpServletRequest req, String sessionID)static AuthContextLocalgetAuthContext(String orgName)static AuthContextLocalgetAuthContext(String orgName, jakarta.servlet.http.HttpServletRequest req)static AuthContextLocalgetAuthContext(String orgName, String sessionID)static AuthContextLocalgetAuthContext(String orgName, String sessionID, boolean logout)static AuthContextLocalgetAuthContext(String orgName, String sessionID, boolean isLogout, jakarta.servlet.http.HttpServletRequest req)Returns the AuthContext Handle for the Request.static AuthContextLocalgetAuthContext(String orgName, String sessionID, boolean isLogout, jakarta.servlet.http.HttpServletRequest req, String indexType, AuthXMLRequest xmlReq)static AuthContextLocalgetAuthContext(String providedOrgName, String sessionID, boolean isLogout, jakarta.servlet.http.HttpServletRequest req, String indexType, AuthXMLRequest xmlReq, boolean forceAuth)static SetgetAuthModules(int authLevel, String organizationDN, String clientType)Returns a set of authentication modules whose authentication level equals to or greater than the specified authLevel.static Callback[]getCallbacksPerState(AuthContextLocal authContext, String pageState)static intgetCompositeAdviceType(AuthContextLocal authContext)static jakarta.servlet.http.CookiegetCookieString(AuthContextLocal ac, String cookieDomain)Returns the Cookie object created based on the cookie name, Session ID and cookie domain.static StringgetDefaultFileName(jakarta.servlet.http.HttpServletRequest request, String fileName)Returns the resource based on the default values.static StringgetFileName(AuthContextLocal authContext, String fileName)static MapgetGlobalAttributes(String serviceName)ReturnsMapattributesstatic StringgetIndexName(AuthContextLocal authContext)static AuthContext.IndexTypegetIndexType(AuthContextLocal authContext)static booleangetInetDomainStatus(AuthContextLocal authContext)static StringgetLocale(AuthContextLocal authContext)static StringgetLoginFailedURL(AuthContextLocal authContext)static LoginStategetLoginState(AuthContextLocal authContext)static StringgetLoginSuccessURL(AuthContextLocal authContext)static StringgetLoginURL(AuthContextLocal authContext)static jakarta.servlet.http.CookiegetLogoutCookie(AuthContextLocal ac, String cookieDomain)Returns the Logout cookie.static StringgetModuleServiceName(String moduleName)Get the module service name in either iplanet-am-auth formatService(old) or sunAMAuth Service format(new). static InternalSessiongetOldSession(AuthContextLocal authContext)static StringgetOrgConfiguredAuthenticationChain(String orgDN)Returns the authentication service or chain configured for the given organization.static StringgetOrgDN(AuthContextLocal authContext)static StringgetPostProcessURL(jakarta.servlet.http.HttpServletRequest servletRequest, String attrName)static Callback[]getRecdCallback(AuthContextLocal authContext)static StringgetRemoteSecurityEnabled()Returns true if remote Auth security is enabled and false otherwisestatic InternalSessiongetSession(AuthContextLocal authContext)static StringgetSessionProperty(String property, AuthContextLocal oldAuthContext)static StringgetSuccessURL(jakarta.servlet.http.HttpServletRequest request, AuthContextLocal authContext)Returns success URL for this request.static StringgetValidGotoURL(jakarta.servlet.http.HttpServletRequest request, String orgDN)Returns valid goto parameter for this request.static ZeroPageLoginConfiggetZeroPageLoginConfig(String realm)Gets the ZPL configuration for the given realm.static booleanisCookieSet(AuthContextLocal ac)static booleanisCookieSupported(AuthContextLocal ac)static booleanisForwardSuccess(AuthContextLocal authContext, jakarta.servlet.http.HttpServletRequest req)Returns the flag indicating a request "forward" after successful authentication.static booleanisNewRequest(AuthContextLocal ac)static booleanisSessionUpgrade(AuthContextLocal authContext)static booleanlogout(InternalSession intSession, SSOToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)Performs a logout on a given token ensuring the post auth classes are calledstatic booleanlogout(String sessionID, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)Performs a logout on a given token ensuring the post auth classes are calledstatic booleannewSessionArgExists(Map<String,String> decodedRequestData, SessionID sessionId)static MapprocessCompositeAdviceXML(String xmlCompositeAdvice, String orgDN, String clientType)static voidremoveAuthContext(SessionID sid)Removes the AuthContextLocal object in the Session object identified by the SessionID object parameter 'sid'.static voidresetPostProcessURLs(jakarta.servlet.http.HttpServletRequest servletRequest)static booleansessionTimedOut(AuthContextLocal authContext)Returnstrueif the session has timed out or the page has timed out.static voidsetCallbacksPerState(AuthContextLocal authContext, String pageState, Callback[] callbacks)static voidsetCookieSupported(AuthContextLocal ac, boolean flag)static voidsetlbCookie(AuthContextLocal authContext, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)-
Methods inherited from class com.sun.identity.authentication.client.AuthClientUtils
addLogoutCookieToURL, checkForCookies, checkForForcedAuth, checkSessionUpgrade, clearHostUrlCookie, clearlbCookie, clearServerCookie, constructLoginURL, createCookie, createCookie, createCookie, createlbCookie, encodeURL, escapePipe, forceAuthFlagExists, getAuthCookieName, getAuthCookieValue, getCharSet, getClientType, getClientURLFromString, getContentType, getCookieDetect, getCookieDomains, getCookieDomainsForRequest, getCookieName, getCookieString, getCookieSupport, getCookieURL, getCookieURLForSessionUpgrade, getDataFromRealmQualifiedData, getDefaultClientType, getDefaultFileName, getDefaultProperty, getDistAuthCookieName, getDomainNameByRequest, getDomainNameByRequest, getDSAMEVersion, getEnvMap, getErrorMessage, getErrorTemplate, getErrorVal, getErrorVal, getExistingValidSSOToken, getFileName, getFilePath, getFilePath, getFileRoot, getHostName, getIndexName, getIndexType, getlbCookieName, getlbCookieValue, getLogoutCookie, getLogoutCookieString, getOrganizationDN, getOrgFilePath, getOrgParam, getOrigRedirectURL, getQueryOrgName, getQueryStrFromParameters, getRealmFromPolicyAdvice, getResourceLocation, getResourceURL, getRootSuffix, getServiceURI, getSessionIDFromRequest, getValidFQDNResource, isClientDetectionEnabled, isContain, isCookieSet, isCookieSupported, isDistAuthServerTrusted, isGenericHTMLClient, isLocalServer, isLocalServer, isServerMemberOfLocalSite, isSessionUpgradeOrForceAuth, isSetCookie, isTimedOut, isUrlRewrite, isValidFQDNRequest, isVersionHeaderEnabled, isZeroPageLoginAllowed, newSessionArgExists, parseRequestParameters, persistAMCookie, printCookies, printHash, sendAuthRequestToOrigServer, setCookieVal, setHostUrlCookie, setlbCookie, setRedirectBackServerCookie, setServerCookie, unescapePipe, URLencodedSunQueryParamsString
-
-
-
-
Field Detail
-
BUNDLE_NAME
public static final String BUNDLE_NAME
- See Also:
- Constant Field Values
-
REALM
public static final int REALM
Authentication type for Realm based authentication after Composite Advices- See Also:
- Constant Field Values
-
SERVICE
public static final int SERVICE
Authentication type for Service based authentication after Composite Advices- See Also:
- Constant Field Values
-
MODULE
public static final int MODULE
Authentication type for Module based authentication after Composite Advices- See Also:
- Constant Field Values
-
FORCE_AUTH
public static final String FORCE_AUTH
Name of parameter used to indicate authn process MUST be run.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSession
public static InternalSession getSession(AuthContextLocal authContext)
-
getAuthContext
public static AuthContextLocal getAuthContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SessionID sid, boolean isSessionUpgrade, boolean isBackPost) throws AuthException
Returns the authentication context for a request.- Parameters:
request- HTTP Servlet Request.response- HTTP Servlet Response.sid- SessionID for this request.isSessionUpgrade-trueif session upgrade.isBackPost-trueif back posting.- Returns:
- authentication context.
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SessionID sessionId, boolean isSessionUpgrade, boolean isBackPost, boolean isLogout, boolean isRestAuth) throws AuthException
Returns the authentication context for a request.- Parameters:
request- HTTP Servlet Request.response- HTTP Servlet Response.sessionId- SessionID for this request.isSessionUpgrade-trueif session upgrade.isBackPost-trueif back posting.isLogout-truefor logout.isRestAuth-trueif the request is coming from JSON REST/XUI.- Returns:
- authentication context.
- Throws:
AuthException
-
getLoginState
public static LoginState getLoginState(AuthContextLocal authContext)
-
getCookieString
public static jakarta.servlet.http.Cookie getCookieString(AuthContextLocal ac, String cookieDomain)
Returns the Cookie object created based on the cookie name, Session ID and cookie domain. If Session is in invalid State then cookie is created with authentication cookie name , if Active/Inactive Session state AM Cookie Name will be used to create cookie.- Parameters:
ac- the AuthContext objectcookieDomain- the cookie domain for creating cookie- Returns:
- Cookie object.
-
getLogoutCookie
public static jakarta.servlet.http.Cookie getLogoutCookie(AuthContextLocal ac, String cookieDomain)
Returns the Logout cookie.- Parameters:
ac- the AuthContextLocal objectcookieDomain- the cookieDomain- Returns:
- Logout cookie .
-
isNewRequest
public static boolean isNewRequest(AuthContextLocal ac)
-
getLoginSuccessURL
public static String getLoginSuccessURL(AuthContextLocal authContext)
-
getLoginFailedURL
public static String getLoginFailedURL(AuthContextLocal authContext)
-
getFileName
public static String getFileName(AuthContextLocal authContext, String fileName)
-
getInetDomainStatus
public static boolean getInetDomainStatus(AuthContextLocal authContext)
-
newSessionArgExists
public static boolean newSessionArgExists(Map<String,String> decodedRequestData, SessionID sessionId)
-
encodeURL
public static String encodeURL(String url, AuthContextLocal authContext)
-
getLocale
public static String getLocale(AuthContextLocal authContext)
-
destroySession
public static void destroySession(AuthContextLocal authContext)
-
sessionTimedOut
public static boolean sessionTimedOut(AuthContextLocal authContext)
Returnstrueif the session has timed out or the page has timed out.- Parameters:
authContext- the authentication context object for the request.- Returns:
trueif timed out else false.
-
createlbCookie
public static jakarta.servlet.http.Cookie createlbCookie(AuthContextLocal authContext, String cookieDomain) throws AuthException
- Throws:
AuthException
-
setlbCookie
public static void setlbCookie(AuthContextLocal authContext, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws AuthException
- Throws:
AuthException
-
getCompositeAdviceType
public static int getCompositeAdviceType(AuthContextLocal authContext)
-
getIndexType
public static AuthContext.IndexType getIndexType(AuthContextLocal authContext)
-
getIndexName
public static String getIndexName(AuthContextLocal authContext)
-
getRecdCallback
public static Callback[] getRecdCallback(AuthContextLocal authContext)
-
getDefaultFileName
public static String getDefaultFileName(jakarta.servlet.http.HttpServletRequest request, String fileName)
Returns the resource based on the default values.- Parameters:
request- HTTP Servlet Request.fileName- name of the file- Returns:
- Path to the resource.
-
getOrgDN
public static String getOrgDN(AuthContextLocal authContext)
-
getAuthContext
public static AuthContextLocal getAuthContext(String orgName) throws AuthException
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(String orgName, String sessionID) throws AuthException
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(String orgName, jakarta.servlet.http.HttpServletRequest req) throws AuthException
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(String orgName, String sessionID, boolean logout) throws AuthException
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(jakarta.servlet.http.HttpServletRequest req, String sessionID) throws AuthException
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(String orgName, String sessionID, boolean isLogout, jakarta.servlet.http.HttpServletRequest req) throws AuthException
Returns the AuthContext Handle for the Request.- Parameters:
orgName- OrganizationName in requestsessionID- Session ID for this requestisLogout- a boolean which is true if it is a Logout requestreq- HttpServletRequest- Returns:
- AuthContextLocal object
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(String orgName, String sessionID, boolean isLogout, jakarta.servlet.http.HttpServletRequest req, String indexType, AuthXMLRequest xmlReq) throws AuthException
- Throws:
AuthException
-
getAuthContext
public static AuthContextLocal getAuthContext(String providedOrgName, String sessionID, boolean isLogout, jakarta.servlet.http.HttpServletRequest req, String indexType, AuthXMLRequest xmlReq, boolean forceAuth) throws AuthException
- Throws:
AuthException
-
getAuthModules
public static Set getAuthModules(int authLevel, String organizationDN, String clientType)
Returns a set of authentication modules whose authentication level equals to or greater than the specified authLevel. If no such module exists, an empty set will be returned.- Parameters:
authLevel- authentication level.organizationDN- DN for the organization.clientType- Client type, e.g. "genericHTML".- Returns:
- Set of authentication modules whose authentication level equals to or greater that the specified authentication level.
-
getOldSession
public static InternalSession getOldSession(AuthContextLocal authContext)
-
getSessionProperty
public static String getSessionProperty(String property, AuthContextLocal oldAuthContext)
-
isSessionUpgrade
public static boolean isSessionUpgrade(AuthContextLocal authContext)
-
setCookieSupported
public static void setCookieSupported(AuthContextLocal ac, boolean flag)
-
isCookieSupported
public static boolean isCookieSupported(AuthContextLocal ac)
-
isCookieSet
public static boolean isCookieSet(AuthContextLocal ac)
-
checkForCookies
public static boolean checkForCookies(jakarta.servlet.http.HttpServletRequest req, AuthContextLocal ac)Returns true if cookies found in the request.- Parameters:
req- HTTP Servlet Request.ac- authentication context.- Returns:
trueif cookies found in request.
-
getLoginURL
public static String getLoginURL(AuthContextLocal authContext)
-
getCallbacksPerState
public static Callback[] getCallbacksPerState(AuthContextLocal authContext, String pageState)
-
setCallbacksPerState
public static void setCallbacksPerState(AuthContextLocal authContext, String pageState, Callback[] callbacks)
-
getModuleServiceName
public static String getModuleServiceName(String moduleName)
Get the module service name in either iplanet-am-auth formatService(old) or sunAMAuth Service format(new).
-
getSuccessURL
public static String getSuccessURL(jakarta.servlet.http.HttpServletRequest request, AuthContextLocal authContext)
Returns success URL for this request. Ifgotoparameter is in the current request then returns thegotoparameter else returns the success URL set in the valid session.- Parameters:
request- HTTP Servlet Request.authContext- authentication context for this request.- Returns:
- success URL.
-
processCompositeAdviceXML
public static Map processCompositeAdviceXML(String xmlCompositeAdvice, String orgDN, String clientType)
-
removeAuthContext
public static void removeAuthContext(SessionID sid)
Removes the AuthContextLocal object in the Session object identified by the SessionID object parameter 'sid'.
-
getOrgConfiguredAuthenticationChain
public static String getOrgConfiguredAuthenticationChain(String orgDN)
Returns the authentication service or chain configured for the given organization.- Parameters:
orgDN- organization DN.- Returns:
- the authentication service or chain configured for the given organization.
-
getRemoteSecurityEnabled
public static String getRemoteSecurityEnabled() throws AuthException
Returns true if remote Auth security is enabled and false otherwise- Returns:
- the value of sunRemoteAuthSecurityEnabled attribute
- Throws:
AuthException
-
isForwardSuccess
public static boolean isForwardSuccess(AuthContextLocal authContext, jakarta.servlet.http.HttpServletRequest req)
Returns the flag indicating a request "forward" after successful authentication.- Parameters:
authContext- AuthContextLocal objectreq- HttpServletRequest object- Returns:
- the boolean flag.
-
forwardSuccessExists
public static boolean forwardSuccessExists(jakarta.servlet.http.HttpServletRequest req)
Returnstrueif the request has theforward=truequery parameter.- Parameters:
req- HttpServletRequest object- Returns:
trueif this parameter is present.
-
getGlobalAttributes
public static Map getGlobalAttributes(String serviceName)
ReturnsMapattributes- Parameters:
serviceName- Service Name- Returns:
Mapof global attributes.
-
clearAllCookies
public static void clearAllCookies(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
clearAllCookiesByDomain
public static void clearAllCookiesByDomain(SessionID sid, String cookieDomain, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
getPostProcessURL
public static String getPostProcessURL(jakarta.servlet.http.HttpServletRequest servletRequest, String attrName)
-
resetPostProcessURLs
public static void resetPostProcessURLs(jakarta.servlet.http.HttpServletRequest servletRequest)
-
getValidGotoURL
public static String getValidGotoURL(jakarta.servlet.http.HttpServletRequest request, String orgDN)
Returns valid goto parameter for this request. Validate goto parameter set in the current request, then returns it if valid.- Parameters:
request- The HttpServletRequest.orgDN- Organization DN.- Returns:
- The validated goto URL.
-
logout
public static boolean logout(String sessionID, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws SSOException
Performs a logout on a given token ensuring the post auth classes are called- Parameters:
sessionID- The token id to logoutrequest- The HTTP requestresponse- The HTTP response- Returns:
- true if the token was still valid before logout was called
- Throws:
SSOException- If token is null or other SSO exceptions
-
logout
public static boolean logout(InternalSession intSession, SSOToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws SSOException
Performs a logout on a given token ensuring the post auth classes are called- Parameters:
intSession- TheInternalSessionto logouttoken- TheSSOTokento logoutrequest- The HTTP requestresponse- The HTTP response- Returns:
- true if the token was still valid before logout was called
- Throws:
SSOException- If token is null or other SSO exceptions
-
getZeroPageLoginConfig
public static ZeroPageLoginConfig getZeroPageLoginConfig(String realm) throws SSOException, SMSException
Gets the ZPL configuration for the given realm.- Parameters:
realm- the realm to get the ZPL configuration for. Not null.- Returns:
- the ZPL configuration object. Never null.
- Throws:
SSOException- if there is a problem authenticating the configuration lookup.SMSException- if there is a problem fetching the configuration data.
-
-