FileDocCategorySizeDatePackage
XMLX509Certificate.javaAPI DocJava SE 6 API4574Tue Jun 10 00:23:02 BST 2008com.sun.org.apache.xml.internal.security.keys.content.x509

XMLX509Certificate

public class XMLX509Certificate extends SignatureElementProxy implements XMLX509DataContent
author
$Author: raul $

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
public static final String
JCA_CERT_ID
Field JCA_CERT_ID
Constructors Summary
public XMLX509Certificate(Element element, String BaseURI)
Constructor X509Certificate

param
element
param
BaseURI
throws
XMLSecurityException


               
       
             
      super(element, BaseURI);
   
public XMLX509Certificate(Document doc, byte[] certificateBytes)
Constructor X509Certificate

param
doc
param
certificateBytes


      super(doc);

      this.addBase64Text(certificateBytes);
   
public XMLX509Certificate(Document doc, X509Certificate x509certificate)
Constructor XMLX509Certificate

param
doc
param
x509certificate
throws
XMLSecurityException


      super(doc);

      try {
         this.addBase64Text(x509certificate.getEncoded());
      } catch (java.security.cert.CertificateEncodingException ex) {
         throw new XMLSecurityException("empty", ex);
      }
   
Methods Summary
public booleanequals(java.lang.Object obj)

inheritDoc


      try {
         if (!obj.getClass().getName().equals(this.getClass().getName())) {
            return false;
         }

         XMLX509Certificate other = (XMLX509Certificate) obj;

         /** $todo$ or should be create X509Certificates and use the equals() from the Certs */
         return java.security.MessageDigest.isEqual(other.getCertificateBytes(),
                                        this.getCertificateBytes());
      } catch (XMLSecurityException ex) {
         return false;
      }
   
public java.lang.StringgetBaseLocalName()

inheritDoc

      return Constants._TAG_X509CERTIFICATE;
   
public byte[]getCertificateBytes()
Method getCertificateBytes

return
the certificate bytes
throws
XMLSecurityException

      return this.getBytesFromTextChild();
   
public java.security.PublicKeygetPublicKey()
Method getPublicKey

return
teh publickey
throws
XMLSecurityException


      X509Certificate cert = this.getX509Certificate();

      if (cert != null) {
         return cert.getPublicKey();
      }

      return null;
   
public java.security.cert.X509CertificategetX509Certificate()
Method getX509Certificate

return
the x509 certificate
throws
XMLSecurityException


      try {
         byte certbytes[] = this.getCertificateBytes();
         CertificateFactory certFact =
            CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID);
         X509Certificate cert =
            (X509Certificate) certFact
               .generateCertificate(new ByteArrayInputStream(certbytes));

         if (cert != null) {
            return cert;
         }

         return null;
      } catch (CertificateException ex) {
         throw new XMLSecurityException("empty", ex);
      }