org.ogf.graap.wsag.client.wsrf.security
Class Merlin

java.lang.Object
  extended by org.ogf.graap.wsag.client.wsrf.security.Merlin
All Implemented Interfaces:
org.apache.ws.security.components.crypto.Crypto

public class Merlin
extends Object
implements org.apache.ws.security.components.crypto.Crypto

WSAG4J Merlin is an implementation of the WSS4J Crypto interface. It reads a crypto object from the Axis2 MessageContext using the SecurityConstants.CRYPTO_SIGN key. All calls to this instance are delegated to the signing crypto.

Author:
Oliver Waeldrich

Constructor Summary
Merlin(Properties properties)
          Default constructor used by the WS-Security implementation.
Merlin(Properties properties, ClassLoader loader)
          Default constructor used by the WS-Security implementation.
 
Method Summary
 String[] getAliasesForDN(String arg0)
          Test Test.
 String getAliasForX509Cert(byte[] arg0)
           
 String getAliasForX509Cert(Certificate arg0)
           
 String getAliasForX509Cert(String issuer)
          
 String getAliasForX509Cert(String arg0, BigInteger arg1)
           
 String getAliasForX509CertThumb(byte[] arg0)
           
 byte[] getCertificateData(boolean arg0, X509Certificate[] certs)
           
 CertificateFactory getCertificateFactory()
           
 X509Certificate[] getCertificates(String alias)
           
 String getDefaultX509Alias()
           
 KeyStore getKeyStore()
           
 PrivateKey getPrivateKey(String alias, String password)
           
 byte[] getSKIBytesFromCert(X509Certificate certificate)
           
 X509Certificate[] getX509Certificates(byte[] bytes, boolean arg1)
           
 X509Certificate loadCertificate(InputStream in)
           
 boolean validateCertPath(X509Certificate[] cert)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Merlin

public Merlin(Properties properties)
       throws org.apache.ws.security.components.crypto.CredentialException,
              IOException
Default constructor used by the WS-Security implementation. In fact, this constructors does nothing.

Parameters:
properties - the Merlin properties
Throws:
org.apache.ws.security.components.crypto.CredentialException - indicates an error loading or processing the credentials
IOException - indicates an error reading from the keystore

Merlin

public Merlin(Properties properties,
              ClassLoader loader)
       throws org.apache.ws.security.components.crypto.CredentialException,
              IOException
Default constructor used by the WS-Security implementation.

Parameters:
properties - the Merlin properties
loader - the ClassLoader to use
Throws:
org.apache.ws.security.components.crypto.CredentialException - indicates an error loading or processing the credentials
IOException - indicates an error reading from the keystore
Method Detail

getAliasesForDN

public String[] getAliasesForDN(String arg0)
                         throws org.apache.ws.security.WSSecurityException
Test Test.

Specified by:
getAliasesForDN in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getAliasForX509Cert

public String getAliasForX509Cert(byte[] arg0)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
arg0 -
Returns:
Throws:
org.apache.ws.security.WSSecurityException
See Also:
Crypto.getAliasForX509Cert(byte[])

getAliasForX509Cert

public String getAliasForX509Cert(Certificate arg0)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
arg0 -
Returns:
Throws:
org.apache.ws.security.WSSecurityException
See Also:
Crypto.getAliasForX509Cert(java.security.cert.Certificate)

getAliasForX509Cert

public String getAliasForX509Cert(String arg0,
                                  BigInteger arg1)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
arg0 -
arg1 -
Returns:
Throws:
org.apache.ws.security.WSSecurityException
See Also:
Crypto.getAliasForX509Cert(java.lang.String, java.math.BigInteger)

getAliasForX509Cert

public String getAliasForX509Cert(String issuer)
                           throws org.apache.ws.security.WSSecurityException

Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException
See Also:
CryptoBase.getAliasForX509Cert(String)

getAliasForX509CertThumb

