use of org.glassfish.appclient.server.core.jws.servedcontent.StaticContent in project Payara by payara.
the class JavaWebStartInfo method createAndAddSignedStaticContent.
private void createAndAddSignedStaticContent(final Map<String, StaticContent> content, final File unsignedFile, final File signedFile, final URI uriForLookup, final String tokenName, final String appName) throws FileNotFoundException {
final StaticContent signedJarContent = createSignedStaticContent(unsignedFile, signedFile, uriForLookup, appName);
recordStaticContent(content, signedJarContent, uriForLookup, tokenName);
}
use of org.glassfish.appclient.server.core.jws.servedcontent.StaticContent in project Payara by payara.
the class JavaWebStartInfo method processExtensionReferences.
private void processExtensionReferences() throws IOException {
// TODO: needs to be expanded to handle signed library JARS, perhap signed by different certs
final URI fileURI = URI.create("file:" + helper.appClientServerOriginalAnchor(dc).getRawSchemeSpecificPart());
Set<Extension> exts = extensionFileManager.findExtensionTransitiveClosure(new File(fileURI), // new File(helper.appClientServerURI(dc)).getParentFile(),
dc.getSource().getManifest().getMainAttributes());
tHelper.setProperty(APP_LIBRARY_EXTENSION_PROPERTY_NAME, jarElementsForExtensions(exts));
for (Extension e : exts) {
final URI uri = URI.create(JWSAdapterManager.publicExtensionLookupURIText(e));
final StaticContent newSystemContent = createSignedStaticContent(e.getFile(), signedFileForDomainFile(e.getFile()), uri, extensionName(e.getFile()));
jwsAdapterManager.addStaticSystemContent(uri.toString(), newSystemContent);
}
}
use of org.glassfish.appclient.server.core.jws.servedcontent.StaticContent in project Payara by payara.
the class RestrictedContentAdapter method processContent.
private void processContent(final String relativeURIString, final Request gReq, final Response gResp) {
try {
final StaticContent sc = content.get(relativeURIString);
if (sc == null) {
throw new RuntimeException(relativeURIString + "-> null");
}
/*
* No need to actually send the file if the request contains a
* If-Modified-Since date and the file is not more recent.
*/
final File fileToSend = sc.file();
if (fileToSend != null) {
if (returnIfClientCacheIsCurrent(relativeURIString, gReq, fileToSend.lastModified())) {
return;
}
}
sc.process(relativeURIString, gReq, gResp);
// final int status = gResp.getStatus();
// if (status != HttpServletResponse.SC_OK) {
// logger.fine(logPrefix() + "Could not serve content for "
// + relativeURIString + " - status = " + status);
// } else {
// logger.fine(logPrefix() + "Served static content for " + gReq.getMethod()
// + ":" + sc.toString());
// }
// finishResponse(gResp, status);
} catch (IOException ioex) {
/*
* Broken pipe errors happen fairly regularly with Java Web Start on
* the client side. There's no need to clutter up the log with
* reports of them that we cannot really do anything about.
*/
if (isBrokenPipe(ioex)) {
logger.log(Level.FINE, "''Broken pipe'' while responding to {0}{1}", new Object[] { logPrefix(), relativeURIString });
} else {
finishErrorResponse(gResp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
logger.log(Level.SEVERE, logPrefix() + relativeURIString, ioex);
}
} catch (Exception e) {
// gResp.getResponse().setErrorException(e);
finishErrorResponse(gResp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
logger.log(Level.SEVERE, logPrefix() + relativeURIString, e);
}
}
use of org.glassfish.appclient.server.core.jws.servedcontent.StaticContent in project Payara by payara.
the class RestrictedContentAdapter method serviceContent.
protected boolean serviceContent(Request gReq, Response gResp) throws IOException {
String relativeURIString = relativizeURIString(contextRoot, gReq.getRequestURI());
/*
* "Forbidden" seems like a more helpful response than "not found"
* if the corresponding app client has been suspended.
*/
if (state == State.SUSPENDED) {
finishErrorResponse(gResp, HttpServletResponse.SC_FORBIDDEN);
if (logger.isLoggable(Level.FINE)) {
logger.fine(logPrefix() + "is suspended; refused to serve static content requested using " + (relativeURIString == null ? "null" : relativeURIString));
}
return true;
}
if (relativeURIString == null) {
if (logger.isLoggable(Level.FINE)) {
logger.fine(logPrefix() + "Could not find static content requested using full request URI = " + gReq.getRequestURI() + " - relativized URI was null");
}
respondNotFound(gResp);
return true;
}
/*
* The Grizzly-managed cache could contain entries for non-existent
* files that users request. If the URI indicates it's a request for
* static content make sure the requested URI is in the predefined staticContent
* before having Grizzly serve it.
*
* Alternatively, if the URI indicates the request is for dynamic content
* then handle that separately.
*
* If the request is for a URI in neither the static nor dynamic
* content this adapter should serve, then just return a 404.
*/
final StaticContent sc = content.get(relativeURIString);
final URI requestURI = Util.getCodebase(gReq);
if (sc != null && sc.isAvailable(requestURI)) {
processContent(relativeURIString, gReq, gResp);
return true;
} else {
finishErrorResponse(gResp, contentStateToResponseStatus(sc, requestURI));
final String scString = (sc == null ? "null" : sc.toString());
final String scStateString = (sc == null ? "null" : sc.state().toString());
if (logger.isLoggable(Level.FINE)) {
logger.fine(logPrefix() + "Found static content for " + gReq.getMethod() + ": " + relativeURIString + " -> " + scString + " but could not serve it; its state is " + scStateString);
}
return true;
}
}
use of org.glassfish.appclient.server.core.jws.servedcontent.StaticContent in project Payara by payara.
the class JavaWebStartInfo method createAndAddSignedStaticContentFromMainJAR.
private void createAndAddSignedStaticContentFromMainJAR(final Map<String, StaticContent> content, final URI uriToFile, final URI uriForLookup, final String tokenName) throws FileNotFoundException {
final File unsignedFile = new File(uriToFile);
final StaticContent signedContent = new StreamedAutoSignedStaticContent(unsignedFile, signingAlias, jarSigner, uriForLookup.toASCIIString(), acServerApp.getDescriptor().getName());
recordStaticContent(content, signedContent, uriForLookup, tokenName);
}
Aggregations