Package org.mycore.mcr.acl.accesskey
Class MCRAccessKeyUtils
java.lang.Object
org.mycore.mcr.acl.accesskey.MCRAccessKeyUtils
Methods for setting and removing
MCRAccessKey
for users.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAccessKeySecret
(MCRSession session, MCRObjectID objectId, String value) static void
addAccessKeySecret
(MCRUser user, MCRObjectID objectId, String value) Adds the value of aMCRAccessKey
as user attribute to aMCRUser
for aMCRObjectID
including derivates.static void
addAccessKeySecretForObject
(MCRSession session, MCRObjectID objectId, String value) static void
addAccessKeySecretForObject
(MCRUser user, MCRObjectID objectId, String value) static void
addAccessKeySecretToCurrentSession
(MCRObjectID objectId, String value) static void
addAccessKeySecretToCurrentUser
(MCRObjectID objectId, String value) static void
Cleans all access key secret attributes of users if the corresponding key does not exist.static String
getAccessKeySecret
(MCRSession session, MCRObjectID objectId) Fetches access key value from session attribute for aMCRObjectID
.static String
getAccessKeySecret
(MCRUserInformation userInformation, MCRObjectID objectId) Fetches access key value from user attribute for aMCRObjectID
.static String
Fetches access key value from session attribute for aMCRObjectID
.static String
getAccessKeySecretFromCurrentUser
(MCRObjectID objectId) Fetches access key value from user attribute for aMCRObjectID
.static MCRAccessKey
getLinkedAccessKey
(MCRSession session, MCRObjectID objectId) Retrieves linked access key if exists from sessionstatic MCRAccessKey
getLinkedAccessKey
(MCRUserInformation userInformation, MCRObjectID objectId) Retrieves linked access key if exists from userstatic MCRAccessKey
Retrieves linked access key if exists from current sessionstatic MCRAccessKey
getLinkedAccessKeyFromCurrentUser
(MCRObjectID objectId) Retrieves linked access key if exists from current userstatic boolean
static boolean
static boolean
isAccessKeyForSessionAllowed
(String permission) static void
removeAccessKeySecret
(MCRSession session, MCRObjectID objectId) Deletes the access key value attribute from givenMCRSession
forMCRObjectID
.static void
removeAccessKeySecret
(MCRUser user, MCRObjectID objectId) Deletes the access key value user attribute from givenMCRUser
forMCRObjectID
.static void
Deletes access key value attribute from currentMCRSession
for aMCRObjectID
.static void
Deletes access key value user attribute from currentMCRUser
for aMCRObjectID
.
-
Field Details
-
ACCESS_KEY_PREFIX
Prefix for user attribute name for value- See Also:
-
-
Constructor Details
-
MCRAccessKeyUtils
public MCRAccessKeyUtils()
-
-
Method Details
-
addAccessKeySecretForObject
public static void addAccessKeySecretForObject(MCRSession session, MCRObjectID objectId, String value) throws MCRException - Parameters:
session
- theMCRSession
objectId
- theMCRObjectID
value
- the value of aMCRAccessKey
- Throws:
MCRException
- if there is no matchingMCRAccessKey
with the same value or not allowed.
-
addAccessKeySecret
public static void addAccessKeySecret(MCRSession session, MCRObjectID objectId, String value) throws MCRException - Parameters:
session
- theMCRSession
objectId
- theMCRObjectID
value
- the value of aMCRAccessKey
- Throws:
MCRException
- if there is no matchingMCRAccessKey
with the same value or not allowed.
-
addAccessKeySecretForObject
public static void addAccessKeySecretForObject(MCRUser user, MCRObjectID objectId, String value) throws MCRException - Parameters:
user
- theMCRUser
the value should assignedobjectId
- theMCRObjectID
value
- the value of aMCRAccessKey
- Throws:
MCRException
- if there is no matchingMCRAccessKey
with the same value.
-
addAccessKeySecret
public static void addAccessKeySecret(MCRUser user, MCRObjectID objectId, String value) throws MCRException Adds the value of aMCRAccessKey
as user attribute to aMCRUser
for aMCRObjectID
including derivates.- Parameters:
user
- theMCRUser
the value should assignedobjectId
- theMCRObjectID
value
- the value of aMCRAccessKey
- Throws:
MCRException
- if there is no matchingMCRAccessKey
with the same value.
-
addAccessKeySecretToCurrentSession
public static void addAccessKeySecretToCurrentSession(MCRObjectID objectId, String value) throws MCRException - Parameters:
objectId
- theMCRObjectID
value
- the value of aMCRAccessKey
- Throws:
MCRException
- if there is no matchingMCRAccessKey
with the same value.
-
addAccessKeySecretToCurrentUser
public static void addAccessKeySecretToCurrentUser(MCRObjectID objectId, String value) throws MCRException - Parameters:
objectId
- theMCRObjectID
value
- the value of aMCRAccessKey
- Throws:
MCRException
- if there is no matchingMCRAccessKey
with the same value.
-
cleanUpUserAttributes
public static void cleanUpUserAttributes()Cleans all access key secret attributes of users if the corresponding key does not exist. -
getAccessKeySecret
Fetches access key value from session attribute for aMCRObjectID
.- Parameters:
session
- theMCRSession
objectId
- theMCRObjectID
- Returns:
- secret or null
-
getAccessKeySecret
Fetches access key value from user attribute for aMCRObjectID
.- Parameters:
userInformation
- theMCRUserInformation
objectId
- theMCRObjectID
- Returns:
- secret or null
-
getAccessKeySecretFromCurrentSession
Fetches access key value from session attribute for aMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
- Returns:
- secret or null
-
getAccessKeySecretFromCurrentUser
Fetches access key value from user attribute for aMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
- Returns:
- secret or null
-
getLinkedAccessKey
Retrieves linked access key if exists from session- Parameters:
session
- theMCRSession
objectId
- of aMCRObjectID
- Returns:
- access key
-
getLinkedAccessKey
public static MCRAccessKey getLinkedAccessKey(MCRUserInformation userInformation, MCRObjectID objectId) Retrieves linked access key if exists from user- Parameters:
userInformation
- theMCRUserInformation
objectId
- of aMCRObjectID
- Returns:
- access key
-
getLinkedAccessKeyFromCurrentSession
Retrieves linked access key if exists from current session- Parameters:
objectId
- of aMCRObjectID
- Returns:
- access key
-
getLinkedAccessKeyFromCurrentUser
Retrieves linked access key if exists from current user- Parameters:
objectId
- of aMCRObjectID
- Returns:
- access key
-
removeAccessKeySecret
Deletes the access key value attribute from givenMCRSession
forMCRObjectID
.- Parameters:
session
- theMCRSession
objectId
- theMCRObjectID
-
removeAccessKeySecret
Deletes the access key value user attribute from givenMCRUser
forMCRObjectID
.- Parameters:
user
- theMCRUser
objectId
- theMCRObjectID
-
removeAccessKeySecretFromCurrentSession
Deletes access key value attribute from currentMCRSession
for aMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
-
removeAccessKeySecretFromCurrentUser
Deletes access key value user attribute from currentMCRUser
for aMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
-
isAccessKeyForSessionAllowed
public static boolean isAccessKeyForSessionAllowed() -
isAccessKeyForSessionAllowed
-
isAccessKeyForObjectTypeAllowed
-
getAllowedSessionPermissionTypes
-