Search in sources :

Example 1 with AccessControlListType

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;
}
Also used : KeyRefType(iso.std.iso_iec._24727.tech.schema.KeyRefType) PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) PinMarkerBuilder(org.openecard.mdlw.sal.didfactory.PinMarkerBuilder) DIDMarkerType(iso.std.iso_iec._24727.tech.schema.DIDMarkerType) DifferentialIdentityType(iso.std.iso_iec._24727.tech.schema.DifferentialIdentityType) PinCompareMarkerType(iso.std.iso_iec._24727.tech.schema.PinCompareMarkerType) DIDInfoType(iso.std.iso_iec._24727.tech.schema.DIDInfoType) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) AccessRuleType(iso.std.iso_iec._24727.tech.schema.AccessRuleType)

Example 2 with AccessControlListType

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;
}
Also used : PathType(iso.std.iso_iec._24727.tech.schema.PathType) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType) ArrayList(java.util.ArrayList) AccessRuleType(iso.std.iso_iec._24727.tech.schema.AccessRuleType)

Example 3 with AccessControlListType

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);
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) CardApplicationCreateResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationCreateResponse) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) CardApplicationList(iso.std.iso_iec._24727.tech.schema.CardApplicationList) SkipException(org.testng.SkipException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationCreate(iso.std.iso_iec._24727.tech.schema.CardApplicationCreate) Test(org.testng.annotations.Test)

Example 4 with AccessControlListType

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;
}
Also used : AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType)

Example 5 with AccessControlListType

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();
}
Also used : ACLList(iso.std.iso_iec._24727.tech.schema.ACLList) ACLListResponse(iso.std.iso_iec._24727.tech.schema.ACLListResponse)

Aggregations

AccessControlListType (iso.std.iso_iec._24727.tech.schema.AccessControlListType)6 AccessRuleType (iso.std.iso_iec._24727.tech.schema.AccessRuleType)3 ACLList (iso.std.iso_iec._24727.tech.schema.ACLList)2 ACLListResponse (iso.std.iso_iec._24727.tech.schema.ACLListResponse)2 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)2 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)2 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)2 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)2 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)2 DIDInfoType (iso.std.iso_iec._24727.tech.schema.DIDInfoType)2 DIDMarkerType (iso.std.iso_iec._24727.tech.schema.DIDMarkerType)2 DifferentialIdentityType (iso.std.iso_iec._24727.tech.schema.DifferentialIdentityType)2 CryptokiException (org.openecard.mdlw.sal.exceptions.CryptokiException)2 Test (org.testng.annotations.Test)2 AlgorithmIdentifierType (iso.std.iso_iec._24727.tech.schema.AlgorithmIdentifierType)1 AlgorithmInfoType (iso.std.iso_iec._24727.tech.schema.AlgorithmInfoType)1 CardApplicationCreate (iso.std.iso_iec._24727.tech.schema.CardApplicationCreate)1 CardApplicationCreateResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationCreateResponse)1 CardApplicationList (iso.std.iso_iec._24727.tech.schema.CardApplicationList)1 CardApplicationListResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse)1