use of iso.std.iso_iec._24727.tech.schema.DIDInfoType in project open-ecard by ecsec.
the class CIFCreator method createCryptoDID.
private DIDInfoType createCryptoDID(List<MwCertificate> mwCerts, SignatureAlgorithms sigalg) throws WSMarshallerException, CryptokiException {
LOG.debug("Creating Crypto DID object.");
DIDInfoType di = new DIDInfoType();
String keyLabel = mwCerts.get(0).getLabel();
// create differential identity
DifferentialIdentityType did = new DifferentialIdentityType();
di.setDifferentialIdentity(did);
String didName = keyLabel + "_" + mwCerts.get(0).getLabel() + "_" + sigalg.getJcaAlg();
LOG.debug("DIDName: {}", didName);
did.setDIDName(didName);
did.setDIDProtocol("urn:oid:1.3.162.15480.3.0.25");
did.setDIDScope(DIDScopeType.LOCAL);
// create crypto marker
CryptoMarkerBuilder markerBuilder = new CryptoMarkerBuilder();
// add AlgorithmInfo
AlgorithmInfoType algInfo = new AlgorithmInfoType();
algInfo.setAlgorithm(sigalg.getJcaAlg());
AlgorithmIdentifierType algIdentifier = new AlgorithmIdentifierType();
algIdentifier.setAlgorithm(sigalg.getAlgId());
algInfo.setAlgorithmIdentifier(algIdentifier);
algInfo.getSupportedOperations().add("Compute-signature");
markerBuilder.setAlgInfo(algInfo);
markerBuilder.setLegacyKeyname(keyLabel);
// add certificates
for (MwCertificate nextCert : mwCerts) {
try {
CertificateRefType certRef = new CertificateRefType();
certRef.setDataSetName(nextCert.getLabel());
markerBuilder.getCertRefs().add(certRef);
} catch (CryptokiException ex) {
LOG.warn("Certificate chain is not complete.");
break;
}
}
// wrap crypto marker and add to parent
CryptoMarkerType marker = markerBuilder.build();
DIDMarkerType markerWrapper = new DIDMarkerType();
markerWrapper.setCryptoMarker(marker);
did.setDIDMarker(markerWrapper);
// create acl
AccessControlListType acl = new AccessControlListType();
di.setDIDACL(acl);
List<AccessRuleType> rules = acl.getAccessRule();
rules.add(createRuleTrue(AuthorizationServiceActionName.ACL_LIST));
rules.add(createRuleTrue(DifferentialIdentityServiceActionName.DID_GET));
// create sign rule with PIN reference
AccessRuleType signRule = createRuleTrue(CryptographicServiceActionName.SIGN);
signRule.setSecurityCondition(createDidCond(PIN_NAME));
rules.add(signRule);
return di;
}
use of iso.std.iso_iec._24727.tech.schema.DIDInfoType in project open-ecard by ecsec.
the class CardInfoWrapper method getDIDStructure.
/**
* @param didName Name of the DID to get the structure for
* @param didScope Scope of the DID
* @return DIDStructure for the specified didName and card application or null, if no such did exists.
*/
public DIDStructureType getDIDStructure(String didName, DIDScopeType didScope) {
DIDInfoType didInfo = this.getDIDInfo(didName, didScope);
if (didInfo == null) {
return null;
}
DIDStructureType didStructure = new DIDStructureType();
didStructure.setDIDName(didInfo.getDifferentialIdentity().getDIDName());
didStructure.setDIDScope(didInfo.getDifferentialIdentity().getDIDScope());
if (didStructure.getDIDScope() == null) {
// no scope is equal to local
didStructure.setDIDScope(DIDScopeType.LOCAL);
}
DIDMarkerType didMarker = didInfo.getDifferentialIdentity().getDIDMarker();
if (didMarker.getCAMarker() != null) {
didStructure.setDIDMarker(didMarker.getCAMarker());
} else if (didMarker.getCryptoMarker() != null) {
didStructure.setDIDMarker(didMarker.getCryptoMarker());
} else if (didMarker.getEACMarker() != null) {
didStructure.setDIDMarker(didMarker.getEACMarker());
} else if (didMarker.getMutualAuthMarker() != null) {
didStructure.setDIDMarker(didMarker.getMutualAuthMarker());
} else if (didMarker.getPACEMarker() != null) {
didStructure.setDIDMarker(didMarker.getPACEMarker());
} else if (didMarker.getPinCompareMarker() != null) {
didStructure.setDIDMarker(didMarker.getPinCompareMarker());
} else if (didMarker.getRIMarker() != null) {
didStructure.setDIDMarker(didMarker.getRIMarker());
} else if (didMarker.getRSAAuthMarker() != null) {
didStructure.setDIDMarker(didMarker.getRSAAuthMarker());
} else if (didMarker.getTAMarker() != null) {
didStructure.setDIDMarker(didMarker.getTAMarker());
}
didStructure.setDIDQualifier(didInfo.getDifferentialIdentity().getDIDQualifier());
return didStructure;
}
Aggregations