use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class HandlerUtils method copyHandle.
// TODO: use builder to copy handles
public static ConnectionHandleType copyHandle(ConnectionHandleType handle) {
ConnectionHandleType result = new ConnectionHandleType();
copyPath(result, handle);
result.setSlotHandle(ByteUtils.clone(handle.getSlotHandle()));
result.setRecognitionInfo(copyRecognition(handle.getRecognitionInfo()));
result.setSlotInfo(copySlotInfo(handle.getSlotInfo()));
return result;
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class SALFileUtils method selectApplication.
/**
* Performs a CardApplicationConnect SAL call for the given handle.
* The path part of the handle is used as a basis to connect the card.
*
* @param appId
* @param handle
* @return The handle of the card after performing the connect.
* @throws org.openecard.common.WSHelper.WSException
*/
public ConnectionHandleType selectApplication(@Nonnull byte[] appId, @Nonnull ConnectionHandleType handle) throws WSException {
CardApplicationConnect appConnectReq = new CardApplicationConnect();
// copy path part of the handle and use it to identify the card
CardApplicationPathType path = HandlerUtils.copyPath(handle);
path.setCardApplication(appId);
appConnectReq.setCardApplicationPath(path);
CardApplicationConnectResponse resp = (CardApplicationConnectResponse) dispatcher.safeDeliver(appConnectReq);
WSHelper.checkResult(resp);
return resp.getConnectionHandle();
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class EventHandler method signalEvent.
@Override
public void signalEvent(EventType eventType, EventObject eventData) {
ConnectionHandleType connectionHandle = eventData.getHandle();
for (Map.Entry<String, LinkedBlockingQueue<StatusChange>> entry : eventQueues.entrySet()) {
try {
LinkedBlockingQueue<StatusChange> queue = entry.getValue();
StatusChange statusChange = new StatusChange();
statusChange.setAction(eventType.getEventTypeIdentifier());
statusChange.setConnectionHandle(connectionHandle);
queue.put(statusChange);
} catch (InterruptedException ignore) {
}
}
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class ListTokens method determineTokenFeatures.
private boolean determineTokenFeatures(TokenInfoType next) {
try {
// request the missing information
ConnectionHandleType h = new ConnectionHandleType();
h.setSlotHandle(next.getConnectionHandle().getSlotHandle());
DidInfos dids = new DidInfos(dispatcher, null, h);
List<DidInfo> didInfos = dids.getDidInfos();
boolean needsDidPin = false;
boolean needsCertPin = false;
TreeSet<String> algorithms = new TreeSet<>();
// find out everything about the token
for (DidInfo didInfo : didInfos) {
if (didInfo.isCryptoDid()) {
// only evaluate if we have no positive match yet
if (!needsDidPin) {
needsDidPin |= didInfo.needsPin();
}
// only evaluate if we have no positive match yet
if (!needsCertPin) {
for (DataSetInfo dataSetinfo : didInfo.getRelatedDataSets()) {
needsCertPin |= dataSetinfo.needsPin();
}
}
// get the algorithm of the did
AlgorithmInfoType algInfo = didInfo.getGenericCryptoMarker().getAlgorithmInfo();
AlgorithmIdentifierType algId = algInfo.getAlgorithmIdentifier();
String alg = algInfo.getAlgorithm();
try {
if (algId != null && algId.getAlgorithm() != null) {
String jcaName = AllowedSignatureAlgorithms.algIdtoJcaName(algId.getAlgorithm());
algorithms.add(jcaName);
}
} catch (UnsupportedAlgorithmException ex) {
// ignore and fall back to Algorithm field
if (alg != null && !alg.isEmpty() && AllowedSignatureAlgorithms.isKnownJcaAlgorithm(alg)) {
algorithms.add(alg);
}
}
}
}
next.setNeedsPinForCertAccess(needsCertPin);
next.setNeedsPinForPrivateKeyAccess(needsDidPin);
next.getAlgorithm().addAll(algorithms);
// finished evaluation everything successfully
return true;
} catch (NoSuchDid | WSHelper.WSException | SecurityConditionUnsatisfiable ex) {
LOG.error("Failed to evaluate DID.", ex);
}
// there has been an error
return false;
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class ListTokens method convertHandles.
private ArrayList<TokenInfoType> convertHandles(List<ConnectionHandleType> handles) {
ArrayList<TokenInfoType> result = new ArrayList<>();
for (ConnectionHandleType next : handles) {
ConnectionHandleType.RecognitionInfo rec = next.getRecognitionInfo();
// create token type and copy available information about it
TokenInfoType ti = new TokenInfoType();
org.openecard.ws.chipgateway.ConnectionHandleType h = new org.openecard.ws.chipgateway.ConnectionHandleType();
h.setSlotHandle(next.getSlotHandle());
h.setCardType(rec.getCardType());
ti.setConnectionHandle(h);
ConnectionHandleType.SlotInfo si = next.getSlotInfo();
if (si != null) {
ti.setHasProtectedAuthPath(si.isProtectedAuthPath());
}
if (determineTokenFeatures(ti)) {
// only add this token if there are no errors
result.add(ti);
}
}
return result;
}
Aggregations