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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations