|
TrueZIP Driver TZP (ZIP.RAES) 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
K - The type of the keys.@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public interface KeyProvider<K>
A general purpose interface used by client applications to retrieve a
key which is required to create or open a protected resource.
Both the key and the protected resources may be virtually anything:
The minimum requirement for a key is just that it's an Object.
Protected resources are not even explicitly modelled in this interface.
So in order to use it, an instance must be associated with a protected
resource by a third party - this is the job of the KeyManager class.
Because the protected resource is not modelled within this interface,
it is at the discretion of the provider implementation whether its
instances may or may not be shared among protected resources.
If they do, then all associated protected resources share the same key.
For the following examples, it helps if you think of the protected resource being an encrypted file and the key being a password. Of course, this interface also works with certificate based encryption.
Once an instance has been associated to a protected resource, the client application is assumed to use the key for two basic operations:
getCreateKey().
getOpenKey(boolean).
equal,
but is not necessarily the same.
From a client application's perspective, the two basic operations may be executed in no particular order. Following are some typical use cases:
getCreateKey() returns a key which compares
equal to the key returned by getOpenKey(boolean) or returns a completely
different (new) key.
Ideally, a brave provider implementation would allow the user to control this.
In fact, this is the behaviour of the PromptingKeyProvider in
this package and its user interface class(es).
Note that provider implementations must be thread-safe. This allows clients to use the same provider by multiple threads concurrently.
KeyManager| Nested Class Summary | |
|---|---|
static interface |
KeyProvider.Factory<K,P extends KeyProvider<K>>
A factory for key providers. |
| Method Summary | |
|---|---|
K |
getCreateKey()
Returns the key which should be used to create a new protected resource or entirely replace the contents of an already existing protected resource. |
K |
getOpenKey(boolean invalid)
Returns the key which should be used to open an existing protected resource in order to access its contents. |
| Method Detail |
|---|
K getCreateKey()
throws UnknownKeyException
Each call to this method returns an object which compares
equal to the previously returned object,
but is not necessarily the same.
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.
K getOpenKey(boolean invalid)
throws UnknownKeyException
Unless invalid is true, each call to this method returns
an object which compares equal to the previously
returned object,
but is not necessarily the same.
Important: From a client application's perspective, a
KeyProvider is not trustworthy!
Hence, the key returned by this method must not only get authenticated,
but the client application should also throttle the pace for the
return from a subsequent call to this method if the key is invalid
in order to protect the client application from 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.
"Safe" implementations of this interface should enforce this
behaviour in order to protect client applications which do not obeye
these considerations against abuses of the key provider implementation.
invalid - true iff a previous call to this method resulted
in an invalid key.
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.
|
TrueZIP Driver TZP (ZIP.RAES) 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||