Class JpaKeyManager
- java.lang.Object
-
- org.apache.archiva.redback.keys.AbstractKeyManager
-
- org.apache.archiva.redback.keys.jpa.JpaKeyManager
-
- All Implemented Interfaces:
KeyManager
@Service("keyManager#jpa") public class JpaKeyManager extends AbstractKeyManager
Key Manager Implementation for JPA. Uses an injected Entity Manager.- Author:
- Martin Stockhammer
-
-
Field Summary
-
Fields inherited from class org.apache.archiva.redback.keys.AbstractKeyManager
log
-
-
Constructor Summary
Constructors Constructor Description JpaKeyManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthenticationKey
addKey(AuthenticationKey key)
protected void
assertNotExpired(AuthenticationKey authkey)
Tests the key to see if it is expired or not.AuthenticationKey
createKey(String principal, String purpose, int expirationMinutes)
Create a key (and save it to the store) for the specified principal.void
deleteKey(String key)
Delete a key from the underlying store.void
deleteKey(AuthenticationKey key)
Delete a key from the underlying store.void
eraseDatabase()
AuthenticationKey
findKey(String key)
Attempt to find a specific key in the store.List<AuthenticationKey>
getAllKeys()
String
getId()
String identifying the key manager implementation.void
setEntityManager(javax.persistence.EntityManager em)
-
Methods inherited from class org.apache.archiva.redback.keys.AbstractKeyManager
generateUUID, getNowGMT, isRandomMode, removeExpiredKeys, setRandomMode
-
-
-
-
Constructor Detail
-
JpaKeyManager
public JpaKeyManager()
-
-
Method Detail
-
setEntityManager
public void setEntityManager(javax.persistence.EntityManager em)
-
getId
public String getId()
Description copied from interface:KeyManager
String identifying the key manager implementation.- Returns:
- the key manager implementation id.
-
createKey
public AuthenticationKey createKey(String principal, String purpose, int expirationMinutes) throws KeyManagerException
Description copied from interface:KeyManager
Create a key (and save it to the store) for the specified principal.- Parameters:
principal
- the principal to generate the key for.purpose
- the purpose of the key. (Example: "selfservice password reset", "new user validation", "remember me") This is a purely informational field .expirationMinutes
- the amount in minutes until this key expires. (-1 means no expiration)- Returns:
- the key created
- Throws:
KeyManagerException
- if there is a fundamental problem with the KeyManager implementation.
-
addKey
public AuthenticationKey addKey(AuthenticationKey key)
-
eraseDatabase
public void eraseDatabase()
-
findKey
public AuthenticationKey findKey(String key) throws KeyNotFoundException, KeyManagerException
Description copied from interface:KeyManager
Attempt to find a specific key in the store. NOTE: Implementations of this interface should never return an expired key.- Parameters:
key
- the key to find.- Returns:
- the actual key found.
- Throws:
KeyNotFoundException
- when the requested, unexpired, key cannot be found.KeyManagerException
- when there is a fundamental problem with the KeyManager implementation.
-
assertNotExpired
protected void assertNotExpired(AuthenticationKey authkey) throws KeyManagerException
Description copied from class:AbstractKeyManager
Tests the key to see if it is expired or not. If the key is expired, a call toKeyManager.deleteKey(AuthenticationKey)
is issued, and aKeyNotFoundException
is thrown.- Overrides:
assertNotExpired
in classAbstractKeyManager
- Parameters:
authkey
- the key to test.- Throws:
KeyNotFoundException
- if the key is expired.KeyManagerException
- if there was a problem removing the key.
-
deleteKey
public void deleteKey(AuthenticationKey key) throws KeyManagerException
Description copied from interface:KeyManager
Delete a key from the underlying store.- Parameters:
key
- the key to delete.- Throws:
KeyManagerException
-
deleteKey
public void deleteKey(String key) throws KeyManagerException
Description copied from interface:KeyManager
Delete a key from the underlying store.- Parameters:
key
- the key to delete.- Throws:
KeyManagerException
-
getAllKeys
public List<AuthenticationKey> getAllKeys()
-
-