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

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

The newest version!
/*     */ package org.jcp.xml.dsig.internal.dom;
/*     */ 
/*     */ import java.math.BigInteger;
/*     */ import java.security.AccessController;
/*     */ import java.security.KeyException;
/*     */ import java.security.PrivilegedAction;
/*     */ import java.security.PublicKey;
/*     */ import java.security.Security;
/*     */ import java.util.List;
/*     */ import javax.xml.crypto.MarshalException;
/*     */ import javax.xml.crypto.URIDereferencer;
/*     */ import javax.xml.crypto.XMLStructure;
/*     */ import javax.xml.crypto.dom.DOMStructure;
/*     */ import javax.xml.crypto.dsig.keyinfo.KeyInfo;
/*     */ import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
/*     */ import javax.xml.crypto.dsig.keyinfo.KeyName;
/*     */ import javax.xml.crypto.dsig.keyinfo.KeyValue;
/*     */ import javax.xml.crypto.dsig.keyinfo.PGPData;
/*     */ import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
/*     */ import javax.xml.crypto.dsig.keyinfo.X509Data;
/*     */ 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 DOMKeyInfoFactory extends KeyInfoFactory
/*     */ {
/*     */   public KeyInfo newKeyInfo(List content)
/*     */   {
/*  39 */     return newKeyInfo(content, null);
/*     */   }
/*     */ 
/*     */   public KeyInfo newKeyInfo(List content, String id) {
/*  43 */     return new DOMKeyInfo(content, id);
/*     */   }
/*     */ 
/*     */   public KeyName newKeyName(String name) {
/*  47 */     return new DOMKeyName(name);
/*     */   }
/*     */ 
/*     */   public KeyValue newKeyValue(PublicKey key) throws KeyException {
/*  51 */     return new DOMKeyValue(key);
/*     */   }
/*     */ 
/*     */   public PGPData newPGPData(byte[] keyId) {
/*  55 */     return newPGPData(keyId, null, null);
/*     */   }
/*     */ 
/*     */   public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) {
/*  59 */     return new DOMPGPData(keyId, keyPacket, other);
/*     */   }
/*     */ 
/*     */   public PGPData newPGPData(byte[] keyPacket, List other) {
/*  63 */     return new DOMPGPData(keyPacket, other);
/*     */   }
/*     */ 
/*     */   public RetrievalMethod newRetrievalMethod(String uri) {
/*  67 */     return newRetrievalMethod(uri, null, null);
/*     */   }
/*     */ 
/*     */   public RetrievalMethod newRetrievalMethod(String uri, String type, List transforms)
/*     */   {
/*  72 */     if (uri == null) {
/*  73 */       throw new NullPointerException("uri must not be null");
/*     */     }
/*  75 */     return new DOMRetrievalMethod(uri, type, transforms);
/*     */   }
/*     */ 
/*     */   public X509Data newX509Data(List content) {
/*  79 */     return new DOMX509Data(content);
/*     */   }
/*     */ 
/*     */   public X509IssuerSerial newX509IssuerSerial(String issuerName, BigInteger serialNumber)
/*     */   {
/*  84 */     return new DOMX509IssuerSerial(issuerName, serialNumber);
/*     */   }
/*     */ 
/*     */   public boolean isFeatureSupported(String feature) {
/*  88 */     if (feature == null) {
/*  89 */       throw new NullPointerException();
/*     */     }
/*  91 */     return false;
/*     */   }
/*     */ 
/*     */   public URIDereferencer getURIDereferencer()
/*     */   {
/*  96 */     return DOMURIDereferencer.INSTANCE;
/*     */   }
/*     */ 
/*     */   public KeyInfo unmarshalKeyInfo(XMLStructure xmlStructure) throws MarshalException
/*     */   {
/* 101 */     if (xmlStructure == null) {
/* 102 */       throw new NullPointerException("xmlStructure cannot be null");
/*     */     }
/* 104 */     Node node = ((DOMStructure)xmlStructure).getNode();
/*     */ 
/* 106 */     node.normalize();
/*     */ 
/* 108 */     Element element = null;
/* 109 */     if (node.getNodeType() == 9)
/* 110 */       element = ((Document)node).getDocumentElement();
/* 111 */     else if (node.getNodeType() == 1)
/* 112 */       element = (Element)node;
/*     */     else {
/* 114 */       throw new MarshalException("xmlStructure does not contain a proper Node");
/*     */     }
/*     */ 
/* 119 */     String tag = element.getLocalName();
/* 120 */     if (tag == null) {
/* 121 */       throw new MarshalException("Document implementation must support DOM Level 2 and be namespace aware");
/*     */     }
/*     */ 
/* 124 */     if (tag.equals("KeyInfo")) {
/* 125 */       return new DOMKeyInfo(element, null);
/*     */     }
/* 127 */     throw new MarshalException("invalid KeyInfo tag: " + tag);
/*     */   }
/*     */ 
/*     */   static
/*     */   {
/*  28 */     AccessController.doPrivileged(new PrivilegedAction() {
/*     */       public Object run() {
/*  30 */         Security.addProvider(new XMLDSigRI());
/*  31 */         return null;
/*     */       }
/*     */     });
/*     */   }
/*     */ }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy