use of iso.std.iso_iec._24727.tech.schema.DIDMarkerType in project open-ecard by ecsec.
the class CIFCreator method createPinDID.
private DIDInfoType createPinDID() throws WSMarshallerException {
LOG.debug("Creating PinCompare DID object.");
DIDInfoType di = new DIDInfoType();
// create differential identity
DifferentialIdentityType did = new DifferentialIdentityType();
di.setDifferentialIdentity(did);
String didName = PIN_NAME;
did.setDIDName(didName);
did.setDIDProtocol("urn:oid:1.3.162.15480.3.0.9");
did.setDIDScope(DIDScopeType.GLOBAL);
// create pin compare marker
PinMarkerBuilder markerBuilder = new PinMarkerBuilder();
KeyRefType kr = new KeyRefType();
// value is irrelevant
kr.setKeyRef(new byte[] { 0x01 });
markerBuilder.setPinRef(kr);
try {
PasswordAttributesType pw = new PasswordAttributesType();
MwToken tok = session.getSlot().getTokenInfo();
long minPinLen = tok.getUlMinPinLen();
long maxPinLen = tok.getUlMinPinLen();
pw.setMinLength(BigInteger.valueOf(minPinLen));
pw.setMaxLength(BigInteger.valueOf(maxPinLen));
markerBuilder.setPwAttributes(pw);
} catch (CryptokiException | NullPointerException ex) {
LOG.warn("Unable to read min and max PIN length from middleware.");
}
// wrap pin compare marker and add to parent
PinCompareMarkerType marker = markerBuilder.build();
DIDMarkerType markerWrapper = new DIDMarkerType();
markerWrapper.setPinCompareMarker(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_LIST));
rules.add(createRuleTrue(DifferentialIdentityServiceActionName.DID_GET));
rules.add(createRuleTrue(DifferentialIdentityServiceActionName.DID_AUTHENTICATE));
return di;
}
use of iso.std.iso_iec._24727.tech.schema.DIDMarkerType in project open-ecard by ecsec.
the class AndroidMarshaller method parseDIDMarkerType.
private DIDMarkerType parseDIDMarkerType(XmlPullParser parser) throws XmlPullParserException, IOException {
DIDMarkerType didMarker = new DIDMarkerType();
int eventType;
do {
parser.next();
eventType = parser.getEventType();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("PACEMarker")) {
didMarker.setPACEMarker((PACEMarkerType) this.parseMarker(parser, PACEMarkerType.class));
} else if (parser.getName().equals("TAMarker")) {
didMarker.setTAMarker((TAMarkerType) this.parseMarker(parser, TAMarkerType.class));
} else if (parser.getName().equals("CAMarker")) {
didMarker.setCAMarker((CAMarkerType) this.parseMarker(parser, CAMarkerType.class));
} else if (parser.getName().equals("RIMarker")) {
didMarker.setRIMarker((RIMarkerType) this.parseMarker(parser, RIMarkerType.class));
} else if (parser.getName().equals("CryptoMarker")) {
didMarker.setCryptoMarker((CryptoMarkerType) this.parseMarker(parser, CryptoMarkerType.class));
} else if (parser.getName().equals("PinCompareMarker")) {
didMarker.setPinCompareMarker((PinCompareMarkerType) this.parseMarker(parser, PinCompareMarkerType.class));
} else if (parser.getName().equals("RSAAuthMarker")) {
didMarker.setRSAAuthMarker((RSAAuthMarkerType) this.parseMarker(parser, RSAAuthMarkerType.class));
} else if (parser.getName().equals("MutualAuthMarker")) {
didMarker.setMutualAuthMarker((MutualAuthMarkerType) this.parseMarker(parser, MutualAuthMarkerType.class));
} else if (parser.getName().equals("EACMarker")) {
didMarker.setEACMarker((EACMarkerType) this.parseMarker(parser, EACMarkerType.class));
} else {
LOG.error(parser.getName() + " not yet implemented");
}
}
} while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals("DIDMarker")));
return didMarker;
}
use of iso.std.iso_iec._24727.tech.schema.DIDMarkerType in project open-ecard by ecsec.
the class CardInfoWrapper method getDIDStructure.
/**
* @param didName Name of the DID to get the structure for
* @param cardApplication Identifier of the card application
* @return DIDStructure for the specified didName and card application or null, if no such did exists.
*/
public DIDStructureType getDIDStructure(String didName, byte[] cardApplication) {
DIDInfoType didInfo = this.getDIDInfo(didName, cardApplication);
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;
}
use of iso.std.iso_iec._24727.tech.schema.DIDMarkerType 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.DIDMarkerType 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