use of oasis.names.tc.dss._1_0.core.schema.Result in project open-ecard by ecsec.
the class IFD method cancel.
@Override
public CancelResponse cancel(Cancel parameters) {
CancelResponse response;
// you thought of a different IFD obviously
if (!ByteUtils.compare(ctxHandle, parameters.getContextHandle())) {
String msg = "Invalid context handle specified.";
Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.INVALID_CONTEXT_HANDLE, msg);
response = WSHelper.makeResponse(CancelResponse.class, r);
return response;
}
String ifdName = parameters.getIFDName();
String session = parameters.getSessionIdentifier();
if (session != null) {
// async wait
Future<List<IFDStatusType>> f = this.asyncWaitThreads.get(session);
if (f != null) {
f.cancel(true);
response = WSHelper.makeResponse(CancelResponse.class, WSHelper.makeResultOK());
} else {
String msg = "No matching Wait call exists for the given session.";
Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.IO.CANCEL_NOT_POSSIBLE, msg);
response = WSHelper.makeResponse(CancelResponse.class, r);
}
} else if (ifdName != null) {
// sync wait
synchronized (this) {
if (syncWaitThread != null) {
syncWaitThread.cancel(true);
// not really needed but seems cleaner
syncWaitThread = null;
response = WSHelper.makeResponse(CancelResponse.class, WSHelper.makeResultOK());
} else {
String msg = "No synchronous Wait to cancel.";
Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.IO.CANCEL_NOT_POSSIBLE, msg);
response = WSHelper.makeResponse(CancelResponse.class, r);
}
}
} else {
// nothing to cancel
String msg = "Invalid parameters given.";
response = WSHelper.makeResponse(CancelResponse.class, WSHelper.makeResultUnknownError(msg));
}
return response;
}
use of oasis.names.tc.dss._1_0.core.schema.Result in project open-ecard by ecsec.
the class ChangePinInSALAction method getPinDid.
@Nonnull
private String getPinDid(ConnectionHandleType handle) throws WSException {
// get all DIDs
DIDList listReq = new DIDList();
listReq.setConnectionHandle(handle);
DIDListResponse listRes = (DIDListResponse) dispatcher.safeDeliver(listReq);
WSHelper.checkResult(listRes);
// find pin did
for (String didName : listRes.getDIDNameList().getDIDName()) {
DIDGet getReq = new DIDGet();
getReq.setConnectionHandle(handle);
getReq.setDIDName(didName);
DIDGetResponse getRes = (DIDGetResponse) dispatcher.safeDeliver(getReq);
// don't check result, just see if we have a response
DIDStructureType struct = getRes.getDIDStructure();
if (struct != null) {
if ("urn:oid:1.3.162.15480.3.0.9".equals(struct.getDIDMarker().getProtocol())) {
return didName;
}
}
}
Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.INAPPROPRIATE_PROTOCOL_FOR_ACTION, "No PIN DID found.");
throw WSHelper.createException(r);
}
use of oasis.names.tc.dss._1_0.core.schema.Result in project open-ecard by ecsec.
the class PACEStep method performChecks.
/**
* Perform all checks as described in BSI TR-03112-7 3.4.4.
*
* @param certDescription CertificateDescription of the eService Certificate
* @param dynCtx Dynamic Context
* @return a {@link Result} set according to the results of the checks
*/
private Result performChecks(CertificateDescription certDescription, DynamicContext dynCtx) {
Object objectActivation = dynCtx.get(TR03112Keys.OBJECT_ACTIVATION);
Object tokenChecks = dynCtx.get(TR03112Keys.TCTOKEN_CHECKS);
boolean checkPassed;
// omit these checks if explicitly disabled
if (convertToBoolean(tokenChecks)) {
checkPassed = checkEserviceCertificate(certDescription, dynCtx);
if (!checkPassed) {
String msg = "Hash of eService certificate is NOT contained in the CertificateDescription.";
// TODO check for the correct minor type
Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.PREREQUISITES_NOT_SATISFIED, msg);
return r;
}
// only perform the following checks if new activation is used
if (!convertToBoolean(objectActivation)) {
checkPassed = checkTCTokenServerCertificates(certDescription, dynCtx);
if (!checkPassed) {
String msg = "Hash of the TCToken server certificate is NOT contained in the CertificateDescription.";
// TODO check for the correct minor type
Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.PREREQUISITES_NOT_SATISFIED, msg);
return r;
}
checkPassed = checkTCTokenAndSubjectURL(certDescription, dynCtx);
if (!checkPassed) {
String msg = "TCToken does not come from the server to which the authorization certificate was issued.";
// TODO check for the correct minor type
Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.PREREQUISITES_NOT_SATISFIED, msg);
return r;
}
} else {
LOG.warn("Checks according to BSI TR03112 3.4.4 (TCToken specific) skipped.");
}
} else {
LOG.warn("Checks according to BSI TR03112 3.4.4 skipped.");
}
// all checks passed
return WSHelper.makeResultOK();
}
use of oasis.names.tc.dss._1_0.core.schema.Result in project open-ecard by ecsec.
the class SALFileUtils method selectAppByDataSet.
/**
* The method connects the given card to the CardApplication containing the requested DataSet.
*
* @param dataSetName Name of the DataSet which should be contained in the application to connect.
* @param handle ConnectionHandle which identifies the card and terminal.
* @return The handle describing the new state of the card.
* @throws WSException Thrown in case any of the requested eCard API methods returned an error, or no application of
* the specified card contains the requested data set.
*/
@Nonnull
public ConnectionHandleType selectAppByDataSet(@Nonnull String dataSetName, @Nonnull ConnectionHandleType handle) throws WSException {
// copy handle so that the given handle is not damaged
handle = HandlerUtils.copyHandle(handle);
// get all card applications
CardApplicationList cardApps = new CardApplicationList();
cardApps.setConnectionHandle(handle);
CardApplicationListResponse cardAppsResp = (CardApplicationListResponse) dispatcher.safeDeliver(cardApps);
WSHelper.checkResult(cardAppsResp);
List<byte[]> cardApplications = cardAppsResp.getCardApplicationNameList().getCardApplicationName();
// check if our data set is in any of the applications
for (byte[] app : cardApplications) {
DataSetList dataSetListReq = new DataSetList();
handle.setCardApplication(app);
dataSetListReq.setConnectionHandle(handle);
DataSetListResponse dataSetListResp = (DataSetListResponse) dispatcher.safeDeliver(dataSetListReq);
WSHelper.checkResult(dataSetListResp);
if (dataSetListResp.getDataSetNameList().getDataSetName().contains(dataSetName)) {
handle = selectApplication(app, handle);
return handle;
}
}
// data set not found
String msg = "Failed to find the requested data set (%s) in any of the applications of the specified card.";
msg = String.format(msg, dataSetName);
Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.FILE_NOT_FOUND, msg);
throw WSHelper.createException(r);
}
use of oasis.names.tc.dss._1_0.core.schema.Result in project open-ecard by ecsec.
the class SALFileUtils method selectAppByDID.
/**
* The method connects the given card to the CardApplication containing the requested DID Name.
*
* @param didName Name of the DID which is contained in the application to connect.
* @param handle ConnectionHandle which identifies Card and Terminal.
* @return The handle describing the new state of the card.
* @throws WSException Thrown in case any of the requested eCard API methods returned an error, or no application of
* the specified card contains the requested DID name.
*/
@Nonnull
public ConnectionHandleType selectAppByDID(@Nonnull String didName, @Nonnull ConnectionHandleType handle) throws WSException {
// copy handle so that the given handle is not damaged
handle = HandlerUtils.copyHandle(handle);
// get all card applications
CardApplicationList cardApps = new CardApplicationList();
cardApps.setConnectionHandle(handle);
CardApplicationListResponse cardAppsResp = (CardApplicationListResponse) dispatcher.safeDeliver(cardApps);
WSHelper.checkResult(cardAppsResp);
List<byte[]> cardApplications = cardAppsResp.getCardApplicationNameList().getCardApplicationName();
// check if our data set is in any of the applications
for (byte[] app : cardApplications) {
DIDList didListReq = new DIDList();
handle.setCardApplication(app);
didListReq.setConnectionHandle(handle);
DIDListResponse didListResp = (DIDListResponse) dispatcher.safeDeliver(didListReq);
WSHelper.checkResult(didListResp);
if (didListResp.getDIDNameList().getDIDName().contains(didName)) {
handle = selectApplication(app, handle);
return handle;
}
}
// data set not found
String msg = "Failed to find the requested DID (%s) in any of the applications of the specified card.";
msg = String.format(msg, didName);
Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.FILE_NOT_FOUND, msg);
throw WSHelper.createException(r);
}
Aggregations