K - The type of the keys.@ThreadSafe public final class PromptingKeyProvider<K extends SafeKey<K>> extends SafeKeyProvider<K>
PromptingKeyProvider.View interface which
is injected to this instance by a PromptingKeyManager.
The view may then display the resource URI by calling getResource()
on this instance (which is also injected by a
PromptingKeyManager) and finally set the key by using the given
PromptingKeyProvider.Controller.PromptingKeyManager| Modifier and Type | Class and Description |
|---|---|
static class |
PromptingKeyProvider.Controller<K extends SafeKey<K>>
Proxies access to the key for
PromptingKeyProvider.View implementations. |
static class |
PromptingKeyProvider.Factory<K extends SafeKey<K>>
A factory for
PromptingKeyProviders. |
private static class |
PromptingKeyProvider.ReadController<K extends SafeKey<K>> |
(package private) static class |
PromptingKeyProvider.State
Implements the behavior strategy of its enclosing class.
|
static interface |
PromptingKeyProvider.View<K extends SafeKey<K>>
Used for the actual prompting of the user for a key (a password for
example) which is required to access a protected resource.
|
private static class |
PromptingKeyProvider.WriteController<K extends SafeKey<K>> |
| Modifier and Type | Field and Description |
|---|---|
private boolean |
changeRequested |
private K |
key |
private URI |
resource
The resource identifier for the protected resource.
|
private PromptingKeyProvider.State |
state |
private PromptingKeyProvider.View<K> |
view
The view instance which is used to prompt the user for a key.
|
MIN_KEY_RETRY_DELAY| Constructor and Description |
|---|
PromptingKeyProvider() |
| Modifier and Type | Method and Description |
|---|---|
private K |
getKey() |
protected K |
getReadKeyImpl(boolean invalid)
Returns the key for reading the contents of an existing protected
resource.
|
URI |
getResource()
Returns the unique resource identifier (resource ID) of the protected
resource for which this key provider is used.
|
private PromptingKeyProvider.State |
getState() |
(package private) PromptingKeyProvider.View<K> |
getView() |
protected K |
getWriteKeyImpl()
Returns the key for (over)writing the contents of a new or existing
protected resource.
|
private boolean |
isChangeRequested()
Returns whether or not the user shall get prompted for a new key upon
the next call to
SafeKeyProvider.getWriteKey(), provided that the key
has been set before. |
private void |
reset() |
void |
resetCancelledKey()
Resets the state of this key provider, its current key and the value of
its
changeRequested property
if and only if prompting for a key has been cancelled. |
void |
resetUnconditionally()
Resets the state of this key provider, its current key and the value of
its
changeRequested property
unconditionally. |
private void |
setChangeRequested(boolean changeRequested) |
void |
setKey(K newKey)
Sets the key programmatically.
|
(package private) void |
setResource(URI resource)
Returns the unique resource identifier (resource ID) of the protected
resource for which this key provider is used.
|
private void |
setState(PromptingKeyProvider.State state) |
(package private) void |
setView(PromptingKeyProvider.View<K> view) |
clone, getReadKey, getWriteKey, reset@CheckForNull private volatile URI resource
@CheckForNull private volatile PromptingKeyProvider.View<K extends SafeKey<K>> view
@NonNull private volatile PromptingKeyProvider.State state
private volatile boolean changeRequested
public URI getResource()
null.void setResource(URI resource)
null.final PromptingKeyProvider.View<K> getView()
final void setView(PromptingKeyProvider.View<K> view)
@NonNull private PromptingKeyProvider.State getState()
private void setState(@NonNull
PromptingKeyProvider.State state)
protected final K getWriteKeyImpl() throws UnknownKeyException
SafeKeyProviderSubsequent calls to this method may return the same object.
getWriteKeyImpl in class SafeKeyProvider<K extends SafeKey<K>>UnknownKeyException - if the required key is unknown for some
reason, e.g. if prompting for the key has been disabled or
cancelled by the user.SafeKeyProvider.getWriteKey()protected final K getReadKeyImpl(boolean invalid) throws UnknownKeyException
SafeKeyProviderSubsequent calls to this method may return the same object.
getReadKeyImpl in class SafeKeyProvider<K extends SafeKey<K>>UnknownKeyException - If the required key is unknown.
At the subclasses discretion, this may mean that prompting for
the key has been disabled or cancelled by the user.KeyProvider.getWriteKey()@CheckForNull private K getKey()
public void setKey(@CheckForNull
K newKey)
KeyProvidernewKey - the key.
If this is null, this key provider is set to a state
as if prompting for the key had been disabled or cancelled.private boolean isChangeRequested()
SafeKeyProvider.getWriteKey(), provided that the key
has been set before.SafeKeyProvider.getWriteKey(), provided that the key
has been set before.private void setChangeRequested(boolean changeRequested)
public void resetCancelledKey()
changeRequested property
if and only if prompting for a key has been cancelled.public void resetUnconditionally()
changeRequested property
unconditionally.private void reset()
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.