use of iso.std.iso_iec._24727.tech.schema.AccessRuleType in project open-ecard by ecsec.
the class AndroidMarshaller method parseAccessRule.
private AccessRuleType parseAccessRule(XmlPullParser parser) throws XmlPullParserException, IOException {
AccessRuleType accessRule = new AccessRuleType();
int eventType;
do {
parser.next();
eventType = parser.getEventType();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("CardApplicationServiceName")) {
accessRule.setCardApplicationServiceName(parser.nextText());
} else if (parser.getName().equals("Action")) {
accessRule.setAction(this.parseAction(parser));
} else if (parser.getName().equals("SecurityCondition")) {
accessRule.setSecurityCondition(this.parseSecurityCondition(parser));
} else {
throw new IOException("not yet implemented");
}
}
} while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals("AccessRule")));
return accessRule;
}
use of iso.std.iso_iec._24727.tech.schema.AccessRuleType in project open-ecard by ecsec.
the class CIFCreator method createRuleTrue.
private AccessRuleType createRuleTrue(AuthorizationServiceActionName actionName) {
AccessRuleType rule = new AccessRuleType();
rule.setCardApplicationServiceName("AuthorizationService");
rule.setAction(createAction(actionName));
rule.setSecurityCondition(createTrueCond());
return rule;
}
use of iso.std.iso_iec._24727.tech.schema.AccessRuleType in project open-ecard by ecsec.
the class CIFCreator method createRuleTrue.
private AccessRuleType createRuleTrue(CryptographicServiceActionName actionName) {
AccessRuleType rule = new AccessRuleType();
rule.setCardApplicationServiceName("CryptographicService");
rule.setAction(createAction(actionName));
rule.setSecurityCondition(createTrueCond());
return rule;
}
use of iso.std.iso_iec._24727.tech.schema.AccessRuleType 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.AccessRuleType in project open-ecard by ecsec.
the class ACLResolver method getUnsatisfiedDIDs.
public List<DIDStructureType> getUnsatisfiedDIDs(TargetNameType target) throws WSException, SecurityConditionUnsatisfiable {
// get the ACL first
ACLList aclReq = new ACLList();
aclReq.setConnectionHandle(handle);
aclReq.setTargetName(target);
ACLListResponse aclRes = (ACLListResponse) dispatcher.safeDeliver(aclReq);
WSHelper.checkResult(aclRes);
List<AccessRuleType> acls = aclRes.getTargetACL().getAccessRule();
List<DIDStructureType> dids = getMissingDids(acls, target);
return dids;
}
Aggregations