public class OpenIdConnectRESTHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
OpenIdConnectRESTHelper() |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildLoginRequestURL(URL loginURL,
String clientId,
String state,
String redirectURI) |
protected static String |
getClientIdFromToken(JWTToken token) |
static byte[] |
getUserAvatar(URL avatarURL,
JWTToken token) |
static byte[] |
getUserAvatar(URL avatarURL,
String authorization) |
static boolean |
isAccessDeniedNotAuthorizedError(String jsonString) |
static boolean |
isInvalidBearerTokenError(String jsonString) |
static boolean |
isTokenNotActiveError(String jsonString) |
static boolean |
logout(URL logoutUrl,
JWTToken token)
Performs the logout (SSOut) from all the sessions opened in the OIDC server.
|
static boolean |
logout(URL logoutUrl,
String clientId,
JWTToken token)
Performs the logout from the session related to the provided client id in the OIDC server.
|
static String |
mapToQueryString(Map<String,List<String>> params) |
protected static boolean |
matchesErrorAndDescription(String jsonString,
String expectedError,
String exepectedErrorDescription) |
protected static JWTToken |
performQueryTokenWithPOST(URL tokenURL,
String authorization,
Map<String,List<String>> params) |
protected static HttpURLConnection |
performURLEncodedPOSTSendData(URL url,
Map<String,List<String>> params,
String authorization) |
static JWTToken |
queryClientToken(String clientId,
String clientSecret,
URL tokenURL)
Queries from the OIDC server an OIDC access token, by using provided clientId and client secret.
|
static JWTToken |
queryToken(String clientId,
URL tokenURL,
String code,
String scope,
String redirectURI) |
static JWTToken |
queryUMAToken(URL tokenUrl,
String authorization,
String audience,
List<String> permissions)
Queries from the OIDC server an UMA token, by using provided access token, for the given audience (context),
in URLEncoded form or not, and optionally a list of permissions.
|
static JWTToken |
queryUMAToken(URL tokenUrl,
String clientId,
String clientSecret,
String audience,
List<String> permissions)
Queries from the OIDC server an UMA token, by using provided clientId and client secret for the given audience
(context), in URLEncoded form or not, and optionally a list of permissions.
|
static JWTToken |
refreshToken(URL tokenURL,
JWTToken token)
Refreshes the token from the OIDC server.
|
static JWTToken |
refreshToken(URL tokenURL,
String clientId,
JWTToken token)
Refreshes the token from the OIDC server for a specific client represented by the client id.
|
static JWTToken |
refreshToken(URL tokenURL,
String clientId,
String clientSecret,
JWTToken token)
Refreshes the token from the OIDC server for a specific client represented by the client id.
|
public static String buildLoginRequestURL(URL loginURL, String clientId, String state, String redirectURI) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic static JWTToken queryClientToken(String clientId, String clientSecret, URL tokenURL) throws OpenIdConnectRESTHelperException
clientId - the client idclientSecret - the client secrettokenUrl - the token endpoint URL of the OIDC serverOpenIdConnectRESTHelperException - if an error occurs (also an unauthorized call), inspect the exception for detailspublic static JWTToken queryToken(String clientId, URL tokenURL, String code, String scope, String redirectURI) throws Exception
Exceptionprotected static JWTToken performQueryTokenWithPOST(URL tokenURL, String authorization, Map<String,List<String>> params) throws OpenIdConnectRESTHelperException
OpenIdConnectRESTHelperExceptionprotected static HttpURLConnection performURLEncodedPOSTSendData(URL url, Map<String,List<String>> params, String authorization) throws IOException, ProtocolException, UnsupportedEncodingException
public static JWTToken queryUMAToken(URL tokenUrl, String clientId, String clientSecret, String audience, List<String> permissions) throws OpenIdConnectRESTHelperException
tokenUrl - the token endpoint URL of the OIDC serverclientId - the client idclientSecret - the client secretaudience - the audience (context) where to request the issuing of the ticketpermissions - a list of permissions, can be nullOpenIdConnectRESTHelperException - if an error occurs (also an unauthorized call), inspect the exception for detailspublic static JWTToken queryUMAToken(URL tokenUrl, String authorization, String audience, List<String> permissions) throws OpenIdConnectRESTHelperException
tokenUrl - the token endpoint URL of the OIDC serverauthorization - the auth token (the access token URLEncoded by the "Bearer " string)audience - the audience (context) where to request the issuing of the ticket (URLEncoded)permissions - a list of permissions, can be nullOpenIdConnectRESTHelperException - if an error occurs (also an unauthorized call), inspect the exception for detailspublic static JWTToken refreshToken(URL tokenURL, JWTToken token) throws OpenIdConnectRESTHelperException
tokenUrl - the token endpoint URL of the OIDC servertoken - the token to be refreshedOpenIdConnectRESTHelperException - if an error occurs (also an unauthorized call), inspect the exception for detailspublic static JWTToken refreshToken(URL tokenURL, String clientId, JWTToken token) throws OpenIdConnectRESTHelperException
tokenUrl - the token endpoint URL of the OIDC serverclientId - the client idtoken - the token to be refreshedOpenIdConnectRESTHelperException - if an error occurs (also an unauthorized call), inspect the exception for detailspublic static JWTToken refreshToken(URL tokenURL, String clientId, String clientSecret, JWTToken token) throws OpenIdConnectRESTHelperException
tokenUrl - the token endpoint URL of the OIDC serverclientId - the client idclientSecret - the client secrettoken - the token to be refreshedOpenIdConnectRESTHelperException - if an error occurs (also an unauthorized call), inspect the exception for detailspublic static boolean logout(URL logoutUrl, JWTToken token) throws IOException
logoutUrl - the logut endpoint URL of the OIDC servertoken - the token used to take info fromtrue if the logout is performed correctly, false otherwiseIOException - if an I/O error occurs during the communication with the serverpublic static boolean logout(URL logoutUrl, String clientId, JWTToken token) throws IOException
logoutUrl - the logut endpoint URL of the OIDC serverclientId - the client idtoken - the token used to take info fromtrue if the logout is performed correctly, false otherwiseIOException - if an I/O error occurs during the communication with the serverprotected static boolean matchesErrorAndDescription(String jsonString, String expectedError, String exepectedErrorDescription)
public static boolean isTokenNotActiveError(String jsonString)
public static boolean isInvalidBearerTokenError(String jsonString)
public static boolean isAccessDeniedNotAuthorizedError(String jsonString)
Copyright © 2022. All Rights Reserved.