Package org.mycore.mcr.acl.accesskey
Class MCRAccessKeyManager
java.lang.Object
org.mycore.mcr.acl.accesskey.MCRAccessKeyManager
Methods to manage
MCRAccessKey
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAccessKeys
(MCRObjectID objectId, List<MCRAccessKey> accessKeys) AddsMCRAccessKey
list for givenMCRObjectID
.static void
Deletes allMCRAccessKey
.static void
clearAccessKeys
(MCRObjectID objectId) Deletes the allMCRAccessKey
for givenMCRObjectID
.static void
createAccessKey
(MCRObjectID objectId, MCRAccessKey accessKey) Creates aMCRAccessKey
for givenMCRObjectID
.static MCRAccessKey
getAccessKeyWithSecret
(MCRObjectID objectId, String secret) Return theMCRAccessKey
for givenMCRObjectID
and secret.static String
hashSecret
(String secret, MCRObjectID objectId) Encrypts secret and usesMCRObjectID
as salt.static boolean
isValidSecret
(String secret) Checks the quality of the secret.static boolean
isValidType
(String type) Checks the quality of the permission.static List<MCRAccessKey>
listAccessKeys
(MCRObjectID objectId) Returns all access keys for givenMCRObjectID
.static List<MCRAccessKey>
listAccessKeysWithType
(MCRObjectID objectId, String type) Return the access keys for givenMCRObjectID
and type.static void
removeAccessKey
(MCRObjectID objectId, String secret) RemovesMCRAccessKey
for givenMCRObjectID
and secret.static void
updateAccessKey
(MCRObjectID objectId, String secret, MCRAccessKey updatedAccessKey) UpdatesMCRAccessKey
-
Constructor Details
-
MCRAccessKeyManager
public MCRAccessKeyManager()
-
-
Method Details
-
listAccessKeys
Returns all access keys for givenMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
- Returns:
MCRAccessKey
list
-
isValidType
Checks the quality of the permission.- Parameters:
type
- permission type- Returns:
- true if valid or false
-
isValidSecret
Checks the quality of the secret.- Parameters:
secret
- the secret- Returns:
- true if valid or false
-
hashSecret
Encrypts secret and usesMCRObjectID
as salt.- Parameters:
secret
- the secretobjectId
- theMCRObjectID
- Returns:
- hashed secret
- Throws:
MCRException
- if encryption fails
-
createAccessKey
public static void createAccessKey(MCRObjectID objectId, MCRAccessKey accessKey) throws MCRException Creates aMCRAccessKey
for givenMCRObjectID
. Hashed the secret- Parameters:
objectId
- theMCRObjectID
accessKey
- access key with secret- Throws:
MCRException
- key is not valid
-
addAccessKeys
public static void addAccessKeys(MCRObjectID objectId, List<MCRAccessKey> accessKeys) throws MCRAccessKeyException AddsMCRAccessKey
list for givenMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
accessKeys
- theMCRAccessKey
list- Throws:
MCRAccessKeyException
- key is not valid
-
clearAccessKeys
public static void clearAccessKeys()Deletes allMCRAccessKey
. -
clearAccessKeys
Deletes the allMCRAccessKey
for givenMCRObjectID
.- Parameters:
objectId
- theMCRObjectID
-
removeAccessKey
public static void removeAccessKey(MCRObjectID objectId, String secret) throws MCRAccessKeyNotFoundException RemovesMCRAccessKey
for givenMCRObjectID
and secret.- Parameters:
objectId
- theMCRObjectID
secret
- the secret- Throws:
MCRAccessKeyNotFoundException
-
updateAccessKey
public static void updateAccessKey(MCRObjectID objectId, String secret, MCRAccessKey updatedAccessKey) throws MCRException UpdatesMCRAccessKey
- Parameters:
objectId
- theMCRObjectID
secret
- the access key secretupdatedAccessKey
- access key- Throws:
MCRException
- if update fails
-
getAccessKeyWithSecret
Return theMCRAccessKey
for givenMCRObjectID
and secret.- Parameters:
objectId
- theMCRObjectID
secret
- the hashed secret- Returns:
- the
MCRAccessKey
-
listAccessKeysWithType
Return the access keys for givenMCRObjectID
and type.- Parameters:
objectId
- theMCRObjectID
type
- the type- Returns:
MCRAccessKey
list
-