K
- the type of the prompting keys.@ThreadSafe public final class PromptingKeyProvider<K extends PromptingKey<K>> extends AbstractKeyProvider<K>
PromptingKey.View
interface.
The view can then use the given PromptingKey.Controller
instance to ask for the
URI of the protected resource and get/set the secret key appropriately.PromptingKeyManager
Modifier and Type | Method and Description |
---|---|
K |
getKeyForReading(boolean invalid)
Returns the key for reading a protected resource.
|
K |
getKeyForWriting()
Returns the key for (over)writing a protected resource.
|
void |
resetCancelledKey()
Resets the state of this key provider
if and only if prompting for the key has been cancelled.
|
void |
resetUnconditionally()
Resets the state of this key provider
unconditionally.
|
void |
setKey(K key)
Sets the key for reading and (over)writing a protected resource.
|
toString
equals, hashCode
public K getKeyForReading(boolean invalid) throws UnknownKeyException
KeyProvider
Important: From a KeyProvider
perspective, a client is
not trustworthy!
Hence, the implementation should throttle the pace for the return from a
subsequent call to this method if the key is invalid in order to protect
against an exhaustive search for the correct key.
As a rule of thumb, at least three seconds should pass between two
consecutive calls to this method by the same thread.
Implementations should return a protective copy of the key in order to protect against subsequent modifications by the client.
invalid
- true
iff a previous call to this method returned
an invalid key.invalid
is true
, subsequent calls to this
method return a key which at least compares
equal
to this key, but is not
necessarily the same.UnknownKeyException
- if the key is unknown for some
reason, e.g. if prompting for the key has been disabled or
cancelled by the user.public K getKeyForWriting() throws UnknownKeyException
KeyProvider
Implementations should return a protective copy of the key in order to protect against subsequent modifications by the client.
equal
to this key,
but is not necessarily the same.UnknownKeyException
- if the key is unknown for some
reason, e.g. if prompting for the key has been disabled
or cancelled by the user.public void resetCancelledKey()
public void resetUnconditionally()
public void setKey(@CheckForNull K key)
KeyProvider.getKeyForReading(boolean)
in order to
update some properties of the key after it has been validated by the
client.
Implementations should make a protective copy of the given key in order to protect against subsequent modifications by the client.
The implementation in the class PromptingKeyProvider
clones the
given nullable key before setting it.
key
- the key.
If this is null
, this key provider is set to a state
as if prompting for the key had been cancelled.Copyright © 2012–2016 Schlichtherle IT Services. All rights reserved.