Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.sourcetap.license
Class EncryptionUtil  view EncryptionUtil download EncryptionUtil.java

java.lang.Object
  extended bycom.sourcetap.license.EncryptionUtil

public class EncryptionUtil
extends java.lang.Object

Provides utility functions to handle public/private key encryption.

Version:
$Revision$

Field Summary
private  java.security.PrivateKey privateKey
           
private  java.security.PublicKey publicKey
           
 
Constructor Summary
EncryptionUtil()
           
 
Method Summary
 void generateKeys()
          Generate a public/private key pair
 void generateKeys(java.lang.String publicURI, java.lang.String privateURI)
          Generate a public/private key pair, and write the keys to the specified files
 java.security.PrivateKey getPrivate()
           
 java.security.PublicKey getPublic()
           
 void readKeys(java.lang.String publicURI, java.lang.String privateURI)
          read public/private keys from specified files
 java.security.PrivateKey readPrivateKey(java.lang.String URI)
          read private key from specified file
 java.security.PublicKey readPublicKey(java.lang.String URI)
          read public key from specified file
 java.lang.String sign(java.lang.String message)
          sign a message using the private key
 java.lang.String sign(java.lang.String message, java.security.PrivateKey privateKey)
          sign a message using the private key
 java.lang.String sign(java.lang.String message, java.lang.String privateKeyURI)
          sign a message using the private key
 boolean verify(java.lang.String message, java.lang.String signature)
          verify that the message was signed by the private key by using the public key
 boolean verify(java.lang.String message, java.lang.String signature, java.security.PublicKey publicKey)
          verify that the message was signed by the private key by using the public key
 boolean verify(java.lang.String message, java.lang.String signature, java.lang.String publicKeyURI)
          verify that the message was signed by the private key by using the public key
 void writeKeys(java.lang.String publicURI, java.lang.String privateURI)
           
 void writePrivateKey(java.lang.String URI)
           
 void writePublicKey(java.lang.String URI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publicKey

private java.security.PublicKey publicKey

privateKey

private java.security.PrivateKey privateKey
Constructor Detail

EncryptionUtil

public EncryptionUtil()
Method Detail

generateKeys

public void generateKeys()
                  throws java.io.IOException,
                         java.security.NoSuchAlgorithmException,
                         java.security.NoSuchProviderException
Generate a public/private key pair


generateKeys

public void generateKeys(java.lang.String publicURI,
                         java.lang.String privateURI)
                  throws java.io.IOException,
                         java.security.NoSuchAlgorithmException,
                         java.security.NoSuchProviderException
Generate a public/private key pair, and write the keys to the specified files


getPublic

public java.security.PublicKey getPublic()

getPrivate

public java.security.PrivateKey getPrivate()

writeKeys

public void writeKeys(java.lang.String publicURI,
                      java.lang.String privateURI)
               throws java.io.IOException,
                      java.io.FileNotFoundException

writePublicKey

public void writePublicKey(java.lang.String URI)
                    throws java.io.IOException,
                           java.io.FileNotFoundException

writePrivateKey

public void writePrivateKey(java.lang.String URI)
                     throws java.io.IOException,
                            java.io.FileNotFoundException

readKeys

public void readKeys(java.lang.String publicURI,
                     java.lang.String privateURI)
              throws java.io.IOException,
                     java.security.NoSuchAlgorithmException,
                     java.security.NoSuchProviderException,
                     java.security.spec.InvalidKeySpecException
read public/private keys from specified files


readPublicKey

public java.security.PublicKey readPublicKey(java.lang.String URI)
                                      throws java.io.IOException,
                                             java.security.NoSuchAlgorithmException,
                                             java.security.NoSuchProviderException,
                                             java.security.spec.InvalidKeySpecException
read public key from specified file


readPrivateKey

public java.security.PrivateKey readPrivateKey(java.lang.String URI)
                                        throws java.io.IOException,
                                               java.security.NoSuchAlgorithmException,
                                               java.security.NoSuchProviderException,
                                               java.security.spec.InvalidKeySpecException
read private key from specified file


sign

public java.lang.String sign(java.lang.String message)
                      throws java.io.IOException,
                             java.security.NoSuchAlgorithmException,
                             java.security.NoSuchProviderException,
                             java.security.spec.InvalidKeySpecException,
                             java.security.InvalidKeyException,
                             java.security.SignatureException
sign a message using the private key


sign

public java.lang.String sign(java.lang.String message,
                             java.lang.String privateKeyURI)
                      throws java.io.IOException,
                             java.security.NoSuchAlgorithmException,
                             java.security.NoSuchProviderException,
                             java.security.spec.InvalidKeySpecException,
                             java.security.InvalidKeyException,
                             java.security.SignatureException,
                             java.io.IOException
sign a message using the private key


sign

public java.lang.String sign(java.lang.String message,
                             java.security.PrivateKey privateKey)
                      throws java.io.IOException,
                             java.security.NoSuchAlgorithmException,
                             java.security.NoSuchProviderException,
                             java.security.spec.InvalidKeySpecException,
                             java.security.InvalidKeyException,
                             java.security.SignatureException
sign a message using the private key


verify

public boolean verify(java.lang.String message,
                      java.lang.String signature,
                      java.lang.String publicKeyURI)
               throws java.io.IOException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.spec.InvalidKeySpecException,
                      java.security.InvalidKeyException,
                      java.security.SignatureException
verify that the message was signed by the private key by using the public key


verify

public boolean verify(java.lang.String message,
                      java.lang.String signature)
               throws java.io.IOException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.spec.InvalidKeySpecException,
                      java.security.InvalidKeyException,
                      java.security.SignatureException
verify that the message was signed by the private key by using the public key


verify

public boolean verify(java.lang.String message,
                      java.lang.String signature,
                      java.security.PublicKey publicKey)
               throws java.io.IOException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.spec.InvalidKeySpecException,
                      java.security.InvalidKeyException,
                      java.security.SignatureException
verify that the message was signed by the private key by using the public key