use of iso.std.iso_iec._24727.tech.schema.AccessControlListType 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.AccessControlListType in project open-ecard by ecsec.
the class CIFCreator method getCertificateDatasets.
private List<DataSetInfoType> getCertificateDatasets() throws CryptokiException {
ArrayList<DataSetInfoType> datasets = new ArrayList<>();
List<MwCertificate> mwCerts = session.getCertificates();
for (MwCertificate cert : mwCerts) {
// create DataSetType and set primitive values
DataSetInfoType ds = new DataSetInfoType();
ds.setDataSetName(cert.getLabel());
PathType path = new PathType();
ds.setDataSetPath(path);
// don't care value
path.setEfIdOrPath(new byte[] { (byte) 0xFF });
// create ACLs
AccessControlListType acl = new AccessControlListType();
ds.setDataSetACL(acl);
List<AccessRuleType> rules = acl.getAccessRule();
rules.add(createRuleTrue(AuthorizationServiceActionName.ACL_LIST));
rules.add(createRuleTrue(NamedDataServiceActionName.DSI_READ));
rules.add(createRuleTrue(NamedDataServiceActionName.DSI_LIST));
rules.add(createRuleTrue(NamedDataServiceActionName.DATA_SET_SELECT));
datasets.add(ds);
}
return datasets;
}
use of iso.std.iso_iec._24727.tech.schema.AccessControlListType in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationCreate.
/**
* Test of cardApplicationCreate method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationCreate() {
System.out.println("cardApplicationCreate");
Set<CardStateEntry> cHandles = states.getMatchingEntries(new ConnectionHandleType());
byte[] appName = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
CardApplicationCreate parameters = new CardApplicationCreate();
parameters.setConnectionHandle(cHandles.iterator().next().handleCopy());
parameters.setCardApplicationName(appName);
AccessControlListType cardApplicationACL = new AccessControlListType();
parameters.setCardApplicationACL(cardApplicationACL);
CardApplicationCreateResponse result = instance.cardApplicationCreate(parameters);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// get path to esign
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
// connect to esign
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse resultConnect = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(ECardConstants.Major.OK, resultConnect.getResult().getResultMajor());
CardApplicationList cardApplicationList = new CardApplicationList();
cardApplicationList.setConnectionHandle(cHandles.iterator().next().handleCopy());
CardApplicationListResponse cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
Iterator<byte[]> it = cardApplicationListResponse.getCardApplicationNameList().getCardApplicationName().iterator();
boolean appFound = false;
try {
while (it.hasNext()) {
byte[] val = it.next();
if (Arrays.equals(val, appName)) {
appFound = true;
}
}
assertTrue(appFound);
} catch (Exception e) {
assertTrue(appFound);
System.out.println(e);
}
}
use of iso.std.iso_iec._24727.tech.schema.AccessControlListType in project open-ecard by ecsec.
the class AndroidMarshaller method parseACL.
private AccessControlListType parseACL(XmlPullParser parser, String endTag) throws XmlPullParserException, IOException {
AccessControlListType accessControlList = new AccessControlListType();
int eventType;
do {
parser.next();
eventType = parser.getEventType();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("AccessRule")) {
accessControlList.getAccessRule().add(this.parseAccessRule(parser));
}
}
} while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals(endTag)));
return accessControlList;
}
use of iso.std.iso_iec._24727.tech.schema.AccessControlListType in project open-ecard by ecsec.
the class DataSetInfo method getACL.
public AccessControlListType getACL() throws WSHelper.WSException {
ACLList req = new ACLList();
req.setConnectionHandle(didInfos.getHandle(application));
req.setTargetName(datasetNameTarget);
ACLListResponse res = (ACLListResponse) didInfos.getDispatcher().safeDeliver(req);
WSHelper.checkResult(res);
return res.getTargetACL();
}
Aggregations