1 2 18 package com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations; 19 20 21 22 import java.security.PublicKey ; 23 import java.security.cert.X509Certificate ; 24 25 26 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 27 import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue; 28 import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi; 29 import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver; 30 import com.sun.org.apache.xml.internal.security.utils.Constants; 31 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; 32 import org.w3c.dom.Element ; 33 34 35 39 public class RSAKeyValueResolver extends KeyResolverSpi { 40 41 42 static java.util.logging.Logger log = 43 java.util.logging.Logger.getLogger( 44 RSAKeyValueResolver.class.getName()); 45 46 47 private Element _rsaKeyElement = null; 48 49 50 public boolean engineCanResolve(Element element, String BaseURI, 51 StorageResolver storage) { 52 if (true) 53 if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName()); 54 55 if (element == null) { 56 return false; 57 } 58 59 boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element, 60 Constants._TAG_KEYVALUE); 61 boolean isRSAKeyValue = XMLUtils.elementIsInSignatureSpace(element, 62 Constants._TAG_RSAKEYVALUE); 63 64 if (isKeyValue) { 65 this._rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(), 66 Constants._TAG_RSAKEYVALUE, 0); 67 68 if (this._rsaKeyElement != null) { 69 return true; 70 } 71 } else if (isRSAKeyValue) { 72 73 this._rsaKeyElement = element; 76 77 return true; 78 } 79 80 return false; 81 } 82 83 84 public PublicKey engineResolvePublicKey( 85 Element element, String BaseURI, StorageResolver storage) { 86 87 if (this._rsaKeyElement == null) { 88 boolean weCanResolve = this.engineCanResolve(element, BaseURI, 89 storage); 90 91 if (!weCanResolve || (this._rsaKeyElement == null)) { 92 return null; 93 } 94 } 95 96 try { 97 RSAKeyValue rsaKeyValue = new RSAKeyValue(this._rsaKeyElement, 98 BaseURI); 99 100 return rsaKeyValue.getPublicKey(); 101 } catch (XMLSecurityException ex) { 102 if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); 103 } 104 105 return null; 106 } 107 108 109 public X509Certificate engineResolveX509Certificate( 110 Element element, String BaseURI, StorageResolver storage) { 111 return null; 112 } 113 114 115 public javax.crypto.SecretKey engineResolveSecretKey( 116 Element element, String BaseURI, StorageResolver storage) { 117 return null; 118 } 119 } 120 | Popular Tags |