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

javax.xml.crypto.dom.DOMCryptoContext Maven / Gradle / Ivy

The newest version!
/*     */ package javax.xml.crypto.dom;
/*     */ 
/*     */ import java.net.URI;
/*     */ import java.util.Collections;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ import javax.xml.crypto.KeySelector;
/*     */ import javax.xml.crypto.URIDereferencer;
/*     */ import javax.xml.crypto.XMLCryptoContext;
/*     */ import org.w3c.dom.Element;
/*     */ 
/*     */ public class DOMCryptoContext
/*     */   implements XMLCryptoContext
/*     */ {
/*  28 */   private HashMap nsMap = new HashMap();
/*  29 */   private HashMap idMap = new HashMap();
/*  30 */   private HashMap objMap = new HashMap();
/*     */   private String baseURI;
/*     */   private KeySelector ks;
/*     */   private URIDereferencer dereferencer;
/*  34 */   private HashMap propMap = new HashMap();
/*     */   private String defaultPrefix;
/*     */ 
/*     */   public String getNamespacePrefix(String namespaceURI, String defaultPrefix)
/*     */   {
/*  51 */     if (namespaceURI == null) {
/*  52 */       throw new NullPointerException("namespaceURI cannot be null");
/*     */     }
/*  54 */     String prefix = (String)this.nsMap.get(namespaceURI);
/*  55 */     return prefix != null ? prefix : defaultPrefix;
/*     */   }
/*     */ 
/*     */   public String putNamespacePrefix(String namespaceURI, String prefix)
/*     */   {
/*  65 */     if (namespaceURI == null) {
/*  66 */       throw new NullPointerException("namespaceURI is null");
/*     */     }
/*  68 */     return (String)this.nsMap.put(namespaceURI, prefix);
/*     */   }
/*     */ 
/*     */   public String getDefaultNamespacePrefix() {
/*  72 */     return this.defaultPrefix;
/*     */   }
/*     */ 
/*     */   public void setDefaultNamespacePrefix(String defaultPrefix) {
/*  76 */     this.defaultPrefix = defaultPrefix;
/*     */   }
/*     */ 
/*     */   public String getBaseURI() {
/*  80 */     return this.baseURI;
/*     */   }
/*     */ 
/*     */   public void setBaseURI(String baseURI)
/*     */   {
/*  87 */     if (baseURI != null) {
/*  88 */       URI.create(baseURI);
/*     */     }
/*  90 */     this.baseURI = baseURI;
/*     */   }
/*     */ 
/*     */   public URIDereferencer getURIDereferencer() {
/*  94 */     return this.dereferencer;
/*     */   }
/*     */ 
/*     */   public void setURIDereferencer(URIDereferencer dereferencer) {
/*  98 */     this.dereferencer = dereferencer;
/*     */   }
/*     */ 
/*     */   public Object getProperty(String name)
/*     */   {
/* 108 */     if (name == null) {
/* 109 */       throw new NullPointerException("name is null");
/*     */     }
/* 111 */     return this.propMap.get(name);
/*     */   }
/*     */ 
/*     */   public Object setProperty(String name, Object value)
/*     */   {
/* 121 */     if (name == null) {
/* 122 */       throw new NullPointerException("name is null");
/*     */     }
/* 124 */     return this.propMap.put(name, value);
/*     */   }
/*     */ 
/*     */   public KeySelector getKeySelector() {
/* 128 */     return this.ks;
/*     */   }
/*     */ 
/*     */   public void setKeySelector(KeySelector ks) {
/* 132 */     this.ks = ks;
/*     */   }
/*     */ 
/*     */   public Element getElementById(String idValue)
/*     */   {
/* 148 */     if (idValue == null) {
/* 149 */       throw new NullPointerException("idValue is null");
/*     */     }
/* 151 */     return (Element)this.idMap.get(idValue);
/*     */   }
/*     */ 
/*     */   public void setIdAttributeNS(Element element, String namespaceURI, String localName)
/*     */   {
/* 174 */     if (element == null) {
/* 175 */       throw new NullPointerException("element is null");
/*     */     }
/* 177 */     if (localName == null) {
/* 178 */       throw new NullPointerException("localName is null");
/*     */     }
/* 180 */     String idValue = element.getAttributeNS(namespaceURI, localName);
/* 181 */     if ((idValue == null) || (idValue.length() == 0)) {
/* 182 */       throw new IllegalArgumentException(localName + " is not an " + "attribute");
/*     */     }
/*     */ 
/* 185 */     this.idMap.put(idValue, element);
/*     */   }
/*     */ 
/*     */   public Iterator iterator()
/*     */   {
/* 201 */     return Collections.unmodifiableMap(this.idMap).entrySet().iterator();
/*     */   }
/*     */ 
/*     */   public Object get(Object key)
/*     */   {
/* 209 */     return this.objMap.get(key);
/*     */   }
/*     */ 
/*     */   public Object put(Object key, Object value)
/*     */   {
/* 219 */     return this.objMap.put(key, value);
/*     */   }
/*     */ }

/* Location:           E:\HYN\Java\trunk\ref\lib-dep\xmldsig\xmldsig.jar
 * Qualified Name:     javax.xml.crypto.dom.DOMCryptoContext
 * JD-Core Version:    0.6.2
 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy