public class MockCredentialStoreManagedObjectSource extends AbstractManagedObjectSource<None,None> implements ManagedObject, CredentialStore
Provides mocking of a CredentialStore
in a similar way
MockHttpSecuritySource
works.
Using this store allows the application to be built with its appropriate
HttpSecuritySource
authentication scheme. This mocks the backing
CredentialStore
for development and tests environments to avoid user
management. This therefore avoids the need to change the application
behaviour between environments (same HttpSecuritySource
but differing
configured CredentialStore
).
AbstractAsyncManagedObjectSource.DependencyLabeller, AbstractAsyncManagedObjectSource.Labeller, AbstractAsyncManagedObjectSource.MetaDataContext<D extends Enum<D>,F extends Enum<F>>, AbstractAsyncManagedObjectSource.SpecificationContext
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_ALGORITHM
Name of the
Property for the algorithm. |
DEFAULT_ALGORITHM, NO_ALGORITHM
Constructor and Description |
---|
MockCredentialStoreManagedObjectSource() |
Modifier and Type | Method and Description |
---|---|
String |
getAlgorithm()
Obtains the algorithm used to encrypt credentials within this
CredentialStore . |
protected ManagedObject |
getManagedObject()
Synchronously obtains the
ManagedObject . |
Object |
getObject()
Obtains the object being managed.
|
protected void |
loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)
Overridden to load meta-data.
|
protected void |
loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Overridden to load specifications.
|
CredentialEntry |
retrieveCredentialEntry(String userId,
String realm)
Retrieves the
CredentialEntry . |
sourceManagedObject
getMetaData, getSpecification, init, start, stop
public static final String PROPERTY_ALGORITHM
Property
for the algorithm.public MockCredentialStoreManagedObjectSource()
protected void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
AbstractAsyncManagedObjectSource
loadSpecification
in class AbstractAsyncManagedObjectSource<None,None>
context
- Specifications.protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context) throws Exception
AbstractAsyncManagedObjectSource
loadMetaData
in class AbstractAsyncManagedObjectSource<None,None>
context
- Meta-data.Exception
- If fails to load the meta-data.protected ManagedObject getManagedObject() throws Throwable
AbstractManagedObjectSource
ManagedObject
.getManagedObject
in class AbstractManagedObjectSource<None,None>
ManagedObject
.Throwable
- If fails to obtain the ManagedObject
.public Object getObject() throws Throwable
ManagedObject
getObject
in interface ManagedObject
Throwable
- Indicating failed to obtain the object for use.public String getAlgorithm()
CredentialStore
Obtains the algorithm used to encrypt credentials within this
CredentialStore
.
Should the return be null
, blank or CredentialStore.NO_ALGORITHM
then the password is considered to be stored in plain text. This is
however only useful for the BASIC
authentication scheme due
to the nature of the other authentication schemes (such as
DIGEST
).
It is expected that the credentials for DIGEST
will be
stored as the algorithm applied to userId:realm:password
(as
per RFC 2617). This is necessary as the password is never supplied and
therefore for DIGEST
this MUST return an algorithm.
getAlgorithm
in interface CredentialStore
public CredentialEntry retrieveCredentialEntry(String userId, String realm) throws IOException
CredentialStore
CredentialEntry
.retrieveCredentialEntry
in interface CredentialStore
userId
- User identifier.realm
- Realm. May be null
(especially in the case for
Basic
authentication).CredentialEntry
or null
if no
CredentialEntry
exists for parameters.IOException
- If fails to retrieve CredentialEntry
.Copyright © 2005–2016. All rights reserved.