public String getAliasForX509CertThumb(byte[] arg0)
                                throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509CertThumb in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
arg0 - The certificate thumb as byte array.
Returns:
The alias for the given certificate thumb.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred getting the alias from the certificate.
See Also:
Crypto.getAliasForX509CertThumb(byte[])

getCertificateData

public byte[] getCertificateData(boolean arg0,
                                 X509Certificate[] certs)
                          throws org.apache.ws.security.WSSecurityException
Specified by:
getCertificateData in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
arg0 -
certs - The certificate chain to convert.
Returns:
The certificate data as byte array.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred getting the certificate data.
See Also:
Crypto.getCertificateData(boolean, java.security.cert.X509Certificate[])

getCertificateFactory

public CertificateFactory getCertificateFactory()
                                         throws org.apache.ws.security.WSSecurityException
Specified by:
getCertificateFactory in interface org.apache.ws.security.components.crypto.Crypto
Returns:
The certificate factory for this user keystore.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred getting the certificate factory.
See Also:
Crypto.getCertificateFactory()

getCertificates

public X509Certificate[] getCertificates(String alias)
                                  throws org.apache.ws.security.WSSecurityException
Specified by:
getCertificates in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
alias - The alias for which the certificate chain should be retrieved.
Returns:
The certificate chain for the given alias.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred getting the certificate chain.
See Also:
Crypto.getCertificates(java.lang.String)

getDefaultX509Alias

public String getDefaultX509Alias()
Specified by:
getDefaultX509Alias in interface org.apache.ws.security.components.crypto.Crypto
Returns:
Returns the default alias of the user keystore.
See Also:
Crypto.getDefaultX509Alias()

getKeyStore

public KeyStore getKeyStore()
Specified by:
getKeyStore in interface org.apache.ws.security.components.crypto.Crypto
Returns:
Returns the user crypto's keystore object.
See Also:
Crypto.getKeyStore()

getPrivateKey

public PrivateKey getPrivateKey(String alias,
                                String password)
                         throws Exception
Specified by:
getPrivateKey in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
alias - The private key alias.
password - The private key password.
Returns:
The private key loaded from the user crypto.
Throws:
Exception - A failure occurred getting the private key.
See Also:
Crypto.getPrivateKey(java.lang.String, java.lang.String)

getSKIBytesFromCert

public byte[] getSKIBytesFromCert(X509Certificate certificate)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getSKIBytesFromCert in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
certificate - The certificate to get the SKI bytes from.
Returns:
The SKI bytes.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred getting the SKI bytes.
See Also:
Crypto.getSKIBytesFromCert(java.security.cert.X509Certificate)

getX509Certificates

public X509Certificate[] getX509Certificates(byte[] bytes,
                                             boolean arg1)
                                      throws org.apache.ws.security.WSSecurityException
Specified by:
getX509Certificates in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
bytes -
arg1 -
Returns:
The loaded certificate chain.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred during the loading procedure.
See Also:
Crypto.getX509Certificates(byte[], boolean)

loadCertificate

public X509Certificate loadCertificate(InputStream in)
                                throws org.apache.ws.security.WSSecurityException
Specified by:
loadCertificate in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
in - The input stream from which the certificate is loaded.
Returns:
The loaded certificate.
Throws:
org.apache.ws.security.WSSecurityException - A failure occurred during the loading procedure.
See Also:
Crypto.loadCertificate(java.io.InputStream)

validateCertPath

public boolean validateCertPath(X509Certificate[] cert)
                         throws org.apache.ws.security.WSSecurityException
Specified by:
validateCertPath in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
cert - The certificate path to validate.
Returns:
true, if the validation succeeded, otherwise false
Throws:
org.apache.ws.security.WSSecurityException - An exception occurred during the certificate path validation process.
See Also:
Crypto.validateCertPath(java.security.cert.X509Certificate[])


Copyright © 2008-2012. All Rights Reserved.