use of org.openecard.addon.AddonNotFoundException in project open-ecard by ecsec.
the class TinySAL method getProtocol.
private SALProtocol getProtocol(@Nonnull ConnectionHandleType handle, @Nullable DIDScopeType scope, @Nonnull String protocolURI) throws UnknownProtocolException, UnknownConnectionHandleException {
CardStateEntry entry = SALUtils.getCardStateEntry(states, handle, scope != DIDScopeType.GLOBAL);
SALProtocol protocol = entry.getProtocol(protocolURI);
if (protocol == null) {
try {
protocol = protocolSelector.getSALProtocol(protocolURI);
entry.setProtocol(protocolURI, protocol);
} catch (AddonNotFoundException ex) {
throw new UnknownProtocolException("The protocol URI '" + protocolURI + "' is not available.");
}
}
protocol.getInternalData().put("cardState", entry);
return protocol;
}
use of org.openecard.addon.AddonNotFoundException in project open-ecard by ecsec.
the class ActivateAction method init.
@Override
public void init(Context ctx) {
tokenHandler = new TCTokenHandler(ctx);
this.ctx = ctx;
gui = ctx.getUserConsent();
dispatcher = ctx.getDispatcher();
manager = ctx.getManager();
settingsAndDefaultView = ctx.getViewController();
try {
AddonSpecification addonSpecStatus = manager.getRegistry().search("Status");
statusAction = manager.getAppPluginAction(addonSpecStatus, "getStatus");
AddonSpecification addonSpecPinMngmt = manager.getRegistry().search("PIN-Plugin");
pinManAction = manager.getAppExtensionAction(addonSpecPinMngmt, "GetCardsAndPINStatusAction");
} catch (AddonNotFoundException ex) {
// this should never happen because the status and pin plugin are always available
String msg = "Failed to get Status or PIN Plugin.";
LOG.error(msg, ex);
throw new RuntimeException(msg, ex);
}
}
use of org.openecard.addon.AddonNotFoundException in project open-ecard by ecsec.
the class ActivationController method activate.
/**
* Performs an activation according to BSI TR-03124-1, but does not perform the return to web session part.
* A result containing the outcome of the
*
* @param url
* @return
*/
public ActivationResult activate(String url) {
// create request uri and extract query strings
URI requestURI = URI.create(url);
String path = requestURI.getPath();
// remove leading '/'
String resourceName = path.substring(1, path.length());
// find suitable addon
String failureMessage;
AddonManager manager = sctx.getManager();
AddonSelector selector = new AddonSelector(manager);
try {
if (manager == null || selector == null) {
throw new IllegalStateException("Addon initialization failed.");
} else {
AppPluginAction action = selector.getAppPluginAction(resourceName);
String rawQuery = requestURI.getRawQuery();
Map<String, String> queries = new HashMap<>(0);
if (rawQuery != null) {
queries = HttpRequestLineUtils.transform(rawQuery);
}
BindingResult result = action.execute(null, queries, null, null);
return createActivationResult(result);
}
} catch (AddonNotFoundException ex) {
failureMessage = ex.getMessage();
LOG.info("Addon not found.", ex);
} catch (UnsupportedEncodingException ex) {
failureMessage = "Unsupported encoding.";
LOG.warn(failureMessage, ex);
} catch (Exception ex) {
failureMessage = ex.getMessage();
LOG.warn(ex.getMessage(), ex);
}
LOG.info("Returning error as INTERRUPTED result.");
return new ActivationResult(INTERRUPTED, failureMessage);
}
use of org.openecard.addon.AddonNotFoundException in project open-ecard by ecsec.
the class HttpAppPluginActionHandler method handle.
@Override
public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext context) throws HttpException, IOException {
LOG.debug("HTTP request: {}", httpRequest.toString());
CORSFilter corsFilter = new CORSFilter();
HttpResponse corsResp = corsFilter.preProcess(httpRequest, context);
if (corsResp != null) {
// CORS Response created, return it to the caller
// This is either a preflight response, or a block, because the Origin mismatched
LOG.debug("HTTP response: {}", corsResp);
Http11Response.copyHttpResponse(corsResp, httpResponse);
return;
}
// deconstruct request uri
String uri = httpRequest.getRequestLine().getUri();
URI requestURI = URI.create(uri);
String path = requestURI.getPath();
// remove leading '/'
String resourceName = path.substring(1, path.length());
// find suitable addon
try {
AppPluginAction action = selector.getAppPluginAction(resourceName);
String rawQuery = requestURI.getRawQuery();
Map<String, String> queries = new HashMap<>(0);
if (rawQuery != null) {
queries = HttpRequestLineUtils.transform(rawQuery);
}
RequestBody body = null;
if (httpRequest instanceof HttpEntityEnclosingRequest) {
LOG.debug("Request contains an entity.");
body = getRequestBody(httpRequest, resourceName);
}
Headers headers = readReqHeaders(httpRequest);
// and add some special values to the header section
headers.setHeader(METHOD_HDR, httpRequest.getRequestLine().getMethod());
BindingResult bindingResult = action.execute(body, queries, headers, null);
HttpResponse response = createHTTPResponseFromBindingResult(bindingResult);
response.setParams(httpRequest.getParams());
LOG.debug("HTTP response: {}", response);
Http11Response.copyHttpResponse(response, httpResponse);
// CORS post processing
corsFilter.postProcess(httpRequest, httpResponse, context);
} catch (AddonNotFoundException ex) {
if (path.equals("/")) {
new IndexHandler().handle(httpRequest, httpResponse, context);
} else if (path.startsWith("/")) {
new FileHandler(new DocumentRoot("/www", "/www-files")).handle(httpRequest, httpResponse, context);
} else {
new DefaultHandler().handle(httpRequest, httpResponse, context);
}
}
}
Aggregations