Secure iNet Factory

com.jscape.inet.ssh.util
Class KeyPairAssembler

java.lang.Object
  extended by com.jscape.inet.ssh.util.KeyPairAssembler

public class KeyPairAssembler
extends java.lang.Object

Key pair reader. Provides reading services for several key formats.

All methods throw NullPointerException if null-references were passed in arguments.

Author:
Alex Usun

Constructor Summary
KeyPairAssembler()
          Creates a new assembler instance.
 
Method Summary
 void addFormat(KeyPairFormat format)
          Adds a new format to the reader.
 boolean containsFormat(KeyPairFormat format)
          Check if format is already added.
 void removeFormat(KeyPairFormat format)
          Removes format from the reader.
 java.security.KeyPair restoreKeyPair(byte[] data, java.lang.String passphrase)
          Restores key pair from the specified byte array.
 java.security.KeyPair restoreKeyPair(java.io.File file, java.lang.String passphrase)
          Reads key pair from the specified file.
 java.security.KeyPair restoreKeyPair(java.io.InputStream in, java.lang.String passphrase)
          Reads key pair from the specified input stream.
 java.security.KeyPair restoreKeyPair(java.lang.String key, java.lang.String passphrase)
          Reads key pair from the specified key string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyPairAssembler

public KeyPairAssembler()
Creates a new assembler instance.

Method Detail

containsFormat

public boolean containsFormat(KeyPairFormat format)
Check if format is already added.

Parameters:
format - target format
Returns:
true if format is already added; false otherwise

addFormat

public void addFormat(KeyPairFormat format)
Adds a new format to the reader.

Parameters:
format - target format
Throws:
java.lang.IllegalArgumentException - if format is already added

removeFormat

public void removeFormat(KeyPairFormat format)
Removes format from the reader.

Parameters:
format - target format

restoreKeyPair

public java.security.KeyPair restoreKeyPair(byte[] data,
                                            java.lang.String passphrase)
                                     throws FormatException
Restores key pair from the specified byte array.

Parameters:
data - key pair data
passphrase - passphrase
Returns:
restored key pair
Throws:
FormatException - if key pair cannot be restored

restoreKeyPair

public java.security.KeyPair restoreKeyPair(java.io.InputStream in,
                                            java.lang.String passphrase)
                                     throws FormatException,
                                            java.io.IOException
Reads key pair from the specified input stream. Assumes, that input stream contains only one key pair.

Parameters:
in - input stream
passphrase - passphrase
Returns:
readed key pair
Throws:
FormatException - if key pair cannot be restored
java.io.IOException - if I/O error occurs

restoreKeyPair

public java.security.KeyPair restoreKeyPair(java.io.File file,
                                            java.lang.String passphrase)
                                     throws FormatException,
                                            java.io.IOException
Reads key pair from the specified file.

Parameters:
file - key pair file
passphrase - passphrase
Returns:
readed key pair
Throws:
FormatException - if key pair cannot be restored
java.io.IOException - if I/O error occurs

restoreKeyPair

public java.security.KeyPair restoreKeyPair(java.lang.String key,
                                            java.lang.String passphrase)
                                     throws FormatException
Reads key pair from the specified key string

Parameters:
key - the private key
passphrase - the private key password
Returns:
key pair
Throws:
FormatException - if key pair cannot be restored
java.io.IOException - if I/O error occurs

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved