Search in sources :

Example 6 with AccessControlListType

use of iso.std.iso_iec._24727.tech.schema.AccessControlListType in project open-ecard by ecsec.

the class DidInfo method getACL.

public AccessControlListType getACL() throws WSHelper.WSException {
    ACLList req = new ACLList();
    req.setConnectionHandle(didInfos.getHandle(application));
    req.setTargetName(didTarget);
    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)

Example 7 with AccessControlListType

use of iso.std.iso_iec._24727.tech.schema.AccessControlListType in project open-ecard by ecsec.

the class TinySALTest method testDataSetCreate.

/**
 * Test of dataSetCreate method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDataSetCreate() {
    System.out.println("dataSetCreate");
    DataSetCreate parameters = new DataSetCreate();
    // 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 result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    AccessControlListType accessControlList = new AccessControlListType();
    parameters.setConnectionHandle(result.getConnectionHandle());
    String dataSetName = "DataSetTest";
    parameters.setDataSetName(dataSetName);
    parameters.setDataSetACL(accessControlList);
    DataSetCreateResponse resultDataSetCreate = instance.dataSetCreate(parameters);
    assertEquals(ECardConstants.Major.OK, resultDataSetCreate.getResult().getResultMajor());
    // list datasets of esign
    DataSetList dataSetList = new DataSetList();
    dataSetList.setConnectionHandle(result.getConnectionHandle());
    DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
    Iterator<String> it = dataSetListResponse.getDataSetNameList().getDataSetName().iterator();
    boolean appFound = false;
    while (it.hasNext()) {
        String val = it.next();
        if (val.equals(dataSetName)) {
            appFound = true;
        }
    }
    assertTrue(appFound);
    assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
}
Also used : DataSetCreateResponse(iso.std.iso_iec._24727.tech.schema.DataSetCreateResponse) DataSetCreate(iso.std.iso_iec._24727.tech.schema.DataSetCreate) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) Test(org.testng.annotations.Test)

Example 8 with AccessControlListType

use of iso.std.iso_iec._24727.tech.schema.AccessControlListType 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;
}
Also used : CryptoMarkerBuilder(org.openecard.mdlw.sal.didfactory.CryptoMarkerBuilder) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) CryptoMarkerType(iso.std.iso_iec._24727.tech.schema.CryptoMarkerType) CertificateRefType(iso.std.iso_iec._24727.tech.schema.CertificateRefType) DIDMarkerType(iso.std.iso_iec._24727.tech.schema.DIDMarkerType) DifferentialIdentityType(iso.std.iso_iec._24727.tech.schema.DifferentialIdentityType) DIDInfoType(iso.std.iso_iec._24727.tech.schema.DIDInfoType) AlgorithmInfoType(iso.std.iso_iec._24727.tech.schema.AlgorithmInfoType) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) AlgorithmIdentifierType(iso.std.iso_iec._24727.tech.schema.AlgorithmIdentifierType) AccessRuleType(iso.std.iso_iec._24727.tech.schema.AccessRuleType)

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