org.apache.rahas.impl.util
Class CommonUtil

java.lang.Object
  extended by org.apache.rahas.impl.util.CommonUtil

public class CommonUtil
extends java.lang.Object

This class implements some utility methods common to SAML1 and SAML2.


Constructor Summary
CommonUtil()
           
 
Method Summary
static java.security.cert.X509Certificate getCertificateByAlias(org.apache.ws.security.components.crypto.Crypto crypto, java.lang.String alias)
          Gets the certificates chain by alias.
static java.security.cert.X509Certificate[] getCertificatesByAlias(org.apache.ws.security.components.crypto.Crypto crypto, java.lang.String alias)
          Gets the certificates chain by alias.
static org.apache.ws.security.components.crypto.Crypto getCrypto(java.util.Properties properties, java.lang.ClassLoader classLoader)
          Constructs crypto configuration based on the given properties.
static org.apache.ws.security.components.crypto.Crypto getCrypto(java.lang.String propertiesFile, java.lang.ClassLoader classLoader)
          Constructs crypto configuration based on the given properties.
static byte[] getDecryptedBytes(javax.security.auth.callback.CallbackHandler callbackHandler, org.apache.ws.security.components.crypto.Crypto crypto, org.w3c.dom.Node encryptedKeyElement)
          Decrypts the EncryptedKey element and returns the secret that was used.
static org.w3c.dom.Document getOMDOMDocument()
          This method creates a DOM compatible Axiom document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonUtil

public CommonUtil()
Method Detail

getOMDOMDocument

public static org.w3c.dom.Document getOMDOMDocument()
                                             throws TrustException
This method creates a DOM compatible Axiom document.

Returns:
DOM compatible Axiom document
Throws:
TrustException - If an error occurred while creating the Document.

getCertificateByAlias

public static java.security.cert.X509Certificate getCertificateByAlias(org.apache.ws.security.components.crypto.Crypto crypto,
                                                                       java.lang.String alias)
                                                                throws TrustException
Gets the certificates chain by alias. Always returns the first certificate if a certificate chain is found.

Parameters:
crypto - Crypto to lookup certificate.
alias - Alias name.
Returns:
X509 certificate object.
Throws:
TrustException - If an error occurred while retrieving the certificate or if no certificates are found for given alias.

getCertificatesByAlias

public static java.security.cert.X509Certificate[] getCertificatesByAlias(org.apache.ws.security.components.crypto.Crypto crypto,
                                                                          java.lang.String alias)
                                                                   throws TrustException
Gets the certificates chain by alias. If no certificates are found return an empty array.

Parameters:
crypto - Crypto to lookup certificate.
alias - Alias name.
Returns:
X509 certificates array.
Throws:
TrustException - If an error occurred while retrieving the certificate.

getDecryptedBytes

public static byte[] getDecryptedBytes(javax.security.auth.callback.CallbackHandler callbackHandler,
                                       org.apache.ws.security.components.crypto.Crypto crypto,
                                       org.w3c.dom.Node encryptedKeyElement)
                                throws org.apache.ws.security.WSSecurityException
Decrypts the EncryptedKey element and returns the secret that was used.

Parameters:
callbackHandler - Callback handler to pass to WSS4J framework.
crypto - To get private key information.
encryptedKeyElement - The encrypted Key element.
Returns:
The secret as a byte stream.
Throws:
org.apache.ws.security.WSSecurityException - If an error is occurred while decrypting the element.

getCrypto

public static org.apache.ws.security.components.crypto.Crypto getCrypto(java.util.Properties properties,
                                                                        java.lang.ClassLoader classLoader)
                                                                 throws TrustException
Constructs crypto configuration based on the given properties. Provider is instantiated using given class loader.

Parameters:
properties - Crypto configuration properties.
classLoader - Class loader used to create provider.
Returns:
A crypto object.
Throws:
TrustException - If an error occurred while creating the Crypto object.

getCrypto

public static org.apache.ws.security.components.crypto.Crypto getCrypto(java.lang.String propertiesFile,
                                                                        java.lang.ClassLoader classLoader)
                                                                 throws TrustException
Constructs crypto configuration based on the given properties. Provider is instantiated using given class loader.

Parameters:
propertiesFile - Crypto configuration properties file name.
classLoader - Class loader used to create provider.
Returns:
A crypto object.
Throws:
TrustException - If an error occurred while creating the Crypto object.