/** * Method engineResolvePublicKey * * @inheritDoc * @param element * @param BaseURI * @param storage */ public PublicKey engineLookupAndResolvePublicKey( Element element, String BaseURI, StorageResolver storage) { if (!XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_RETRIEVALMETHOD)) { return null; } try { // Create a retrieval method over the given element RetrievalMethod rm = new RetrievalMethod(element, BaseURI); String type = rm.getType(); XMLSignatureInput resource = resolveInput(rm, BaseURI); if (RetrievalMethod.TYPE_RAWX509.equals(type)) { // a raw certificate, direct parsing is done! X509Certificate cert = getRawCertificate(resource); if (cert != null) { return cert.getPublicKey(); } return null; } ; Element e = obtainRefrenceElement(resource); return resolveKey(e, BaseURI, storage); } catch (XMLSecurityException ex) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } catch (CertificateException ex) { log.log(java.util.logging.Level.FINE, "CertificateException", ex); } catch (IOException ex) { log.log(java.util.logging.Level.FINE, "IOException", ex); } catch (ParserConfigurationException e) { log.log(java.util.logging.Level.FINE, "ParserConfigurationException", e); } catch (SAXException e) { log.log(java.util.logging.Level.FINE, "SAXException", e); } return null; }
/** * Method engineResolveX509Certificate * * @inheritDoc * @param element * @param BaseURI * @param storage */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage) { if (!XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_RETRIEVALMETHOD)) { return null; } try { RetrievalMethod rm = new RetrievalMethod(element, BaseURI); String type = rm.getType(); XMLSignatureInput resource = resolveInput(rm, BaseURI); if (RetrievalMethod.TYPE_RAWX509.equals(type)) { X509Certificate cert = getRawCertificate(resource); return cert; } Element e = obtainRefrenceElement(resource); return resolveCertificate(e, BaseURI, storage); } catch (XMLSecurityException ex) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } catch (CertificateException ex) { log.log(java.util.logging.Level.FINE, "CertificateException", ex); } catch (IOException ex) { log.log(java.util.logging.Level.FINE, "IOException", ex); } catch (ParserConfigurationException e) { log.log(java.util.logging.Level.FINE, "ParserConfigurationException", e); } catch (SAXException e) { log.log(java.util.logging.Level.FINE, "SAXException", e); } return null; }