Search in sources :

Example 6 with StaticContent

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);
}
Also used : StreamedAutoSignedStaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StreamedAutoSignedStaticContent) StaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StaticContent)

Example 7 with StaticContent

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);
    }
}
Also used : Extension(org.glassfish.appclient.server.core.jws.ExtensionFileManager.Extension) StreamedAutoSignedStaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StreamedAutoSignedStaticContent) StaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StaticContent) URI(java.net.URI) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 8 with StaticContent

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);
    }
}
Also used : StaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StaticContent) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException)

Example 9 with StaticContent

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;
    }
}
Also used : StaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StaticContent) URI(java.net.URI)

Example 10 with StaticContent

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);
}
Also used : StreamedAutoSignedStaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StreamedAutoSignedStaticContent) StaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StaticContent) StreamedAutoSignedStaticContent(org.glassfish.appclient.server.core.jws.servedcontent.StreamedAutoSignedStaticContent) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

StaticContent (org.glassfish.appclient.server.core.jws.servedcontent.StaticContent)13 URI (java.net.URI)7 File (java.io.File)6 JarFile (java.util.jar.JarFile)5 StreamedAutoSignedStaticContent (org.glassfish.appclient.server.core.jws.servedcontent.StreamedAutoSignedStaticContent)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AutoSignedContent (org.glassfish.appclient.server.core.jws.servedcontent.AutoSignedContent)2 FileFilter (java.io.FileFilter)1 IOException (java.io.IOException)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Manifest (java.util.jar.Manifest)1 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)1 Extension (org.glassfish.appclient.server.core.jws.ExtensionFileManager.Extension)1 FixedContent (org.glassfish.appclient.server.core.jws.servedcontent.FixedContent)1