use of org.osate.aadl2.Connection in project pentaho-kettle by pentaho.
the class JobEntrySSH2PUTDialog method connect.
private boolean connect() {
boolean retval = false;
try {
if (conn == null) {
// Create a connection instance
conn = new Connection(jobMeta.environmentSubstitute(wServerName.getText()), Const.toInt(jobMeta.environmentSubstitute(wServerPort.getText()), 22));
/* We want to connect through a HTTP proxy */
if (wuseHTTPProxy.getSelection()) {
// if the proxy requires basic authentication:
if (wuseBasicAuthentication.getSelection()) {
conn.setProxyData(new HTTPProxyData(jobMeta.environmentSubstitute(wHTTPProxyHost.getText()), Const.toInt(wHTTPProxyPort.getText(), 22), jobMeta.environmentSubstitute(wHTTPProxyUsername.getText()), jobMeta.environmentSubstitute(wHTTPProxyPassword.getText())));
} else {
conn.setProxyData(new HTTPProxyData(jobMeta.environmentSubstitute(wHTTPProxyHost.getText()), Const.toInt(wHTTPProxyPort.getText(), 22)));
}
}
conn.connect();
// Authenticate
if (wusePublicKey.getSelection()) {
retval = conn.authenticateWithPublicKey(jobMeta.environmentSubstitute(wUserName.getText()), new java.io.File(jobMeta.environmentSubstitute(wKeyFilename.getText())), jobMeta.environmentSubstitute(wkeyfilePass.getText()));
} else {
retval = conn.authenticateWithPassword(jobMeta.environmentSubstitute(wUserName.getText()), jobMeta.environmentSubstitute(wPassword.getText()));
}
}
retval = true;
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JobSSH2PUT.ErrorConnect.NOK", e.getMessage()) + Const.CR);
mb.setText(BaseMessages.getString(PKG, "JobSSH2PUT.ErrorConnect.Title.Bad"));
mb.open();
}
return retval;
}
use of org.osate.aadl2.Connection in project brave by openzipkin.
the class TracingInterceptor method parseRouteAddress.
static void parseRouteAddress(Chain chain, Span span) {
if (span.isNoop())
return;
Connection connection = chain.connection();
if (connection == null)
return;
InetSocketAddress socketAddress = connection.route().socketAddress();
span.remoteIpAndPort(socketAddress.getHostString(), socketAddress.getPort());
}
use of org.osate.aadl2.Connection in project pancm_project by xuwujing.
the class SshUtil method main.
public static void main(String[] args) {
// 此处根据实际情况,换成自己需要访问的主机IP
String ip = "192.168.8.12";
String userName = "root";
String password = "admin123";
Connection conn = SshUtil.login(ip, userName, password);
String cmd = "dis mac-address";
String result = SshUtil.execute(conn, cmd);
System.out.println(splitStr + "\n执行的结果如下: \n" + result + splitStr);
}
use of org.osate.aadl2.Connection in project ttdj by soonphe.
the class HttpLoggingInterceptor method intercept.
@Override
public Response intercept(Chain chain) throws IOException {
Level level = this.level;
Request request = chain.request();
if (level == Level.NONE) {
return chain.proceed(request);
}
boolean logBody = level == Level.BODY;
boolean logHeaders = logBody || level == Level.HEADERS;
RequestBody requestBody = request.body();
boolean hasRequestBody = requestBody != null;
Connection connection = chain.connection();
Protocol protocol = connection != null ? connection.protocol() : Protocol.HTTP_1_1;
String requestStartMessage = "--> " + request.method() + ' ' + request.url() + ' ' + protocol(protocol);
if (!logHeaders && hasRequestBody) {
requestStartMessage += " (" + requestBody.contentLength() + "-byte body)";
}
logger.log(requestStartMessage);
if (logHeaders) {
if (hasRequestBody) {
// them to be included (when available) so there values are known.
if (requestBody.contentType() != null) {
logger.log("Content-Type: " + requestBody.contentType());
}
if (requestBody.contentLength() != -1) {
logger.log("Content-Length: " + requestBody.contentLength());
}
}
Headers headers = request.headers();
for (int i = 0, count = headers.size(); i < count; i++) {
String name = headers.name(i);
// Skip headers from the request body as they are explicitly logged above.
if (!"Content-Type".equalsIgnoreCase(name) && !"Content-Length".equalsIgnoreCase(name)) {
logger.log(name + ": " + headers.value(i));
}
}
if (!logBody || !hasRequestBody) {
logger.log("--> END " + request.method());
} else if (bodyEncoded(request.headers())) {
logger.log("--> END " + request.method() + " (encoded body omitted)");
} else {
Buffer buffer = new Buffer();
requestBody.writeTo(buffer);
Charset charset = UTF8;
MediaType contentType = requestBody.contentType();
if (contentType != null) {
charset = contentType.charset(UTF8);
}
logger.log("");
logger.log(buffer.readString(charset));
logger.log("--> END " + request.method() + " (" + requestBody.contentLength() + "-byte body)");
}
}
long startNs = System.nanoTime();
Response response = chain.proceed(request);
long tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
ResponseBody responseBody = response.body();
long contentLength = responseBody.contentLength();
String bodySize = contentLength != -1 ? contentLength + "-byte" : "unknown-length";
logger.log("<-- " + response.code() + ' ' + response.message() + ' ' + response.request().url() + " (" + tookMs + "ms" + (!logHeaders ? ", " + bodySize + " body" : "") + ')');
if (logHeaders) {
Headers headers = response.headers();
for (int i = 0, count = headers.size(); i < count; i++) {
logger.log(headers.name(i) + ": " + headers.value(i));
}
if (!logBody || !HttpHeaders.hasBody(response)) {
logger.log("<-- END HTTP");
} else if (bodyEncoded(response.headers())) {
logger.log("<-- END HTTP (encoded body omitted)");
} else {
BufferedSource source = responseBody.source();
// Buffer the entire body.
source.request(Long.MAX_VALUE);
Buffer buffer = source.buffer();
Charset charset = UTF8;
MediaType contentType = responseBody.contentType();
if (contentType != null) {
charset = contentType.charset(UTF8);
}
if (contentLength != 0) {
logger.log("");
logger.log(buffer.clone().readString(charset));
}
logger.log("<-- END HTTP (" + buffer.size() + "-byte body)");
}
}
return response;
}
use of org.osate.aadl2.Connection in project ovirt-engine-sdk-java by oVirt.
the class IscsiDiscover method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Get the reference to the hosts service:
HostsService hostsService = connection.systemService().hostsService();
// Find the host:
Host host = hostsService.list().search("name=myhost").send().hosts().get(0);
// Locate the service that manages the host, as that is where the action methods are defined:
HostService hostService = hostsService.hostService(host.id());
// Call the "iscsiDiscover" method of the service to start it:
HostService.IscsiDiscoverResponse response = hostService.iscsiDiscover().iscsi(iscsiDetails().address("myaddress")).send();
// Print only targets:
for (String target : response.iscsiTargets()) {
System.out.println(target);
}
// Print only address corresponding to target:
for (IscsiDetails detail : response.discoveredTargets()) {
System.out.println(detail.address() + ":" + detail.target());
}
// Close the connection to the server:
connection.close();
}
Aggregations