@Override protected void handleLocal(Request request, Response response, String decodedPath) { String scheme = request.getResourceRef().getScheme(); if (!FILE.getSchemeName().equalsIgnoreCase(scheme)) { throw new IllegalArgumentException(format( "Protocol \"%s\" not supported by the connector. Only FILE is supported.", scheme)); } handleFile(request, response, decodedPath); }
/** * 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 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; }
/** * Returns the name. * * @return The name. */ @Override public String toString() { return getName() + ((getVersion() == null) ? "" : "/" + getVersion()); }
/** * 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; }
for (Map.Entry<String, Object> entry : request.getAttributes() .entrySet()) { if (!getHeaderFilterStrategy().applyFilterToExternalHeaders( inMessage.setHeader(Exchange.HTTP_METHOD, request.getMethod()); inMessage.setHeader(Exchange.CONTENT_TYPE, request.getEntity() .getMediaType()); String query = request.getResourceRef().getQuery(); Request httpRequest = (Request) request; if (httpRequest.getHostRef() != null) { String host = httpRequest.getHostRef().getHostDomain(); int port = httpRequest.getHostRef().getHostPort(); String protocol = "http"; if (httpRequest.getHostRef().getSchemeProtocol() != null) { protocol = httpRequest.getHostRef().getSchemeProtocol().getSchemeName();
ClientInfo clientInfo = request.getClientInfo(); addHeader(HEADER_FROM, request.getClientInfo().getFrom(), headers); Reference hostRef = (request.getResourceRef().getBaseRef() != null) ? request .getResourceRef().getBaseRef() : request.getResourceRef(); if (hostRef.getHostDomain() != null) { String host = hostRef.getHostDomain(); int hostRefPortValue = hostRef.getHostPort(); && (hostRefPortValue != request.getProtocol().getDefaultPort())) { host = host + ':' + hostRefPortValue; Context.getCurrentLogger() .log(WARNING, "Unable to format the HTTP If-Range header due to the presence of both entity tag and modification date.");
@Override public void handle(Request request, Response response) { try { if (Protocol.FTP.equals(request.getProtocol())) { if (Method.GET.equals(request.getMethod())) { Reference ftpRef = request.getResourceRef(); String userInfo = null; ftpRef.setUserInfo(userInfo); URL url = ftpRef.toUrl(); URLConnection connection = url.openConnection(); Entity.updateMetadata(request.getResourceRef().getPath(), response.getEntity(), true, getMetadataService()); } else {
result = (this.request != null) ? this.request.getAttributes().get(variableName) : null; if (result != null) { return result; ChallengeResponse cr = this.request.getChallengeResponse(); Representation entity = this.request.getEntity(); return (this.request.getMethod() != null) ? this.request.getMethod().getName() : null; case "p": return (this.request.getProtocol() != null) ? this.request.getProtocol().getName() : null; default: if (variableName.startsWith("o")) {
Endpoint endpoint = new Endpoint(baseRef.getHostDomain(), baseRef.getHostPort(), baseRef.getSchemeProtocol() .getSchemeName(), baseRef.getPath(), scheme); definition.getEndpoints().add(endpoint); Protocol.HTTP.getSchemeName(), "/v1", scheme); definition.getEndpoints().add(endpoint);
/** * Displays a synthesis of the request like an HTTP request line. * * @return A synthesis of the request like an HTTP request line. */ public String toString() { return ((getMethod() == null) ? "" : getMethod().toString()) + " " + ((getResourceRef() == null) ? "" : getResourceRef() .toString()) + " " + ((getProtocol() == null) ? "" : (getProtocol().getName() + ((getProtocol() .getVersion() == null) ? "" : "/" + getProtocol().getVersion()))); }
final String path = getPath(); if (path != null) { input.append(path); && input.substring(0, 4).equals("/../")) { input.delete(0, 3); removeLastSegment(output); } else if ((input.length() == 3) && input.substring(0, 3).equals("/..")) { input.delete(1, 3); removeLastSegment(output); final int hostPort = getHostPort(); if (hostPort != -1) { final int defaultPort = Protocol.valueOf(getScheme()) .getDefaultPort(); if (hostPort == defaultPort) { setHostPort(null);
@Override protected void handleLocal(Request request, Response response, String decodedPath) { String scheme = request.getResourceRef().getScheme(); if (scheme.equalsIgnoreCase(Protocol.CLAP.getSchemeName())) { LocalReference cr = new LocalReference(request.getResourceRef()); ClassLoader classLoader = null; Object classLoaderAttribute = request.getAttributes().get( "org.restlet.clap.classLoader");
sb.append(httpCall.getProtocol().getSchemeName()).append("://"); sb.append(httpCall.getHostDomain()); if ((httpCall.getHostPort() != -1) && (httpCall.getHostPort() != httpCall.getProtocol().getDefaultPort())) { sb.append(':').append(httpCall.getHostPort()); setResourceRef(new Reference(getHostRef(), httpCall.getRequestUri())); if (getResourceRef().isRelative()) { setResourceRef(new Reference(getHostRef().toString() + "/" + httpCall.getRequestUri())); } else {
String hostScheme = ""; if (request.getHostRef() != null) { hostDomain = request.getHostRef().getHostDomain(); int basePortValue = request.getHostRef().getHostPort(); basePortValue = request.getHostRef().getSchemeProtocol() .getDefaultPort(); .getSchemeProtocol() != null) { resourcePortValue = request.getResourceRef() .getSchemeProtocol().getDefaultPort(); serverPortValue = request.getProtocol().getDefaultPort();
client = new Client(new Context(), protocolsList); client = new Client(new Context(), getProtocol(item .getNodeValue())); new Context(), protocol, getInt(portNode, protocol.getDefaultPort()), getServers().getTarget()); new Reference(item.getNodeValue()));
final String scheme = request.getResourceRef().getScheme(); if (Protocol.RIAP.getSchemeName().equalsIgnoreCase(scheme)) { LocalReference ref = new LocalReference(request.getResourceRef()); && RiapServerHelper.instance.getContext() != null && RiapServerHelper.instance.getContext() .getClientDispatcher() != null) { RiapServerHelper.instance.getContext() .getClientDispatcher().handle(request, response); } else { super.handle(request, response);
@Override protected void handleLocal(Request request, Response response, String decodedPath) { String scheme = request.getResourceRef().getScheme(); if (scheme.equalsIgnoreCase(Protocol.OBAP.getSchemeName())) { Bundle bundle = BUNDLE_CACHE.get(request.getResourceRef() .getAuthority()); getLogger().fine( "Look for bundle " + request.getResourceRef().getAuthority()); handleBundle(request, response, bundle); } else { throw new IllegalArgumentException( "Protocol \"" + scheme + "\" not supported by the connector. Only OBAP is supported."); } }
@Override protected int doHandle(Request request, Response response) { int result = CONTINUE; Protocol protocol = request.getProtocol(); if (protocol.equals(Protocol.RIAP)) { LocalReference cr = new LocalReference(request.getResourceRef()); Component component = getComponent(); request.getResourceRef().setBaseRef( request.getResourceRef().getHostIdentifier()); request.getResourceRef().setBaseRef( request.getResourceRef().getHostIdentifier());
/** * @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); } }