|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PromptingKeyProviderUI
Used by PromptingKeyProvider
s for the actual prompting of the user
for a key (a password for example) which is required to access a protected
resource.
This interface is not depending on any particular user interface techology,
so prompting could be implemented using Swing, the console, a web page
or any other user interface technology.
Implementations of this interface are instantiated and maintained by the
PromptingKeyManager
and are shared between different
PromptingKeyProvider
instances.
Hence, implementations of this interface must be thread safe
and should have no side effects!
Method Summary | |
---|---|
void |
promptCreateKey(PromptingKeyProvider provider)
Prompts the user for the key which may be used to create a new protected resource or entirely replace the contents of an already existing protected resource. |
boolean |
promptInvalidOpenKey(PromptingKeyProvider provider)
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents. |
boolean |
promptUnknownOpenKey(PromptingKeyProvider provider)
Prompts the user for the key which may be used to open an existing protected resource in order to access its contents. |
Method Detail |
---|
void promptCreateKey(PromptingKeyProvider provider)
Upon return, the implementation is expected to update the common key
in provider
.
Upon return, if provider.getKey()
returns null
,
prompting for the key is assumed to have been cancelled by the user.
In this case, the current and each subsequent call to
KeyProvider.getOpenKey()
or KeyProvider.getCreateKey()
by the client results in an UnknownKeyException
and the user
is not prompted anymore until the provider is reset by the
KeyManager
.
Otherwise, the key is used as the common key, a clone of which is
provided to the client upon request.
Hint: If the user cancels the dialog, it is recommended to
leave the provider's key
property simply unmodified.
This causes the old key to be reused and allows the client to
continue its operation as if the user would not have requested to
change the key.
Since TrueZIP 6.4, an implementation may also throw a
RuntimeException
with any kind of UnknownKeyException
as its cause.
This will trigger the calling method in the
PromptingKeyProvider
class to unwrap and pass on the
cause without changing its state.
This may be useful if prompting was interrupted by a call to
Thread.interrupt()
while waiting on the Event Dispatch Thread.
In this case, another try to prompt the user should have the chance to
succeed instead of being cancelled without actually prompting the user
again.
To trigger this behaviour, the implementation should simply throw any
kind of RuntimeException
with a
KeyPromptingInterruptedException
as its cause.
provider
- The default key provider to store the result in.
RuntimeException
- with an UnknownKeyException
as its
cause if the implementation does not want the key provider's
state to be changed.boolean promptUnknownOpenKey(PromptingKeyProvider provider)
Upon return, the implementation is expected to update the common key
in provider
.
Upon return, if provider.getKey()
returns null
,
prompting for the key is assumed to have been cancelled by the user.
In this case, the current and each subsequent call to
KeyProvider.getOpenKey()
or KeyProvider.getCreateKey()
by the client results in an UnknownKeyException
and the user
is not prompted anymore until the provider is reset by the
KeyManager
.
Otherwise, the key is used as the common key, a clone of which is
provided to the client upon request.
Since TrueZIP 6.4, an implementation may also throw a
RuntimeException
with any kind of UnknownKeyException
as its cause.
This will trigger the calling method in the
PromptingKeyProvider
class to unwrap and pass on the
cause without changing its state.
This may be useful if prompting was interrupted by a call to
Thread.interrupt()
while waiting on the Event Dispatch Thread.
In this case, another try to prompt the user should have the chance to
succeed instead of being cancelled without actually prompting the user
again.
To trigger this behaviour, the implementation should simply throw any
kind of RuntimeException
with a
KeyPromptingInterruptedException
as its cause.
provider
- The key provider to store the result in.
true
if the user has requested to change the
provided key.
RuntimeException
- with an UnknownKeyException
as its
cause if the implementation does not want the key provider's
state to be changed.boolean promptInvalidOpenKey(PromptingKeyProvider provider)
promptUnknownOpenKey(de.schlichtherle.key.PromptingKeyProvider)
is invalid.
Upon return, the implementation is expected to update the common key
in provider
.
Upon return, if provider.getKey()
returns null
,
prompting for the key is assumed to have been cancelled by the user.
In this case, the current and each subsequent call to
KeyProvider.getOpenKey()
or KeyProvider.getCreateKey()
by the client results in an UnknownKeyException
and the user
is not prompted anymore until the provider is reset by the
KeyManager
.
Otherwise, the key is used as the common key, a clone of which is
provided to the client upon request.
Since TrueZIP 6.4, an implementation may also throw a
RuntimeException
with any kind of UnknownKeyException
as its cause.
This will trigger the calling method in the
PromptingKeyProvider
class to unwrap and pass on the
cause without changing its state.
This may be useful if prompting was interrupted by a call to
Thread.interrupt()
while waiting on the Event Dispatch Thread.
In this case, another try to prompt the user should have the chance to
succeed instead of being cancelled without actually prompting the user
again.
To trigger this behaviour, the implementation should simply throw any
kind of RuntimeException
with a
KeyPromptingInterruptedException
as its cause.
provider
- The key provider to store the result in.
true
if the user has requested to change the
provided key.
RuntimeException
- with an UnknownKeyException
as its
cause if the implementation does not want the key provider's
state to be changed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |