}
Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory()
.getUnmarshaller(KeyInfo.DEFAULT_ELEMENT_NAME);
if (unmarshaller == null) {
throw new SecurityPolicyException("Could not obtain a KeyInfo unmarshaller");
}
ByteArrayInputStream is = new ByteArrayInputStream(Base64.decode(kiBase64));
KeyInfo keyInfo = null;
try {
Document doc = parser.parse(is);
keyInfo = (KeyInfo) unmarshaller.unmarshall(doc.getDocumentElement());
} catch (XMLParserException e) {
log.warn("Error parsing KeyInfo data", e);
throw new SecurityPolicyException("Error parsing KeyInfo data", e);
} catch (UnmarshallingException e) {
log.warn("Error unmarshalling KeyInfo data", e);
throw new SecurityPolicyException("Error unmarshalling KeyInfo data", e);
}
if (keyInfo == null) {
log.warn("Could not successfully extract KeyInfo object from the form control data");
return null;
}
List<Credential> credentials = new ArrayList<Credential>();
CriteriaSet criteriaSet = new CriteriaSet(new KeyInfoCriteria(keyInfo));
try {
for (Credential cred : keyInfoResolver.resolve(criteriaSet)) {
credentials.add(cred);
}
} catch (SecurityException e) {
log.warn("Error resolving credentials from KeyInfo", e);
throw new SecurityPolicyException("Error resolving credentials from KeyInfo", e);
}
return credentials;
}