use of org.openecard.crypto.common.sal.did.DataSetInfo in project open-ecard by ecsec.
the class ListTokens method determineTokenFeatures.
private boolean determineTokenFeatures(TokenInfoType next) {
try {
// request the missing information
ConnectionHandleType h = new ConnectionHandleType();
h.setSlotHandle(next.getConnectionHandle().getSlotHandle());
DidInfos dids = new DidInfos(dispatcher, null, h);
List<DidInfo> didInfos = dids.getDidInfos();
boolean needsDidPin = false;
boolean needsCertPin = false;
TreeSet<String> algorithms = new TreeSet<>();
// find out everything about the token
for (DidInfo didInfo : didInfos) {
if (didInfo.isCryptoDid()) {
// only evaluate if we have no positive match yet
if (!needsDidPin) {
needsDidPin |= didInfo.needsPin();
}
// only evaluate if we have no positive match yet
if (!needsCertPin) {
for (DataSetInfo dataSetinfo : didInfo.getRelatedDataSets()) {
needsCertPin |= dataSetinfo.needsPin();
}
}
// get the algorithm of the did
AlgorithmInfoType algInfo = didInfo.getGenericCryptoMarker().getAlgorithmInfo();
AlgorithmIdentifierType algId = algInfo.getAlgorithmIdentifier();
String alg = algInfo.getAlgorithm();
try {
if (algId != null && algId.getAlgorithm() != null) {
String jcaName = AllowedSignatureAlgorithms.algIdtoJcaName(algId.getAlgorithm());
algorithms.add(jcaName);
}
} catch (UnsupportedAlgorithmException ex) {
// ignore and fall back to Algorithm field
if (alg != null && !alg.isEmpty() && AllowedSignatureAlgorithms.isKnownJcaAlgorithm(alg)) {
algorithms.add(alg);
}
}
}
}
next.setNeedsPinForCertAccess(needsCertPin);
next.setNeedsPinForPrivateKeyAccess(needsDidPin);
next.getAlgorithm().addAll(algorithms);
// finished evaluation everything successfully
return true;
} catch (NoSuchDid | WSHelper.WSException | SecurityConditionUnsatisfiable ex) {
LOG.error("Failed to evaluate DID.", ex);
}
// there has been an error
return false;
}
use of org.openecard.crypto.common.sal.did.DataSetInfo in project open-ecard by ecsec.
the class SmartCardCredentialFactory method isCertNeedsPin.
private boolean isCertNeedsPin(DidInfo info) throws WSHelper.WSException, SecurityConditionUnsatisfiable {
boolean needsPin = false;
List<DataSetInfo> dsis = info.getRelatedDataSets();
for (DataSetInfo dsi : dsis) {
needsPin = needsPin && dsi.needsPin();
}
return needsPin;
}
Aggregations