public final class AuthorizationService extends Object
| Modifier and Type | Method and Description |
|---|---|
static Authorization |
getAuthorization()
Creates an
Authorization object whenever an authorization check is required. |
static AuthJWTToken |
getJWTToken()
This method gets JWTAuthToken
|
static String |
getUserAttribute(String attributeName)
Returns the value for the specified attribute which is part of JWT.
|
static String |
getUserId()
Returns the ID of this current user.
|
static Object |
getUserInfo()
Gets the USERInfo object for the current request
|
static String |
getUserName()
Returns the name of this current user.
|
static String |
getWhereCondition()
Gets the condition specified in the service model for granting entity-level access.
|
static boolean |
hasEntityAccess(String entityName,
String operation)
Checks if the current user has rights to perform
the specified operation on an entity.
|
static boolean |
hasExpandedEntityAccess(String entityName,
String operation)
Checks if the current user has rights to perform
the specified operation on an expanded entity.
|
static boolean |
hasUserRole(String roleName)
Checks if the current user has the given role associated.
|
static boolean |
isAuthenticatedUser(String serviceName)
Checks if the current user is authenticated to access the service.
|
static boolean |
isRegisteredUser(String serviceName)
Checks if the current user is registered to access the service.
|
static void |
purgeCurrentAuthorization()
Removes the Authorization data for current request.
|
static void |
setJWTToken(String base64EncodedJWTStr)
Sets the JWT Token using Base64 Encoded string for current request.
|
static void |
setJWTToken(String base64EncodedJWTStr,
com.google.gson.JsonObject jwtJson)
Sets the JWT Token using Base64 Encoded string and its converted JsonNode for current request.
|
static void |
setWhereCondition(String whereCondition) |
public static Authorization getAuthorization()
Authorization object whenever an authorization check is required. Once created, this object is
available till the request is processed.Authorization objectpublic static boolean isAuthenticatedUser(String serviceName)
serviceName - Name of the service for which the authentication check is performedtrue if there is no restriction on the service or if the user is authenticated to access the service
, false otherwisepublic static boolean isRegisteredUser(String serviceName)
serviceName - Name of the service for which the authentication check is performedtrue if there is no restriction on the service or if the user is authenticated to access the service
, false otherwisepublic static boolean hasEntityAccess(String entityName, String operation)
entityName - Name of the entity being accessedoperation - String representing the operation. Allowed values are READ or WRITE.true if the user is granted rights to perform the specified operation on the entity
, false otherwisepublic static boolean hasExpandedEntityAccess(String entityName, String operation)
entityName - Name of the entity being accessedoperation - String representing the operation. Allowed values are READ or WRITE.true if the user is granted rights to perform the specified operation on the entity
, false otherwisepublic static String getWhereCondition()
String containing the resolved where conditionpublic static void setWhereCondition(String whereCondition)
public static String getUserName()
String containing the current principal's user name.public static String getUserId()
String containing the current principal's user id.public static boolean hasUserRole(String roleName)
roleName - the role nametrue if the user has the specified role, false otherwisepublic static String getUserAttribute(String attributeName)
attributeName - the attribute name same as in JWT token.String if user has the given value for given attribute otherwise nullpublic static AuthJWTToken getJWTToken()
public static void setJWTToken(String base64EncodedJWTStr)
base64EncodedJWTStr - public static void setJWTToken(String base64EncodedJWTStr, com.google.gson.JsonObject jwtJson)
base64EncodedJWTStr - public static Object getUserInfo()
public static void purgeCurrentAuthorization()
Copyright © 2020 SAP. All Rights Reserved.