List of usage examples for javax.xml.crypto KeySelectorResult KeySelectorResult
KeySelectorResult
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.DocumentFactory.java
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { Iterator ki = keyInfo.getContent().iterator(); while (ki.hasNext()) { XMLStructure info = (XMLStructure) ki.next(); if (!(info instanceof X509Data)) continue; X509Data x509Data = (X509Data) info; Iterator xi = x509Data.getContent().iterator(); while (xi.hasNext()) { Object o = xi.next(); if (!(o instanceof X509Certificate)) continue; final PublicKey key = ((X509Certificate) o).getPublicKey(); // Make sure the algorithm is compatible // with the method. if (algEquals(method.getAlgorithm(), key.getAlgorithm())) { return new KeySelectorResult() { public Key getKey() { return key; }// ww w . j a v a 2 s. co m }; } } } Logger.getLogger(this.getClass()).error("No Key found"); throw new KeySelectorException("No key found!"); }