Component c = new Component(); Client client = c.getClients().add(Protocol.HTTP); client.getContext().getParameters().add ( "parameter", "value" );
Client client = new Client(new Context(), Protocol.HTTP); client.getContext().getParameters().add ( "parameter", "value" ); ClientResource cr = new ClientResource("http://example.com"); cr.setNext(client);
@Override public void start() { try { coreContainer = (CoreContainer) getHelped().getContext() .getAttributes().get("CoreContainer"); if (coreContainer == null) { String directory = getHelped().getContext().getParameters() .getFirstValue("directory"); String configFile = getHelped().getContext().getParameters() .getFirstValue("configFile"); if (directory != null && configFile != null) { File config = new File(configFile); if (!config.exists()) { config = new File(new URI(configFile)); } coreContainer = CoreContainer.createAndLoad(directory, config); } } if (coreContainer == null) { throw new RuntimeException( "Could not initialize core container"); } } catch (Exception e) { throw new RuntimeException("Could not initialize core container", e); } }
@Override public boolean add(Client client) { // Set the client's context, if the client does not have already one. if (client.getContext() == null) { client.setContext(getContext().createChildContext()); } return super.add(client); }
@Override public boolean add(Client client) { // Set the client's context, if the client does not have already one. if (client.getContext() == null) { client.setContext(getContext().createChildContext()); } return super.add(client); }
&& (valueNode != null)) { client .getContext() .getParameters() .add(
/** * Constructor. * * @param uri * Target resource URI. */ public UacClientResource(String uri) { this.clientResource = new SipClientResource(uri); this.clientResource.setCallId("a84b4c76e66710@pc33.atlanta.com"); this.clientResource.setCommandSequence("314159"); this.clientResource.setFrom(new Address("sip:alice@atlanta.com", "Alice")); this.clientResource.setTo(new Address("sip:bob@biloxi.com", "Bob")); Client client = new Client(new Context(), Protocol.SIP); client.getContext().getParameters().add("minThreads", "1"); client.getContext().getParameters().add("tracing", "true"); client.getContext().getParameters().add("proxyHost", "localhost"); client.getContext().getParameters().add("proxyPort", "5060"); this.clientResource.setNext(client); this.proxy = this.clientResource.wrap(UacResource.class); }
@Override public List<Car> list() { Client client = new Client(new Context(), Protocol.HTTPS); Series<Parameter> parameters = client.getContext().getParameters(); parameters.add("truststorePath", System.getProperty("javax.net.ssl.trustStore")); ClientResource clientResource = new ClientResource("https://localhost:8043/api/cars/cars"); clientResource.setNext(client); ChallengeResponse challenge = new ChallengeResponse(ChallengeScheme.HTTP_OAUTH_BEARER); challenge.setRawValue(Request.getCurrent().getAttributes().getOrDefault("token", "").toString()); clientResource.setChallengeResponse(challenge); CarServiceInterface carServiceInterface = clientResource.wrap(CarServiceInterface.class); Car[] allCars = carServiceInterface.getAllCars(); try { client.stop(); } catch (Exception e) { throw new RuntimeException(e); } return asList(allCars); } }
public static void main(String[] args) throws Exception { String[] arguments = new String[1]; arguments[0] = "8111"; // Start the origin server on port 8111 UacServerResource.main(arguments); Component c = new Component(); Server server = new Server(Protocol.SIP); c.getServers().add(server); server.getContext().getParameters().add("tracing", "true"); Client client = new Client(Protocol.SIP); c.getClients().add(client); client.getContext().getParameters().add("proxyHost", "localhost"); client.getContext().getParameters().add("proxyPort", arguments[0]); client.getContext().getParameters().add("tracing", "false"); client.getContext().getParameters() .add("pipeliningConnections", "false"); c.getDefaultHost().attachDefault( new B2buaRedirector(null, "sip:localhost:8111")); c.start(); }
client.getContext().getParameters() .add(p);
/** * @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); } }
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(); }
public static void main(String[] args) throws Exception { // Create and configure HTTPS client 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"); // Create and configure client resource ClientResource clientResource = new ClientResource( "https://localhost:8183/accounts/chunkylover53/mails/123"); clientResource.setNext(client); // Preemptively configure the authentication credentials ChallengeResponse authentication = new ChallengeResponse( ChallengeScheme.HTTP_BASIC, "chunkylover53", "pwd"); clientResource.setChallengeResponse(authentication); // Communicate with remote resource MailResource mailClient = clientResource.wrap(MailResource.class); mailClient.store(mailClient.retrieve()); // Store HTTPS client client.stop(); }
public static void main(String[] args) throws Exception { // Create and configure HTTPS client 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"); // Create and configure client resource ClientResource clientResource = new ClientResource( "https://localhost:8183/accounts/chunkylover53/mails/123"); clientResource.setNext(client); // Preemptively configure the authentication credentials ChallengeResponse authentication = new ChallengeResponse( ChallengeScheme.HTTP_BASIC, "chunkylover53", "pwd"); clientResource.setChallengeResponse(authentication); // Communicate with remote resource MailResource mailClient = clientResource.wrap(MailResource.class); mailClient.store(mailClient.retrieve()); // Store HTTPS client client.stop(); }
public static void main(String[] args) throws Exception { // Create and configure HTTPS client 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"); // Create and configure client resource ClientResource clientResource = new ClientResource( "https://localhost:8183/accounts/chunkylover53/mails/123"); clientResource.setNext(client); // Preemptively configure the authentication credentials ChallengeResponse authentication = new ChallengeResponse( ChallengeScheme.HTTP_BASIC, "chunkylover53", "pwd"); clientResource.setChallengeResponse(authentication); // Communicate with remote resource MailResource mailClient = clientResource.wrap(MailResource.class); mailClient.store(mailClient.retrieve()); // Store HTTPS client client.stop(); }
public static void main(String[] args) throws Exception { // Create and configure HTTPS client Client client = new Client(new Context(), Protocol.HTTPS); Series<Parameter> parameters = client.getContext().getParameters(); parameters.add("keystorePath", "src/org/restlet/example/book/restlet/ch05/clientKey.jks"); parameters.add("keystorePassword", "password"); parameters.add("keystoreType", "JKS"); parameters.add("keyPassword", "password"); parameters.add("truststorePath", "src/org/restlet/example/book/restlet/ch05/clientTrust.jks"); parameters.add("truststorePassword", "password"); parameters.add("truststoreType", "JKS"); // Create and configure client resource ClientResource clientResource = new ClientResource( "https://localhost:8183/accounts/chunkylover53/mails/123"); clientResource.setNext(client); // Preemptively configure the authentication credentials ChallengeResponse authentication = new ChallengeResponse( ChallengeScheme.HTTP_BASIC, "chunkylover53", "pwd"); clientResource.setChallengeResponse(authentication); // Communicate with remote resource MailResource mailClient = clientResource.wrap(MailResource.class); mailClient.store(mailClient.retrieve()); // Store HTTPS client client.stop(); }
public static void main(String[] args) throws Exception { Series<Parameter> parameters = client.getContext().getParameters(); parameters.add("truststorePath", "src/org/restlet/example/book/restlet/ch05/clientTrust.jks");