Search in sources :

Example 1 with PathType

use of iso.std.iso_iec._24727.tech.schema.PathType 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 2 with PathType

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

the class DatasetInfoCrerator method create.

public DataSetInfoType create() {
    DataSetInfoType dsit = new DataSetInfoType();
    dsit.setDataSetName(datasetName);
    dsit.setDataSetACL(acl);
    PathType pt = new PathType();
    pt.setEfIdOrPath(efIdOrPath);
    dsit.setDataSetPath(pt);
    return dsit;
}
Also used : PathType(iso.std.iso_iec._24727.tech.schema.PathType) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType)

Example 3 with PathType

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

the class TinySALTest method testDsiCreate.

/**
 * Test of dsiCreate method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDsiCreate() {
    System.out.println("dsiCreate");
    // 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());
    // list datasets of esign
    DataSetList dataSetList = new DataSetList();
    dataSetList.setConnectionHandle(result.getConnectionHandle());
    DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
    Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
    assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
    String dataSetName = dataSetListResponse.getDataSetNameList().getDataSetName().get(0);
    byte[] dsiContent = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
    String dsiName = "DsiTest";
    PathType dsiPath = new PathType();
    byte[] dsiEF = { (byte) 0x03, (byte) 0x00 };
    dsiPath.setEfIdOrPath(dsiEF);
    DSICreate parameters = new DSICreate();
    parameters.setConnectionHandle(result.getConnectionHandle());
    parameters.setDSIContent(dsiContent);
    parameters.setDSIName(dsiName);
    DSICreateResponse resultDSICreate = instance.dsiCreate(parameters);
    assertEquals(ECardConstants.Major.OK, resultDSICreate.getResult().getResultMajor());
    // list DSIs of DataSetName
    DSIList parametersDSI = new DSIList();
    parametersDSI.setConnectionHandle(result.getConnectionHandle());
    DSIListResponse resultDSIList = instance.dsiList(parametersDSI);
    assertEquals(ECardConstants.Major.OK, resultDSIList.getResult().getResultMajor());
    // try to find new DSI
    Iterator<String> it = resultDSIList.getDSINameList().getDSIName().iterator();
    boolean dsiFound = false;
    while (it.hasNext()) {
        String val = it.next();
        if (val.equals(dsiName)) {
            dsiFound = true;
        }
    }
    assertTrue(dsiFound);
}
Also used : DSICreateResponse(iso.std.iso_iec._24727.tech.schema.DSICreateResponse) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) DSIList(iso.std.iso_iec._24727.tech.schema.DSIList) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) DSIListResponse(iso.std.iso_iec._24727.tech.schema.DSIListResponse) PathType(iso.std.iso_iec._24727.tech.schema.PathType) 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) DSICreate(iso.std.iso_iec._24727.tech.schema.DSICreate) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) Test(org.testng.annotations.Test)

Example 4 with PathType

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

the class AndroidMarshaller method parseDataSetPath.

private PathType parseDataSetPath(XmlPullParser parser) throws XmlPullParserException, IOException {
    PathType path = new PathType();
    int eventType;
    do {
        parser.next();
        eventType = parser.getEventType();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("efIdOrPath")) {
                path.setEfIdOrPath(StringUtils.toByteArray(parser.nextText()));
            } else {
                throw new IOException(parser.getName() + " not yet implemented");
            }
        }
    } while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals("DataSetPath")));
    return path;
}
Also used : PathType(iso.std.iso_iec._24727.tech.schema.PathType) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) IOException(java.io.IOException)

Example 5 with PathType

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

the class ChangePinInSALAction method connectCards.

private List<ConnectionHandleType> connectCards() throws WSHelper.WSException {
    // get all cards in the system
    CardApplicationPath pathReq = new CardApplicationPath();
    CardApplicationPathType pathType = new CardApplicationPathType();
    pathReq.setCardAppPathRequest(pathType);
    CardApplicationPathResponse pathRes = (CardApplicationPathResponse) dispatcher.safeDeliver(pathReq);
    WSHelper.checkResult(pathRes);
    // connect every card in the set
    ArrayList<ConnectionHandleType> connectedCards = new ArrayList<>();
    for (CardApplicationPathType path : pathRes.getCardAppPathResultSet().getCardApplicationPathResult()) {
        try {
            CardApplicationConnect conReq = new CardApplicationConnect();
            conReq.setCardApplicationPath(path);
            conReq.setExclusiveUse(false);
            CardApplicationConnectResponse conRes = (CardApplicationConnectResponse) dispatcher.safeDeliver(conReq);
            WSHelper.checkResult(conRes);
            connectedCards.add(conRes.getConnectionHandle());
        } catch (WSHelper.WSException ex) {
            LOG.error("Failed to connect card, skipping this entry.", ex);
        }
    }
    return connectedCards;
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) WSHelper(org.openecard.common.WSHelper) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) ArrayList(java.util.ArrayList) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) WSException(org.openecard.common.WSHelper.WSException)

Aggregations

CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)5 PathType (iso.std.iso_iec._24727.tech.schema.PathType)5 ArrayList (java.util.ArrayList)4 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)3 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)3 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)3 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)3 DSIList (iso.std.iso_iec._24727.tech.schema.DSIList)2 DataSetList (iso.std.iso_iec._24727.tech.schema.DataSetList)2 WSHelper (org.openecard.common.WSHelper)2 ACLList (iso.std.iso_iec._24727.tech.schema.ACLList)1 AccessControlListType (iso.std.iso_iec._24727.tech.schema.AccessControlListType)1 AccessRuleType (iso.std.iso_iec._24727.tech.schema.AccessRuleType)1 CardApplicationList (iso.std.iso_iec._24727.tech.schema.CardApplicationList)1 CardApplicationNameList (iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse.CardApplicationNameList)1 CardApplicationServiceList (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceList)1 CardApplicationServiceNameList (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse.CardApplicationServiceNameList)1 DIDGetResponse (iso.std.iso_iec._24727.tech.schema.DIDGetResponse)1