com.atlassian.security.auth.trustedapps
Class BouncyCastleEncryptionProvider

java.lang.Object
  extended bycom.atlassian.security.auth.trustedapps.BaseEncryptionProvider
      extended bycom.atlassian.security.auth.trustedapps.BouncyCastleEncryptionProvider
All Implemented Interfaces:
EncryptionProvider

public class BouncyCastleEncryptionProvider
extends BaseEncryptionProvider


Constructor Summary
BouncyCastleEncryptionProvider()
           
 
Method Summary
 EncryptedCertificate createEncryptedCertificate(java.lang.String userName, java.security.PrivateKey privateKey, java.lang.String appId)
          Create a new encrypted certificate for transmission to another application
 ApplicationCertificate decodeEncryptedCertificate(EncryptedCertificate encCert, java.security.PublicKey publicKey, java.lang.String appId)
          Decode an encrypted certificate to retrieve its ApplicationCertificate
 java.security.KeyPair generateNewKeyPair()
          Generates a new KeyPair.
 java.security.PrivateKey toPrivateKey(byte[] encodedForm)
          Decodes the given form into the real key object according to the given algorithm Uses Bouncy Castle as a provider
 java.security.PublicKey toPublicKey(byte[] encodedForm)
          Decodes the given form into the real key object according to the given algorithm Uses Bouncy Castle as a provider
 
Methods inherited from class com.atlassian.security.auth.trustedapps.BaseEncryptionProvider
generateUID, getApplicationCertificate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BouncyCastleEncryptionProvider

public BouncyCastleEncryptionProvider()
Method Detail

toPublicKey

public java.security.PublicKey toPublicKey(byte[] encodedForm)
                                    throws java.security.NoSuchAlgorithmException,
                                           java.security.spec.InvalidKeySpecException,
                                           java.security.NoSuchProviderException
Decodes the given form into the real key object according to the given algorithm Uses Bouncy Castle as a provider

Parameters:
encodedForm - the byte[] containing the key data
Returns:
the generated PublicKey
Throws:
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.security.NoSuchProviderException

toPrivateKey

public java.security.PrivateKey toPrivateKey(byte[] encodedForm)
                                      throws java.security.NoSuchAlgorithmException,
                                             java.security.spec.InvalidKeySpecException,
                                             java.security.NoSuchProviderException
Decodes the given form into the real key object according to the given algorithm Uses Bouncy Castle as a provider

Parameters:
encodedForm - the PKS8 encoded key data
Returns:
a fully formed PrivateKey
Throws:
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.security.NoSuchProviderException

generateNewKeyPair

public java.security.KeyPair generateNewKeyPair()
                                         throws java.security.NoSuchAlgorithmException,
                                                java.security.NoSuchProviderException
Generates a new KeyPair.

Given algorithm name will be used to generate the key pair. It is mandatory. Security provides parameter is optional and can be null in which case the choice of a provider is left to the VM. Key size is optional and can be set to -1 in which case the default size is used.

Returns:
a new public/private key pair
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException

decodeEncryptedCertificate

public ApplicationCertificate decodeEncryptedCertificate(EncryptedCertificate encCert,
                                                         java.security.PublicKey publicKey,
                                                         java.lang.String appId)
                                                  throws InvalidCertificateException
Description copied from interface: EncryptionProvider
Decode an encrypted certificate to retrieve its ApplicationCertificate

Parameters:
encCert - the encrypted certificate of the application
publicKey - the application's public key
appId - the application's ID
Returns:
the decrypted ApplicationCertificate
Throws:
InvalidCertificateException - if the certificate was malformed, or could not be decrypted

createEncryptedCertificate

public EncryptedCertificate createEncryptedCertificate(java.lang.String userName,
                                                       java.security.PrivateKey privateKey,
                                                       java.lang.String appId)
Description copied from interface: EncryptionProvider
Create a new encrypted certificate for transmission to another application

Parameters:
userName - the username to certify
privateKey - the private key of this application
appId - the ID of this application
Returns:


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.