org.globus.wsrf.impl.security.authentication
Class ContextCrypto

java.lang.Object
  extended byorg.globus.wsrf.impl.security.authentication.ContextCrypto
All Implemented Interfaces:
org.apache.ws.security.components.crypto.Crypto

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


Field Summary
private static String ALIAS
           
private static String[] ALIASES
           
private  CertificateFactory certFact
           
private static ContextCrypto crypto
           
private static org.globus.util.I18n i18n
           
private static org.apache.commons.logging.Log log
           
private  Properties properties
           
(package private) static String SKI_OID
           
 
Constructor Summary
ContextCrypto()
           
ContextCrypto(Properties properties)
           
 
Method Summary
 String[] getAliasesForDN(String subjectDN)
           
 String getAliasForX509Cert(byte[] skiBytes)
           
 String getAliasForX509Cert(Certificate cert)
           
 String getAliasForX509Cert(String issuer)
           
 String getAliasForX509Cert(String issuer, BigInteger serialNumber)
           
 byte[] getCertificateData(boolean reverse, X509Certificate[] certs)
           
 CertificateFactory getCertificateFactory()
           
 X509Certificate[] getCertificates(String alias)
          Gets the list of certificates for a given alias.
 String getDefaultX509Alias()
           
static ContextCrypto getInstance()
           
 KeyStore getKeyStore()
           
 PrivateKey getPrivateKey(String alias, String password)
          Gets the private key from the current thread context.
 byte[] getSKIBytesFromCert(X509Certificate cert)
          Reads the SubjectKeyIdentifier information from the certificate.
 X509Certificate[] getX509Certificates(byte[] data, boolean reverse)
           
 void load(InputStream input)
           
 X509Certificate loadCertificate(InputStream in)
           
 void setKeyStore(KeyStore ks)
           
 boolean validateCertPath(X509Certificate[] certs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i18n

private static org.globus.util.I18n i18n

log

private static org.apache.commons.logging.Log log

ALIAS

private static final String ALIAS
See Also:
Constant Field Values

ALIASES

private static final String[] ALIASES

properties

private Properties properties

certFact

private CertificateFactory certFact

crypto

private static ContextCrypto crypto

SKI_OID

static String SKI_OID
Constructor Detail

ContextCrypto

public ContextCrypto()

ContextCrypto

public ContextCrypto(Properties properties)
Method Detail

getInstance

public static ContextCrypto getInstance()

getPrivateKey

public PrivateKey getPrivateKey(String alias,
                                String password)
                         throws Exception
Gets the private key from the current thread context.

Specified by:
getPrivateKey in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
alias - ignored
password - ignored
Returns:
The private key
Throws:
Exception

loadCertificate

public X509Certificate loadCertificate(InputStream in)
                                throws org.apache.ws.security.WSSecurityException
Specified by:
loadCertificate in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getX509Certificates

public X509Certificate[] getX509Certificates(byte[] data,
                                             boolean reverse)
                                      throws org.apache.ws.security.WSSecurityException
Specified by:
getX509Certificates in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

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

getAliasForX509Cert

public String getAliasForX509Cert(String issuer,
                                  BigInteger serialNumber)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getAliasForX509Cert

public String getAliasForX509Cert(byte[] skiBytes)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getAliasForX509Cert

public String getAliasForX509Cert(Certificate cert)
                           throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasForX509Cert in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getDefaultX509Alias

public String getDefaultX509Alias()
Specified by:
getDefaultX509Alias in interface org.apache.ws.security.components.crypto.Crypto

getCertificates

public X509Certificate[] getCertificates(String alias)
                                  throws org.apache.ws.security.WSSecurityException
Gets the list of certificates for a given alias.

Specified by:
getCertificates in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
alias - Lookup certificate chain for this alias
Returns:
Array of X509 certificates for this alias name, or null if this alias does not exist in the keystore
Throws:
org.apache.ws.security.WSSecurityException

setKeyStore

public void setKeyStore(KeyStore ks)

load

public void load(InputStream input)
          throws org.apache.ws.security.components.crypto.CredentialException
Throws:
org.apache.ws.security.components.crypto.CredentialException

getKeyStore

public KeyStore getKeyStore()
Specified by:
getKeyStore in interface org.apache.ws.security.components.crypto.Crypto

getAliasesForDN

public String[] getAliasesForDN(String subjectDN)
                         throws org.apache.ws.security.WSSecurityException
Specified by:
getAliasesForDN in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getCertificateData

public byte[] getCertificateData(boolean reverse,
                                 X509Certificate[] certs)
                          throws org.apache.ws.security.WSSecurityException
Specified by:
getCertificateData in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

getSKIBytesFromCert

public byte[] getSKIBytesFromCert(X509Certificate cert)
                           throws org.apache.ws.security.WSSecurityException
Reads the SubjectKeyIdentifier information from the certificate.

Specified by:
getSKIBytesFromCert in interface org.apache.ws.security.components.crypto.Crypto
Parameters:
cert - The certificate to read SKI
Returns:
The byte array conating the binary SKI data
Throws:
org.apache.ws.security.WSSecurityException

getCertificateFactory

public CertificateFactory getCertificateFactory()
                                         throws org.apache.ws.security.WSSecurityException
Specified by:
getCertificateFactory in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException

validateCertPath

public boolean validateCertPath(X509Certificate[] certs)
                         throws org.apache.ws.security.WSSecurityException
Specified by:
validateCertPath in interface org.apache.ws.security.components.crypto.Crypto
Throws:
org.apache.ws.security.WSSecurityException