/** * Create an HTTPS restlet Server instance matching the given parameters. * * @param port * @param address * @param keystorePath * @param keystorePassword * @param keyPassword */ protected void setupServer(int port, String address, String keystorePath, String keystorePassword, String keyPassword) { Server server = new Server(Protocol.HTTPS,address,port,null); component.getServers().add(server); server.getContext().getParameters().add("keystorePath", keystorePath); server.getContext().getParameters().add("keystorePassword", keystorePassword); server.getContext().getParameters().add("keyPassword", keyPassword); }
public static Series<Parameter> getParameters(Context context) { if (context == null) { return null; } return context.getParameters(); }
/** * Returns the value of the "authPage" parameter. * * @param c * The context where to find the parameter. * @return The value of the "authPage" parameter. */ public static String getAuthPage(Context c) { return c.getParameters().getFirstValue("authPage", "/auth_page"); }
/** * Returns the value of the "loginPage" parameter. * * @param c * The context where to find the parameter. * @return The value of the "loginPage" parameter. */ public static String getLoginPage(Context c) { return c.getParameters().getFirstValue("login", "/login"); }
/** * Returns the value of the "authPageTemplate" parameter. * * @param c * The context where to find the parameter. * @return The value of the "authPageTemplate" parameter. */ public static String getAuthPageTemplate(Context c) { return c.getParameters().getFirstValue("authPageTemplate"); }
/** * Sets the value of the "authPage" parameter. * * @param authPage * The value of the "authPage" parameter. * @param c * The context to update. */ public static void setAuthPage(String authPage, Context c) { c.getParameters().set("authPage", authPage); }
/** * Sets the value of the "loginPage" parameter. * * @param loginPage * The value of the "loginPage" parameter. * @param c * The context to update. */ public static void setLoginPage(String loginPage, Context c) { c.getParameters().set("loginPage", loginPage); }
/** * Sets the value of the "authPageTemplate" parameter. * * @param authPageTemplate * The value of the "authPageTemplate" parameter. * @param c * The context to update. */ public static void setAuthPageTemplate(String authPageTemplate, Context c) { c.getParameters().set("authPageTemplate", authPageTemplate); }
/** * Sets the value of the "authSkipApproved" parameter. * * @param skip * The value of the "authSkipApproved" parameter. * @param c * The context to update. */ public static void setAuthSkipApproved(boolean skip, Context c) { c.getParameters().set("authSkipApproved", Boolean.toString(skip)); }
/** * Returns the value of the "authPage" parameter. * * @param c * The context where to find the parameter. * @return The value of the "authPage" parameter. */ public static String getAuthPage(Context c) { return c.getParameters().getFirstValue("authPage", "/auth_page"); } public static String getErrorPageTemplate(Context c) {
public static void setErrorPageTemplate(String errorPageTemplate, Context c) { c.getParameters().set("errorPageTemplate", errorPageTemplate); }
/** * Sets parameters on the server. * * @param parameters * Parameters to set on the server. */ public void setParameters(Properties parameters) { final Enumeration<?> names = parameters.propertyNames(); while (names.hasMoreElements()) { final String name = (String) names.nextElement(); getContext().getParameters() .add(name, parameters.getProperty(name)); } }
/** * Returns the value of the "authSkipApproved" parameter. * * @param c * The context where to find the parameter. * @return The value of the "authSkipApproved" parameter. */ public static boolean getAuthSkipApproved(Context c) { c.getLogger().fine("Trying to get auth page template"); String skip = c.getParameters().getFirstValue("authSkipApproved"); if (skip == null) return false; return Boolean.parseBoolean(skip); }
private ClientResource createClientResource(String url, boolean buffering) { ClientResource clientResource = new ClientResource(new Context(), url); clientResource.getContext().getParameters().add("socketConnectTimeoutMs", String.valueOf(CONNECTION_TIMEOUT)); clientResource.getContext().getParameters().add("maxIoIdleTimeMs", String.valueOf(CONNECTION_TIMEOUT)); clientResource.setEntityBuffering(buffering); return clientResource; }
@Override public synchronized void start() throws Exception { setName( polygeneApplication.name() ); Series<Parameter> parameters = getContext().getParameters(); String mode = parameters.getFirstValue( "org.apache.polygene.runtime.mode" ); super.start(); getLogger().info( "RestApplication successfully started." ); }
/** * Returns the helped Restlet parameters. * * @return The helped Restlet parameters. */ public Series<Parameter> getHelpedParameters() { Series<Parameter> result = null; if ((getHelped() != null) && (getHelped().getContext() != null)) { result = getHelped().getContext().getParameters(); } else { result = new Series<Parameter>(Parameter.class); } return result; }
/** * Returns the helped Restlet parameters. * * @return The helped Restlet parameters. */ public Series<Parameter> getHelpedParameters() { Series<Parameter> result = null; if ((getHelped() != null) && (getHelped().getContext() != null)) { result = getHelped().getContext().getParameters(); } else { result = new Form(); } return result; }
@Inject public RestComponent(@Hello Application helloApp, @Car Application carApp, Verifier authTokenVerifier) { getClients().add(Protocol.HTTPS); Server secureServer = getServers().add(Protocol.HTTPS, 8043); Series<Parameter> parameters = secureServer.getContext().getParameters(); parameters.add("sslContextFactory", "org.restlet.engine.ssl.DefaultSslContextFactory"); parameters.add("keyStorePath", System.getProperty("javax.net.ssl.keyStorePath")); getDefaultHost().attach("/api/hello", secure(helloApp, authTokenVerifier, "ame")); getDefaultHost().attach("/api/cars", secure(carApp, authTokenVerifier, "ame")); replaceConverter(JacksonConverter.class, new JacksonCustomConverter()); }
public static void main(String[] args) throws Exception { Client client = new Client(new Context(), Protocol.HTTPS); Series<Parameter> parameters = client.getContext().getParameters(); parameters.add("truststorePath", "src/org/restlet/example/book/restlet/ch05/clientTrust.jks"); parameters.add("truststorePassword", "password"); parameters.add("truststoreType", "JKS"); ClientResource clientResource = new ClientResource( "https://localhost:8183/accounts/chunkylover53/mails/123"); clientResource.setNext(client); MailResource mailClient = clientResource.wrap(MailResource.class); mailClient.store(mailClient.retrieve()); client.stop(); }
/** * default constructor for UmlgRestletComponent */ public UmlgRestletComponent() { setName("restAndJson"); setDescription("Halo, I am your first comment."); getClients().add(Protocol.FILE); getClients().add(Protocol.CLAP); getClients().add(Protocol.RIAP); Server server = new Server(new Context(), Protocol.HTTP, 8111); server.getContext().getParameters().set("tracing", "true"); getServers().add(server); attachApplications(); }