com.maverick.sshd
Interface PublicKeyStore

All Known Implementing Classes:
AuthorizedKeysStoreImpl

public interface PublicKeyStore

This interface allows you to define a custom public key store for the publickey authentication mechanism. The actual key verification is performed by the mechanism itself and your only requirement is to return a value which indicates whether the key has been authorized by the user for public key access.

Author:
Lee David Painter

Method Summary
 void add(SessionChannel session, String algorithm, String comment, byte[] encodedKey)
          Store the supplied key in the key store if possible.
 Iterator getKeys(SessionChannel session)
          Get an iterator of all stored public keys.
 boolean isAuthorizedKey(com.maverick.ssh.components.SshPublicKey key, Connection con, AuthenticationProvider authenticationProvider)
           Check the supplied public key against the users authorized keys.
 void remove(SessionChannel session, String algorithm, byte[] encodedKey)
          Remove the supplied key from the key store if possible.
 

Method Detail

isAuthorizedKey

boolean isAuthorizedKey(com.maverick.ssh.components.SshPublicKey key,
                        Connection con,
                        AuthenticationProvider authenticationProvider)

Check the supplied public key against the users authorized keys. The actual verification of the key is performed by the server, you only need to return a value to indicate whether the key is authorized or not. You can obtain the username, home directory, group or remote socket address from the com.maverick.sshd.platform.AuthenticationProviderTOBEREMOVED instance.

If your authorized key database is kept on the native file system you can obtain and initialize an instance as follows:

 NativeFileSystemProvider nfs = (NativeFileSystemProvider) authenticationProvider.getContext().getFileSystemProvider().newInstance();
 nfs.init(sessionid, null, authenticationProvider.getContext());
 
Don't forget to close any file handles and the file system once you've done accessing files.

Parameters:
key - SshPublicKey
sessionid - byte[]
authenticationProvider - AuthenticationProvider
Returns:
boolean true if the key is an authorized key, otherwise false

add

void add(SessionChannel session,
         String algorithm,
         String comment,
         byte[] encodedKey)
         throws IOException
Store the supplied key in the key store if possible. This is used by the Public Key Subsystem

Parameters:
session - session
algorithm - algorithm
comment - comment
encodedKey - encoded key
Throws:
IOException
UnsupportedOperationException - if this key store is readonly

remove

void remove(SessionChannel session,
            String algorithm,
            byte[] encodedKey)
            throws IOException
Remove the supplied key from the key store if possible. This is used by the Public Key Subsystem

Parameters:
session - session
algorithm - algorithm
comment - comment
encodedKey - encoded key
Throws:
IOException
UnsupportedOperationException - if this key store is readonly

getKeys

Iterator getKeys(SessionChannel session)
Get an iterator of all stored public keys.

Parameters:
session - session
Returns:
iterator of public keys
Throws:
UnsupportedOperationException - if this key store cannot list keys


Copyright © 2012. All Rights Reserved.