Search in sources :

Example 1 with DataSetInfoType

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

the class MiddlewareSAL method dataSetSelect.

@Override
public DataSetSelectResponse dataSetSelect(DataSetSelect request) {
    DataSetSelectResponse response = WSHelper.makeResponse(DataSetSelectResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] applicationID = connectionHandle.getCardApplication();
        String dataSetName = request.getDataSetName();
        Assert.assertIncorrectParameter(dataSetName, "The parameter DataSetName is empty.");
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        DataSetInfoType dataSetInfo = cardInfoWrapper.getDataSet(dataSetName, applicationID);
        Assert.assertNamedEntityNotFound(dataSetInfo, "The given DataSet cannot be found.");
        Assert.securityConditionDataSet(cardStateEntry, applicationID, dataSetName, NamedDataServiceActionName.DATA_SET_SELECT);
    // nothing else to do, DSI Read works for itself
    } catch (ECardException e) {
        response.setResult(e.getResult());
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throwThreadKillException(e);
        response.setResult(WSHelper.makeResult(e));
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType) ThreadTerminateException(org.openecard.common.ThreadTerminateException) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException) ECardException(org.openecard.common.ECardException) FinalizationException(org.openecard.mdlw.sal.exceptions.FinalizationException) PinBlockedException(org.openecard.mdlw.sal.exceptions.PinBlockedException) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) TokenException(org.openecard.mdlw.sal.exceptions.TokenException) WSMarshallerException(org.openecard.ws.marshal.WSMarshallerException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) UnsupportedAlgorithmException(org.openecard.crypto.common.UnsupportedAlgorithmException) PinIncorrectException(org.openecard.mdlw.sal.exceptions.PinIncorrectException) DataSetSelectResponse(iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse)

Example 2 with DataSetInfoType

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

the class CIFCreator method addTokenInfo.

public CardInfoType addTokenInfo() throws WSMarshallerException, CryptokiException {
    LOG.debug("Adding information to CardInfo file for card type {}.", cif.getCardType().getObjectIdentifier());
    PIN_NAME = "USER_PIN";
    DIDInfoType pinDid = createPinDID();
    List<DIDInfoType> cryptoDids = getSignatureCryptoDIDs();
    List<DataSetInfoType> datasets = getCertificateDatasets();
    CardApplicationType app = cif.getApplicationCapabilities().getCardApplication().get(0);
    app.getDIDInfo().add(pinDid);
    app.getDIDInfo().addAll(cryptoDids);
    app.getDataSetInfo().addAll(datasets);
    return cif;
}
Also used : CardApplicationType(iso.std.iso_iec._24727.tech.schema.CardApplicationType) DIDInfoType(iso.std.iso_iec._24727.tech.schema.DIDInfoType) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType)

Example 3 with DataSetInfoType

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

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

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

the class TinySAL method aclList.

/**
 * The ACLList function returns the access control list for the stated target object (card application, data set, DID).
 * See BSI-TR-03112-4, version 1.1.2, section 3.7.1.
 *
 * @param request ACLList
 * @return ACLListResponse
 */
@Publish
@Override
public ACLListResponse aclList(ACLList request) {
    ACLListResponse response = WSHelper.makeResponse(ACLListResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        TargetNameType targetName = request.getTargetName();
        Assert.assertIncorrectParameter(targetName, "The parameter TargetName is empty.");
        // get the target values, according to the schema only one must exist, we pick the first existing ;-)
        byte[] targetAppId = targetName.getCardApplicationName();
        String targetDataSet = targetName.getDataSetName();
        String targetDid = targetName.getDIDName();
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        byte[] handleAppId = connectionHandle.getCardApplication();
        if (targetDataSet != null) {
            DataSetInfoType dataSetInfo = cardInfoWrapper.getDataSet(targetDataSet, handleAppId);
            Assert.assertNamedEntityNotFound(dataSetInfo, "The given DataSet cannot be found.");
            response.setTargetACL(cardInfoWrapper.getDataSet(targetDataSet, handleAppId).getDataSetACL());
        } else if (targetDid != null) {
            DIDInfoType didInfo = cardInfoWrapper.getDIDInfo(targetDid, handleAppId);
            Assert.assertNamedEntityNotFound(didInfo, "The given DIDInfo cannot be found.");
            // TODO Check security condition ?
            response.setTargetACL(cardInfoWrapper.getDIDInfo(targetDid, handleAppId).getDIDACL());
        } else if (targetAppId != null) {
            CardApplicationWrapper cardApplication = cardInfoWrapper.getCardApplication(targetAppId);
            Assert.assertNamedEntityNotFound(cardApplication, "The given CardApplication cannot be found.");
            Assert.securityConditionApplication(cardStateEntry, targetAppId, AuthorizationServiceActionName.ACL_LIST);
            response.setTargetACL(cardInfoWrapper.getCardApplication(targetAppId).getCardApplicationACL());
        } else {
            throw new IncorrectParameterException("The given TargetName is invalid.");
        }
    } catch (ECardException e) {
        response.setResult(e.getResult());
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throwThreadKillException(e);
        response.setResult(WSHelper.makeResult(e));
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) TargetNameType(iso.std.iso_iec._24727.tech.schema.TargetNameType) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) ACLListResponse(iso.std.iso_iec._24727.tech.schema.ACLListResponse) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException) ECardException(org.openecard.common.ECardException) DIDInfoType(iso.std.iso_iec._24727.tech.schema.DIDInfoType) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType) CardApplicationWrapper(org.openecard.common.sal.state.cif.CardApplicationWrapper) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) Publish(org.openecard.common.interfaces.Publish)

Aggregations

DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)15 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)9 ECardException (org.openecard.common.ECardException)9 ThreadTerminateException (org.openecard.common.ThreadTerminateException)9 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)9 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)9 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)9 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)9 CardInfoWrapper (org.openecard.common.sal.state.cif.CardInfoWrapper)9 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)8 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)8 NameExistsException (org.openecard.common.sal.exception.NameExistsException)8 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)8 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)8 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)8 TLVException (org.openecard.common.tlv.TLVException)8 DSIType (iso.std.iso_iec._24727.tech.schema.DSIType)5 Publish (org.openecard.common.interfaces.Publish)5 DIDInfoType (iso.std.iso_iec._24727.tech.schema.DIDInfoType)3 PathType (iso.std.iso_iec._24727.tech.schema.PathType)3