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

X509Data

public class X509Data extends SignatureElementProxy implements KeyInfoContent
author
$Author: raul $

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
Constructors Summary
public X509Data(Document doc)
Constructor X509Data

param
doc


           
      

      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);
   
public X509Data(Element element, String BaseURI)
Constructor X509Data

param
element
param
BaseURI
throws
XMLSecurityException


      super(element, BaseURI);
      
      boolean noElements=true;
      Node sibling=this._constructionElement.getFirstChild();
      while (sibling!=null) {
      	 if (sibling.getNodeType()!=Node.ELEMENT_NODE) {
      	 	sibling=sibling.getNextSibling();
            continue;
         }
        noElements=false;
         Element currentElem = (Element) sibling;
         sibling=sibling.getNextSibling();
         String localname = currentElem.getLocalName();

         if (currentElem.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
            if (localname.equals(Constants._TAG_X509ISSUERSERIAL)) {
               XMLX509IssuerSerial is = new XMLX509IssuerSerial(currentElem,
                                           BaseURI);

               this.add(is);
            } else if (localname.equals(Constants._TAG_X509SKI)) {
               XMLX509SKI ski = new XMLX509SKI(currentElem, BaseURI);

               this.add(ski);
            } else if (localname.equals(Constants._TAG_X509SUBJECTNAME)) {
               XMLX509SubjectName sn = new XMLX509SubjectName(currentElem,
                                          BaseURI);

               this.add(sn);
            } else if (localname.equals(Constants._TAG_X509CERTIFICATE)) {
               XMLX509Certificate cert = new XMLX509Certificate(currentElem,
                                            BaseURI);

               this.add(cert);
            } else if (localname.equals(Constants._TAG_X509CRL)) {
               XMLX509CRL crl = new XMLX509CRL(currentElem, BaseURI);

               this.add(crl);
            } else {
               log.log(java.util.logging.Level.WARNING, "Found a " + currentElem.getTagName() + " element in "
                        + Constants._TAG_X509DATA);
               this.addUnknownElement(currentElem);
            }
         } else {
            log.log(java.util.logging.Level.WARNING, "Found a " + currentElem.getTagName() + " element in "
                     + Constants._TAG_X509DATA);
            this.addUnknownElement(currentElem);
         }
      }
      if (noElements) {
        Object exArgs[] = { "Elements", Constants._TAG_X509DATA };

        throw new XMLSecurityException("xml.WrongContent", exArgs);
     }

   
Methods Summary
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SubjectName xmlX509SubjectName)
Method add

param
xmlX509SubjectName


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(xmlX509SubjectName.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate xmlX509Certificate)
Method add

param
xmlX509Certificate


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(xmlX509Certificate.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509CRL xmlX509CRL)
Method add

param
xmlX509CRL


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(xmlX509CRL.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509IssuerSerial xmlX509IssuerSerial)
Method add

