All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.picketlink.rest.ScriptEndpoint Maven / Gradle / Ivy

Go to download

There is a newer version: 2.7.0.Final
Show newest version
package org.picketlink.rest;

import java.io.IOException;
import java.io.InputStream;

import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**
 * Returns JavaScript resources
 *
 * @author Shane Bryzak
 *
 */
@Path("/script")
@ApplicationScoped
public class ScriptEndpoint {

    private String picketlinkScript;

    public ScriptEndpoint()
        throws IOException {
        InputStream is = getClass().getClassLoader().getResourceAsStream("picketlink.js");

        byte[] buffer = new byte[4096];
        StringBuilder sb = new StringBuilder();

        int read = is.read(buffer);
        while (read != -1) {
            sb.append(new String(buffer, 0, read));
            read = is.read(buffer);
        }

        picketlinkScript = sb.toString();
    }

    @GET
    @Path("/picketlink.js")
    @Produces("application/javascript")
    public String getPicketLinkClientScript() {
        return picketlinkScript;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy