1 17 package com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations; 18 19 20 21 import java.security.PublicKey ; 22 import java.security.cert.X509Certificate ; 23 24 25 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 26 import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue; 27 import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi; 28 import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver; 29 import com.sun.org.apache.xml.internal.security.utils.Constants; 30 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; 31 import org.w3c.dom.Element ; 32 33 34 38 public class DSAKeyValueResolver extends KeyResolverSpi { 39 40 41 private Element _dsaKeyElement = null; 42 43 44 public boolean engineCanResolve(Element element, String BaseURI, 45 StorageResolver storage) { 46 47 if (element == null) { 48 return false; 49 } 50 51 boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element, 52 Constants._TAG_KEYVALUE); 53 boolean isDSAKeyValue = XMLUtils.elementIsInSignatureSpace(element, 54 Constants._TAG_DSAKEYVALUE); 55 56 if (isKeyValue) { 57 58 this._dsaKeyElement = 59 XMLUtils.selectDsNode(element.getFirstChild(),Constants._TAG_DSAKEYVALUE,0); 60 61 if (this._dsaKeyElement != null) { 62 return true; 63 } 64 } else if (isDSAKeyValue) { 65 66 this._dsaKeyElement = element; 69 70 return true; 71 } 72 73 return false; 74 } 75 76 84 public PublicKey engineResolvePublicKey( 85 Element element, String BaseURI, StorageResolver storage) { 86 87 if (this._dsaKeyElement == null) { 88 boolean weCanResolve = this.engineCanResolve(element, BaseURI, 89 storage); 90 91 if (!weCanResolve || (this._dsaKeyElement == null)) { 92 return null; 93 } 94 } 95 96 try { 97 DSAKeyValue dsaKeyValue = new DSAKeyValue(this._dsaKeyElement, 98 BaseURI); 99 PublicKey pk = dsaKeyValue.getPublicKey(); 100 101 return pk; 102 } catch (XMLSecurityException ex) { 103 } 105 106 return null; 107 } 108 109 110 111 public X509Certificate engineResolveX509Certificate( 112 Element element, String BaseURI, StorageResolver storage) { 113 return null; 114 } 115 116 117 public javax.crypto.SecretKey engineResolveSecretKey( 118 Element element, String BaseURI, StorageResolver storage){ 119 return null; 120 } 121 } 122 | Popular Tags |