protected Service createSplunkService(final ProcessContext context) { final ServiceArgs serviceArgs = new ServiceArgs(); serviceArgs.setScheme(scheme); serviceArgs.setHost(host); serviceArgs.setPort(port); serviceArgs.setApp(app); serviceArgs.setOwner(owner); serviceArgs.setToken(token); serviceArgs.setUsername(username); serviceArgs.setPassword(password); serviceArgs.setSSLSecurityProtocol(SSLSecurityProtocol.valueOf(secProtocol));
/** * Create connection with the splunk server. */ @Override public void connect() { try { ServiceArgs loginArgs = new ServiceArgs(); loginArgs.setUsername(userName); loginArgs.setPassword(password); loginArgs.setHost(host); loginArgs.setPort(port); service = Service.connect(loginArgs); } catch (Exception e) { throw new RuntimeException("closing connection", e); } }
/** * @param app * The application context of the service. */ public void setApp(String app) { this.app = app; // for backward compatibility this.put("app", app); }
/** * Creates a new {@code Service} instance using a collection of arguments. * * @param args The {@code ServiceArgs} to initialize the service. */ // NOTE: This overload exists primarily to provide better documentation // for the "args" parameter. @SuppressWarnings("deprecation") public Service(ServiceArgs args) { super(); // NOTE: Must read the deprecated fields for backward compatibility. // (Consider the case where the fields are initialized directly, // rather than using the new setters.) // NOTE: Must also read the underlying dictionary for forward compatibility. // (Consider the case where the user calls Map.put() directly, // rather than using the new setters.) this.app = Args.<String>get(args, "app", args.app != null ? args.app : null); this.host = Args.<String>get(args, "host", args.host != null ? args.host : DEFAULT_HOST); this.owner = Args.<String>get(args, "owner", args.owner != null ? args.owner : null); this.port = Args.<Integer>get(args, "port", args.port != null ? args.port : DEFAULT_PORT); this.scheme = Args.<String>get(args, "scheme", args.scheme != null ? args.scheme : DEFAULT_SCHEME); this.token = Args.<String>get(args, "token", args.token != null ? args.token : null); this.username = (String)args.get("username"); this.password = (String)args.get("password"); this.httpsHandler = Args.<URLStreamHandler>get(args, "httpsHandler", null); this.setSslSecurityProtocol(Args.get(args, "SSLSecurityProtocol", Service.getSslSecurityProtocol())); this.addCookie((String)args.get("cookie")); }
/** * Create connection with the splunk server. */ @Override public void connect() { try{ ServiceArgs loginArgs = new ServiceArgs(); loginArgs.setUsername(userName); loginArgs.setPassword(password); loginArgs.setHost(host); loginArgs.setPort(port); service = Service.connect(loginArgs); } catch(Exception e){ throw new RuntimeException("closing connection", e); } }
/** * @param cookie * A valid login cookie. */ public void setCookie(String cookie) { this.put("cookie", cookie); } }
public void initialize(ThunderProperties properties) throws Exception { this.properties = properties; if (service == null) { try { ServiceArgs loginArgs = new ServiceArgs(); loginArgs.setHost(properties.getString(ThunderConstant.SPLUNK_HOST_ATTRIBUTE_NAME)); loginArgs.setPort(properties.getInteger(ThunderConstant.SPLUNK_PORT_ATTRIBUTE_NAME)); loginArgs.setUsername(properties.getString(ThunderConstant.SPLUNK_USER_NAME_ATTRIBUTE_NAME)); loginArgs.setPassword(properties.getString(ThunderConstant.SPLUNK_PASSWORD_ATTRIBUTE_NAME)); loginArgs.setSSLSecurityProtocol(SSLSecurityProtocol.TLSv1_2); service = Service.connect(loginArgs); } catch (Exception e) { LOG.error("Initialize Splunk connection failed", e); dispose(); } } }
/** * @param password * The password to use when logging in. */ public void setPassword(String password) { this.put("password", password); }
/** * @param username * The username to use when logging in. */ public void setUsername(String username) { this.put("username", username); }
/** * @param host * The host name of the service. */ public void setHost(String host) { this.host = host; // for backward compatibility this.put("host", host); }
/** * @param scheme * The scheme to use for accessing the service. */ public void setScheme(String scheme) { this.scheme = scheme; // for backward compatibility this.put("scheme", scheme); }
/** * @param securityProtocol * The SSL security protocol for the service. */ public void setSSLSecurityProtocol(SSLSecurityProtocol securityProtocol) { this.put("SSLSecurityProtocol", securityProtocol); }
/** * @param handler * A URLStreamHandler to handle HTTPS requests for the service. */ public void setHTTPSHandler(URLStreamHandler handler) { this.put("httpsHandler", handler); }
/** * @param owner * The owner context of the service. */ public void setOwner(String owner) { this.owner = owner; // for backward compatibility this.put("owner", owner); }
/** * @param port * The port number of the service. */ public void setPort(int port) { this.port = port; // for backward compatibility this.put("port", port); }
/** * @param token * A Splunk authentication token to use for the session. */ public void setToken(String token) { this.token = token; // for backward compatibility this.put("token", token); }