org.opcfoundation.ua.transport.security
Class KeyPair

java.lang.Object
  extended by org.opcfoundation.ua.transport.security.KeyPair

public final class KeyPair
extends Object

Valid and encodeable certificate, including signed public key and private key This class aggregates private and public keys. TODO Use KeyPair Instead?

Author:
Toni Kalajainen (toni.kalajainen@iki.fi), Mikko Salonen

Field Summary
 Cert certificate
           
 PrivKey privateKey
           
 
Constructor Summary
KeyPair(Cert certificate, PrivKey privateKey)
          Constructor for KeyPair.
 
Method Summary
 Cert getCertificate()
          Getter for the field certificate.
 PrivKey getPrivateKey()
          Getter for the field privateKey.
static KeyPair load(File certificateFile, File privateKeyFile, String privateKeyPassword)
          Load Certificate and Private key pair from X.509 and keystore file
static KeyPair load(URL certificateFile, URL privateKeyFile, String privateKeyPassword)
          Load Certificate and Private key pair from X.509 and keystore file
 void save(File certificateFile, File privateKeyFile)
          save.
 void save(File certificateFile, File privateKeyFile, String privateKeyPassword)
          save.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

certificate

public final Cert certificate

privateKey

public final PrivKey privateKey
Constructor Detail

KeyPair

public KeyPair(Cert certificate,
               PrivKey privateKey)

Constructor for KeyPair.

Parameters:
certificate - a Cert object.
privateKey - a PrivKey object.
Method Detail

load

public static KeyPair load(URL certificateFile,
                           URL privateKeyFile,
                           String privateKeyPassword)
                    throws IOException,
                           UnrecoverableKeyException,
                           NoSuchAlgorithmException,
                           CertificateException,
                           KeyStoreException
Load Certificate and Private key pair from X.509 and keystore file

Parameters:
certificateFile - a URL object.
privateKeyFile - a URL object.
privateKeyPassword - a String object.
Returns:
a new keypair instance
Throws:
IOException - if any.
KeyStoreException - if any.
CertificateException - if any.
NoSuchAlgorithmException - if any.
UnrecoverableKeyException - if any.

load

public static KeyPair load(File certificateFile,
                           File privateKeyFile,
                           String privateKeyPassword)
                    throws IOException,
                           UnrecoverableKeyException,
                           NoSuchAlgorithmException,
                           CertificateException,
                           KeyStoreException
Load Certificate and Private key pair from X.509 and keystore file

Parameters:
certificateFile - a File object.
privateKeyFile - a File object.
privateKeyPassword - a String object.
Returns:
a new keypair instance
Throws:
IOException - if any.
KeyStoreException - if any.
CertificateException - if any.
NoSuchAlgorithmException - if any.
UnrecoverableKeyException - if any.

save

public void save(File certificateFile,
                 File privateKeyFile)
          throws IOException

save.

Parameters:
certificateFile - a File object.
privateKeyFile - a File object.
Throws:
IOException - if any.

save

public void save(File certificateFile,
                 File privateKeyFile,
                 String privateKeyPassword)
          throws IOException

save.

Parameters:
certificateFile - a File object.
privateKeyFile - a File object.
privateKeyPassword - a String object.
Throws:
IOException - if any.

getCertificate

public Cert getCertificate()

Getter for the field certificate.

Returns:
a Cert object.

getPrivateKey

public PrivKey getPrivateKey()

Getter for the field privateKey.

Returns:
a PrivKey object.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2018. All rights reserved.