TrueZIP Driver TZP (ZIP.RAES) 7.0-rc1

de.schlichtherle.truezip.key
Class SafeKeyManager<K extends SafeKey<K>,P extends SafeKeyProvider<K>>

java.lang.Object
  extended by de.schlichtherle.truezip.key.SafeKeyManager<K,P>
All Implemented Interfaces:
KeyManager<K,P>
Direct Known Subclasses:
PromptingKeyManager

@ThreadSafe
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public class SafeKeyManager<K extends SafeKey<K>,P extends SafeKeyProvider<K>>
extends Object
implements KeyManager<K,P>

Uses a map to hold the safe key providers managed by this instance.

Author:
Christian Schlichtherle

Field Summary
private  KeyProvider.Factory<? extends K,? extends P> factory
           
private  Map<URI,P> providers
           
 
Constructor Summary
SafeKeyManager(KeyProvider.Factory<? extends K,? extends P> factory)
          Constructs a new default key manager.
 
Method Summary
(package private)  P findKeyProvider(URI resource)
           
 P getKeyProvider(URI resource)
          Returns the key provider for the given protected resource.
 boolean moveKeyProvider(URI oldResource, URI newResource)
          Moves the key provider from the URI oldResource to newResource.
 boolean removeKeyProvider(URI resource)
          Removes the key provider for the given protected resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

providers

private final Map<URI,P extends SafeKeyProvider<K>> providers

factory

private final KeyProvider.Factory<? extends K extends SafeKey<K>,? extends P extends SafeKeyProvider<K>> factory
Constructor Detail

SafeKeyManager

public SafeKeyManager(KeyProvider.Factory<? extends K,? extends P> factory)
Constructs a new default key manager.

Parameters:
factory - the factory for creating new key providers.
Method Detail

getKeyProvider

public P getKeyProvider(URI resource)
Description copied from interface: KeyManager
Returns the key provider for the given protected resource. If no key provider is mapped, a new key provider is created and returned.

Specified by:
getKeyProvider in interface KeyManager<K extends SafeKey<K>,P extends SafeKeyProvider<K>>
Parameters:
resource - the URI of the protected resource.
Returns:
The key provider mapped for the protected resource.

findKeyProvider

P findKeyProvider(URI resource)

moveKeyProvider

public boolean moveKeyProvider(URI oldResource,
                               URI newResource)
Description copied from interface: KeyManager
Moves the key provider from the URI oldResource to newResource.

Specified by:
moveKeyProvider in interface KeyManager<K extends SafeKey<K>,P extends SafeKeyProvider<K>>
Parameters:
oldResource - the old URI of the protected resource.
newResource - the new URI of the protected resource.
Returns:
whether or not the operation succeeded, i.e. if a key provider was present for the old URI.

removeKeyProvider

public boolean removeKeyProvider(URI resource)
Description copied from interface: KeyManager
Removes the key provider for the given protected resource.

Specified by:
removeKeyProvider in interface KeyManager<K extends SafeKey<K>,P extends SafeKeyProvider<K>>
Parameters:
resource - the URI of the protected resource.
Returns:
whether or not the operation succeeded, i.e. if a key provider was present for the old URI.

TrueZIP Driver TZP (ZIP.RAES) 7.0-rc1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.