KeyName keyName = keyInfo.itemKeyName(0);
if (keyName != null) {
aliases = new String[] { keyName.getKeyName() };
}
} catch (XMLSecurityException xme) {
throw new XKMSException(xme);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("No SubjectDN is specified");
}
} else {
aliases = getAliasesForDN(identifer);
}
byte[] skiValue = getSKIValue(keybinding);
if (skiValue != null) {
String alias = getAliasForX509Cert(skiValue);
if (alias != null) {
aliases = new String[] { alias };
}
}
if (aliases == null || aliases.length == 0) {
throw new XKMSException("KeyNotFound");
}
List keyUsage = keybinding.getKeyUsage();
boolean digitalSigning = keyUsage.contains(KeyUsage.SIGNATURE);
boolean dataEncryption = keyUsage.contains(KeyUsage.ENCRYPTION);
List list = new ArrayList();
for (int i = 0; i < aliases.length; i++) {
String alias = aliases[i];
X509Certificate cert = getCertificate(alias);
if (cert != null) {
boolean[] ku = cert.getKeyUsage();
if (digitalSigning && !ku[0]) {
continue;
}
if (dataEncryption && !ku[3]) {
continue;
}
list.add(alias);
}
}
if (list.isEmpty()) {
throw new XKMSException(XKMSException.NO_MATCH, "KeyNotFound");
}
LocateResult result = XKMSUtil.createLocateResult();
buildResultType((RequestAbstractType) locate, (ResultType) result);