param
xmlX509IssuerSerial


      if (this._state == MODE_SIGN) {
         this._constructionElement
            .appendChild(xmlX509IssuerSerial.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI xmlX509SKI)
Method add

param
xmlX509SKI


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(xmlX509SKI.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidaddCRL(byte[] crlBytes)
Method addCRL

param
crlBytes

      this.add(new XMLX509CRL(this._doc, crlBytes));
   
public voidaddCertificate(java.security.cert.X509Certificate x509certificate)
Method addCertificate

param
x509certificate
throws
XMLSecurityException

      this.add(new XMLX509Certificate(this._doc, x509certificate));
   
public voidaddCertificate(byte[] x509certificateBytes)
Method addCertificate

param
x509certificateBytes

      this.add(new XMLX509Certificate(this._doc, x509certificateBytes));
   
public voidaddIssuerSerial(java.lang.String X509IssuerName, java.math.BigInteger X509SerialNumber)
Method addIssuerSerial

param
X509IssuerName
param
X509SerialNumber

      this.add(new XMLX509IssuerSerial(this._doc, X509IssuerName,
                                       X509SerialNumber));
   
public voidaddIssuerSerial(java.lang.String X509IssuerName, java.lang.String X509SerialNumber)
Method addIssuerSerial

param
X509IssuerName
param
X509SerialNumber

      this.add(new XMLX509IssuerSerial(this._doc, X509IssuerName,
                                       X509SerialNumber));
   
public voidaddIssuerSerial(java.lang.String X509IssuerName, int X509SerialNumber)
Method addIssuerSerial

param
X509IssuerName
param
X509SerialNumber

      this.add(new XMLX509IssuerSerial(this._doc, X509IssuerName,
                                       X509SerialNumber));
   
public voidaddSKI(byte[] skiBytes)
Method addSKI

param
skiBytes

      this.add(new XMLX509SKI(this._doc, skiBytes));
   
public voidaddSKI(java.security.cert.X509Certificate x509certificate)
Method addSKI

param
x509certificate
throws
XMLSecurityException

      this.add(new XMLX509SKI(this._doc, x509certificate));
   
public voidaddSubjectName(java.lang.String subjectName)
Method addSubjectName

param
subjectName

      this.add(new XMLX509SubjectName(this._doc, subjectName));
   
public voidaddSubjectName(java.security.cert.X509Certificate x509certificate)
Method addSubjectName

param
x509certificate

      this.add(new XMLX509SubjectName(this._doc, x509certificate));
   
public voidaddUnknownElement(org.w3c.dom.Element element)
Method addUnknownElement

param
element


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(element);
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public booleancontainsCRL()
Method containsCRL

return
true if this X509Data contains a CRL

      return this.lengthCRL() > 0;
   
public booleancontainsCertificate()
Method containsCertificate

return
true if this X509Data contains a Certificate

      return this.lengthCertificate() > 0;
   
public booleancontainsIssuerSerial()
Method containsIssuerSerial

return
true if this X509Data contains a IssuerSerial

      return this.lengthIssuerSerial() > 0;
   
public booleancontainsSKI()
Method containsSKI

return
true if this X509Data contains a SKI

      return this.lengthSKI() > 0;
   
public booleancontainsSubjectName()
Method containsSubjectName

return
true if this X509Data contains a SubjectName

      return this.lengthSubjectName() > 0;
   
public booleancontainsUnknownElement()
Method containsUnknownElement

return
true if this X509Data contains an UnknownElement

      return this.lengthUnknownElement() > 0;
   
public java.lang.StringgetBaseLocalName()

inheritDoc

      return Constants._TAG_X509DATA;
   
public com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509CRLitemCRL(int i)
Method itemCRL

param
i
return
the X509CRL, null if not present
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_X509CRL,i);

      if (e != null) {
         return new XMLX509CRL(e, this._baseURI);
      } 
       return null;
   
public com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509CertificateitemCertificate(int i)
Method itemCertificate

param
i
return
the X509Certifacte, null if not present
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_X509CERTIFICATE,i);

      if (e != null) {
         return new XMLX509Certificate(e, this._baseURI);
      } 
       return null;
   
public com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509IssuerSerialitemIssuerSerial(int i)
Method itemIssuerSerial

param
i
return
the X509IssuerSerial, null if not present
throws
XMLSecurityException


      Element e =
        XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                       Constants._TAG_X509ISSUERSERIAL,i);

      if (e != null) {
         return new XMLX509IssuerSerial(e, this._baseURI);
      } 
      return null;
   
public com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKIitemSKI(int i)
Method itemSKI

param
i
return
the X509SKI, null if not present
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_X509SKI,i);

      if (e != null) {
         return new XMLX509SKI(e, this._baseURI);
      }
      return null;
   
public com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SubjectNameitemSubjectName(int i)
Method itemSubjectName

param
i
return
the X509SubjectName, null if not present
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_X509SUBJECTNAME,i);

      if (e != null) {
         return new XMLX509SubjectName(e, this._baseURI);
      } 
       return null;
   
public org.w3c.dom.ElementitemUnknownElement(int i)
Method itemUnknownElement

param
i
return
the Unknown Element at i TODO implement

	  if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "itemUnknownElement not implemented:"+i);
      return null;
   
public intlengthCRL()
Method lengthCRL

return
the number of CRL elements in this X509Data

      return this.length(Constants.SignatureSpecNS, Constants._TAG_X509CRL);
   
public intlengthCertificate()
Method lengthCertificate

return
the number of Certificate elements in this X509Data

      return this.length(Constants.SignatureSpecNS,
                         Constants._TAG_X509CERTIFICATE);
   
public intlengthIssuerSerial()
Method lengthIssuerSerial

return
the number of IssuerSerial elements in this X509Data

      return this.length(Constants.SignatureSpecNS,
                         Constants._TAG_X509ISSUERSERIAL);
   
public intlengthSKI()
Method lengthSKI

return
the number of SKI elements in this X509Data

      return this.length(Constants.SignatureSpecNS, Constants._TAG_X509SKI);
   
public intlengthSubjectName()
Method lengthSubjectName

return
the number of SubjectName elements in this X509Data

      return this.length(Constants.SignatureSpecNS,
                         Constants._TAG_X509SUBJECTNAME);
   
public intlengthUnknownElement()
Method lengthUnknownElement

return
the number of UnknownElement elements in this X509Data

      
      int result = 0;
      Node n=this._constructionElement.getFirstChild();
      while (n!=null){         

         if ((n.getNodeType() == Node.ELEMENT_NODE)
                 &&!n.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
            result += 1;
         }
         n=n.getNextSibling();
      }
      
      return result;