|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
package com.sun.org.apache.xml.internal.security.keys.content; |
|
|
|
import java.math.BigInteger; |
|
import java.security.cert.X509Certificate; |
|
|
|
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; |
|
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509CRL; |
|
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate; |
|
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Digest; |
|
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509IssuerSerial; |
|
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI; |
|
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SubjectName; |
|
import com.sun.org.apache.xml.internal.security.utils.Constants; |
|
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; |
|
import com.sun.org.apache.xml.internal.security.utils.XMLUtils; |
|
import org.w3c.dom.Document; |
|
import org.w3c.dom.Element; |
|
import org.w3c.dom.Node; |
|
|
|
public class X509Data extends SignatureElementProxy implements KeyInfoContent { |
|
|
|
private static final com.sun.org.slf4j.internal.Logger LOG = |
|
com.sun.org.slf4j.internal.LoggerFactory.getLogger(X509Data.class); |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public X509Data(Document doc) { |
|
super(doc); |
|
|
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public X509Data(Element element, String baseURI) throws XMLSecurityException { |
|
super(element, baseURI); |
|
|
|
Node sibling = getFirstChild(); |
|
while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE) { |
|
sibling = sibling.getNextSibling(); |
|
} |
|
if (sibling == null || sibling.getNodeType() != Node.ELEMENT_NODE) { |
|
|
|
Object exArgs[] = { "Elements", Constants._TAG_X509DATA }; |
|
throw new XMLSecurityException("xml.WrongContent", exArgs); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addIssuerSerial(String X509IssuerName, BigInteger X509SerialNumber) { |
|
this.add(new XMLX509IssuerSerial(getDocument(), X509IssuerName, X509SerialNumber)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addIssuerSerial(String X509IssuerName, String X509SerialNumber) { |
|
this.add(new XMLX509IssuerSerial(getDocument(), X509IssuerName, X509SerialNumber)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addIssuerSerial(String X509IssuerName, int X509SerialNumber) { |
|
this.add(new XMLX509IssuerSerial(getDocument(), X509IssuerName, X509SerialNumber)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void add(XMLX509IssuerSerial xmlX509IssuerSerial) { |
|
|
|
appendSelf(xmlX509IssuerSerial); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addSKI(byte[] skiBytes) { |
|
this.add(new XMLX509SKI(getDocument(), skiBytes)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addSKI(X509Certificate x509certificate) |
|
throws XMLSecurityException { |
|
this.add(new XMLX509SKI(getDocument(), x509certificate)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void add(XMLX509SKI xmlX509SKI) { |
|
appendSelf(xmlX509SKI); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addSubjectName(String subjectName) { |
|
this.add(new XMLX509SubjectName(getDocument(), subjectName)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addSubjectName(X509Certificate x509certificate) { |
|
this.add(new XMLX509SubjectName(getDocument(), x509certificate)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void add(XMLX509SubjectName xmlX509SubjectName) { |
|
appendSelf(xmlX509SubjectName); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addCertificate(X509Certificate x509certificate) |
|
throws XMLSecurityException { |
|
this.add(new XMLX509Certificate(getDocument(), x509certificate)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addCertificate(byte[] x509certificateBytes) { |
|
this.add(new XMLX509Certificate(getDocument(), x509certificateBytes)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void add(XMLX509Certificate xmlX509Certificate) { |
|
appendSelf(xmlX509Certificate); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addCRL(byte[] crlBytes) { |
|
this.add(new XMLX509CRL(getDocument(), crlBytes)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void add(XMLX509CRL xmlX509CRL) { |
|
appendSelf(xmlX509CRL); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addDigest(X509Certificate x509certificate, String algorithmURI) |
|
throws XMLSecurityException { |
|
this.add(new XMLX509Digest(getDocument(), x509certificate, algorithmURI)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addDigest(byte[] x509CertificateDigestBytes, String algorithmURI) { |
|
this.add(new XMLX509Digest(getDocument(), x509CertificateDigestBytes, algorithmURI)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void add(XMLX509Digest xmlX509Digest) { |
|
appendSelf(xmlX509Digest); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addUnknownElement(Element element) { |
|
appendSelf(element); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthIssuerSerial() { |
|
return this.length(Constants.SignatureSpecNS, Constants._TAG_X509ISSUERSERIAL); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthSKI() { |
|
return this.length(Constants.SignatureSpecNS, Constants._TAG_X509SKI); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthSubjectName() { |
|
return this.length(Constants.SignatureSpecNS, Constants._TAG_X509SUBJECTNAME); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthCertificate() { |
|
return this.length(Constants.SignatureSpecNS, Constants._TAG_X509CERTIFICATE); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthCRL() { |
|
return this.length(Constants.SignatureSpecNS, Constants._TAG_X509CRL); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthDigest() { |
|
return this.length(Constants.SignatureSpec11NS, Constants._TAG_X509DIGEST); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int lengthUnknownElement() { |
|
int result = 0; |
|
Node n = getFirstChild(); |
|
while (n != null) { |
|
if (n.getNodeType() == Node.ELEMENT_NODE |
|
&& !n.getNamespaceURI().equals(Constants.SignatureSpecNS)) { |
|
result++; |
|
} |
|
n = n.getNextSibling(); |
|
} |
|
|
|
return result; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLX509IssuerSerial itemIssuerSerial(int i) throws XMLSecurityException { |
|
Element e = |
|
XMLUtils.selectDsNode( |
|
getFirstChild(), Constants._TAG_X509ISSUERSERIAL, i); |
|
|
|
if (e != null) { |
|
return new XMLX509IssuerSerial(e, this.baseURI); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLX509SKI itemSKI(int i) throws XMLSecurityException { |
|
|
|
Element e = |
|
XMLUtils.selectDsNode( |
|
getFirstChild(), Constants._TAG_X509SKI, i); |
|
|
|
if (e != null) { |
|
return new XMLX509SKI(e, this.baseURI); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLX509SubjectName itemSubjectName(int i) throws XMLSecurityException { |
|
|
|
Element e = |
|
XMLUtils.selectDsNode( |
|
getFirstChild(), Constants._TAG_X509SUBJECTNAME, i); |
|
|
|
if (e != null) { |
|
return new XMLX509SubjectName(e, this.baseURI); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { |
|
|
|
Element e = |
|
XMLUtils.selectDsNode( |
|
getFirstChild(), Constants._TAG_X509CERTIFICATE, i); |
|
|
|
if (e != null) { |
|
return new XMLX509Certificate(e, this.baseURI); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLX509CRL itemCRL(int i) throws XMLSecurityException { |
|
|
|
Element e = |
|
XMLUtils.selectDsNode( |
|
getFirstChild(), Constants._TAG_X509CRL, i); |
|
|
|
if (e != null) { |
|
return new XMLX509CRL(e, this.baseURI); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLX509Digest itemDigest(int i) throws XMLSecurityException { |
|
|
|
Element e = |
|
XMLUtils.selectDs11Node( |
|
getFirstChild(), Constants._TAG_X509DIGEST, i); |
|
|
|
if (e != null) { |
|
return new XMLX509Digest(e, this.baseURI); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**/ |
|
public Element itemUnknownElement(int i) { |
|
LOG.debug("itemUnknownElement not implemented: {}", i); |
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsIssuerSerial() { |
|
return this.lengthIssuerSerial() > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsSKI() { |
|
return this.lengthSKI() > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsSubjectName() { |
|
return this.lengthSubjectName() > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsCertificate() { |
|
return this.lengthCertificate() > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsDigest() { |
|
return this.lengthDigest() > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsCRL() { |
|
return this.lengthCRL() > 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean containsUnknownElement() { |
|
return this.lengthUnknownElement() > 0; |
|
} |
|
|
|
|
|
public String getBaseLocalName() { |
|
return Constants._TAG_X509DATA; |
|
} |
|
} |