/** * Constructor. * * @param protocolName * The connector protocol. */ public Client(String protocolName) { this(Protocol.valueOf(protocolName)); }
/** * Constructor. * * @param protocolName * The connector protocol. */ public Client(String protocolName) { this(Protocol.valueOf(protocolName)); }
/** * Constructor. * * @param protocolName * The connector protocol. */ public Client(String protocolName) { this(Protocol.valueOf(protocolName)); }
/** * Returns the protocol associated with the scheme component. * * @return The protocol associated with the scheme component. */ public Protocol getSchemeProtocol() { return Protocol.valueOf(getScheme()); }
/** * Returns the server protocol. * * @return The server protocol. */ @Override public Protocol getProtocol() { return Protocol.valueOf(getRequest().getScheme()); }
/** * Returns the protocol associated with the scheme component. * * @return The protocol associated with the scheme component. */ public Protocol getSchemeProtocol() { return Protocol.valueOf(getScheme()); }
/** * Constructor. * * @param protocol * The server's protocol such as "HTTP" or "HTTPS". */ public SpringServer(String protocol) { super(new Context(), Protocol.valueOf(protocol), null); }
/** * Returns the server protocol. * * @return The server protocol. */ @Override public Protocol getProtocol() { return Protocol.valueOf(getRequest().getScheme()); }
/** * Constructor. * * @param protocol * The server's protocol such as "HTTP" or "HTTPS". * @param port * The port number. */ public SpringServer(String protocol, int port) { super(new Context(), Protocol.valueOf(protocol), port, null); }
/** * Returns the protocol associated with the scheme component. * * @return The protocol associated with the scheme component. */ public Protocol getSchemeProtocol() { return Protocol.valueOf(getScheme()); }
/** * Constructor. * * @param protocol * The server's protocol such as "HTTP" or "HTTPS". * @param address * The IP address. * @param port * The port number. */ public SpringServer(String protocol, String address, int port) { super(new Context(), Protocol.valueOf(protocol), address, port, null); }
/** * Returns a protocol by its scheme. If the latter is unknown, instantiate a * new protocol object. * * @param scheme * the scheme of the desired protocol. * @return a known protocol or a new instance. */ private Protocol getProtocol(String scheme) { Protocol protocol = Protocol.valueOf(scheme); if (protocol == null) { protocol = new Protocol(scheme); } return protocol; }
/** * Returns a protocol by its scheme. If the latter is unknown, instantiate a * new protocol object. * * @param scheme * the scheme of the desired protocol. * @return a known protocol or a new instance. */ private Protocol getProtocol(String scheme) { Protocol protocol = Protocol.valueOf(scheme); if (protocol == null) { protocol = new Protocol(scheme); } return protocol; }
/** * Creates a reference string from its parts. * * @param scheme * The scheme ("http", "https" or "ftp"). * @param hostName * The host name or IP address. * @param hostPort * The host port (default ports are correctly ignored). * @param path * The path component for hierarchical identifiers. * @param query * The optional query component for hierarchical identifiers. * @param fragment * The optional fragment identifier. * @return The reference as String. */ public static String toString(String scheme, String hostName, Integer hostPort, String path, String query, String fragment) { String host = hostName; // Appends the host port number if (hostPort != null) { final int defaultPort = Protocol.valueOf(scheme).getDefaultPort(); if (hostPort != defaultPort) { host = hostName + ':' + hostPort; } } return toString(scheme, host, path, query, fragment); }
/** * Creates a reference string from its parts. * * @param scheme * The scheme ("http", "https" or "ftp"). * @param hostName * The host name or IP address. * @param hostPort * The host port (default ports are correctly ignored). * @param path * The path component for hierarchical identifiers. * @param query * The optional query component for hierarchical identifiers. * @param fragment * The optional fragment identifier. * @return The reference as String. */ public static String toString(String scheme, String hostName, Integer hostPort, String path, String query, String fragment) { String host = hostName; // Appends the host port number if (hostPort != null) { final int defaultPort = Protocol.valueOf(scheme).getDefaultPort(); if (hostPort != defaultPort) { host = hostName + ':' + hostPort; } } return toString(scheme, host, path, query, fragment); }
/** * Sets the list of servers, either as protocol names, Protocol instances or * Server instances. * * @param serversInfo * The list of servers. */ public void setServersList(List<Object> serversInfo) { for (final Object serverInfo : serversInfo) { if (serverInfo instanceof String) { getServers().add(Protocol.valueOf((String) serverInfo)); } else if (serverInfo instanceof Protocol) { getServers().add((Protocol) serverInfo); } else if (serverInfo instanceof Server) { getServers().add((Server) serverInfo); } else { getLogger() .warning( "Unknown object found in the servers list. Only instances of String, org.restlet.data.Protocol and org.restlet.Server are allowed."); } } }
/** * Sets the list of clients, either as protocol names, Protocol instances or * Client instances. * * @param clients * The list of clients. */ public synchronized void setClientsList(List<Object> clients) { for (final Object client : clients) { if (client instanceof String) { getClients().add(Protocol.valueOf((String) client)); } else if (client instanceof Protocol) { getClients().add((Protocol) client); } else if (client instanceof Client) { getClients().add((Client) client); } else { getLogger() .warning( "Unknown object found in the clients list. Only instances of String, org.restlet.data.Protocol and org.restlet.Client are allowed."); } } }
/** * Creates the protocol associated to a URI scheme name. If an existing * constant exists then it is returned, otherwise a new instance is created. * * @param name * The scheme name. * @param version * The version number. * @return The associated protocol. */ public static Protocol valueOf(String name, String version) { Protocol result = valueOf(name); if (!version.equals(result.getVersion())) { result = new Protocol(result.getSchemeName(), result.getName(), result.getTechnicalName(), result.getDescription(), result.getDefaultPort(), result.isConfidential(), version); } return result; }
/** * Creates the protocol associated to a URI scheme name. If an existing * constant exists then it is returned, otherwise a new instance is created. * * @param name * The scheme name. * @param version * The version number. * @return The associated protocol. */ public static Protocol valueOf(String name, String version) { Protocol result = valueOf(name); if (!version.equals(result.getVersion())) { result = new Protocol(result.getSchemeName(), result.getName(), result.getTechnicalName(), result.getDescription(), result.getDefaultPort(), result.isConfidential(), version); } return result; }
/** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { Client sdcClient = new Client(new Context(), Protocol.valueOf("SDC")); Series<Parameter> parameters = sdcClient.getContext().getParameters(); parameters.add("keystorePath", "sdc.keystore"); parameters.add("keystorePassword", "password"); parameters.add("enabledCipherSuites", "TLS_RSA_WITH_AES_128_CBC_SHA"); parameters.add("sslProtocol", "TLSv1"); sdcClient.start(); System.out .println("Press a key when the SDC agent is started and has established a tunnel..."); System.in.read(); Request request = new Request(Method.GET, "http://restlet.org"); request.setProtocol(Protocol.valueOf("SDC")); request.setProxyChallengeResponse(new ChallengeResponse(ChallengeScheme .valueOf("SDC"), "myUser@example.com", "myPassword")); Response response = sdcClient.handle(request); response.getEntity().write(System.out); } }