All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jcp.xml.dsig.internal.dom.DOMX509IssuerSerial Maven / Gradle / Ivy

The newest version!
/*     */ package org.jcp.xml.dsig.internal.dom;
/*     */ 
/*     */ import java.math.BigInteger;
/*     */ import javax.security.auth.x500.X500Principal;
/*     */ import javax.xml.crypto.MarshalException;
/*     */ import javax.xml.crypto.dom.DOMCryptoContext;
/*     */ import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
/*     */ import org.w3c.dom.Document;
/*     */ import org.w3c.dom.Element;
/*     */ import org.w3c.dom.Node;
/*     */ 
/*     */ public final class DOMX509IssuerSerial extends DOMStructure
/*     */   implements X509IssuerSerial
/*     */ {
/*     */   private final String issuerName;
/*     */   private final BigInteger serialNumber;
/*     */ 
/*     */   public DOMX509IssuerSerial(String issuerName, BigInteger serialNumber)
/*     */   {
/*  44 */     if (issuerName == null) {
/*  45 */       throw new NullPointerException("issuerName cannot be null");
/*     */     }
/*  47 */     if (serialNumber == null) {
/*  48 */       throw new NullPointerException("serialNumber cannot be null");
/*     */     }
/*     */ 
/*  51 */     new X500Principal(issuerName);
/*  52 */     this.issuerName = issuerName;
/*  53 */     this.serialNumber = serialNumber;
/*     */   }
/*     */ 
/*     */   public DOMX509IssuerSerial(Element isElem)
/*     */   {
/*  62 */     Element iNElem = DOMUtils.getFirstChildElement(isElem);
/*  63 */     Element sNElem = DOMUtils.getNextSiblingElement(iNElem);
/*  64 */     this.issuerName = iNElem.getFirstChild().getNodeValue();
/*  65 */     this.serialNumber = new BigInteger(sNElem.getFirstChild().getNodeValue());
/*     */   }
/*     */ 
/*     */   public String getIssuerName() {
/*  69 */     return this.issuerName;
/*     */   }
/*     */ 
/*     */   public BigInteger getSerialNumber() {
/*  73 */     return this.serialNumber;
/*     */   }
/*     */ 
/*     */   public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException
/*     */   {
/*  78 */     Document ownerDoc = DOMUtils.getOwnerDocument(parent);
/*     */ 
/*  80 */     Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial", "http://www.w3.org/2000/09/xmldsig#", dsPrefix);
/*     */ 
/*  82 */     Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName", "http://www.w3.org/2000/09/xmldsig#", dsPrefix);
/*     */ 
/*  84 */     Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber", "http://www.w3.org/2000/09/xmldsig#", dsPrefix);
/*     */ 
/*  86 */     inElem.appendChild(ownerDoc.createTextNode(this.issuerName));
/*  87 */     snElem.appendChild(ownerDoc.createTextNode(this.serialNumber.toString()));
/*  88 */     isElem.appendChild(inElem);
/*  89 */     isElem.appendChild(snElem);
/*  90 */     parent.appendChild(isElem);
/*     */   }
/*     */ 
/*     */   public boolean equals(Object obj) {
/*  94 */     if (this == obj) {
/*  95 */       return true;
/*     */     }
/*  97 */     if (!(obj instanceof X509IssuerSerial)) {
/*  98 */       return false;
/*     */     }
/* 100 */     X509IssuerSerial ois = (X509IssuerSerial)obj;
/* 101 */     return (this.issuerName.equals(ois.getIssuerName())) && (this.serialNumber.equals(ois.getSerialNumber()));
/*     */   }
/*     */ }

/* Location:           E:\HYN\Java\trunk\ref\lib-dep\xmldsig\xmldsig.jar
 * Qualified Name:     org.jcp.xml.dsig.internal.dom.DOMX509IssuerSerial
 * JD-Core Version:    0.6.2
 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy