@Override public Pair<THBaseService.Client, TTransport> getClient() throws IOException { Preconditions.checkArgument(connection.getHost().startsWith("http"), "http client host must start with http or https"); String url = connection.getHost() + ":" + connection.getPort(); try { THttpClient httpClient = new THttpClient(url, connection.getHttpClient()); for (Map.Entry<String, String> header : customHeader.entrySet()) { httpClient.setCustomHeader(header.getKey(), header.getValue()); } httpClient.open(); TProtocol prot = new TBinaryProtocol(httpClient); THBaseService.Client client = new THBaseService.Client(prot); return new Pair<>(client, httpClient); } catch (TTransportException e) { throw new IOException(e); } } }
String url = "http://" + host + ":" + port; THttpClient httpClient = new THttpClient(url); httpClient.open(); TProtocol protocol = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(protocol);
protected void talkToThriftServer(String url, int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient(url); httpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } httpClient.setCustomHeader("User-Agent", sb.toString()); } try { TProtocol prot; prot = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { httpClient.close(); } }
@Override protected void talkToThriftServer(String url, int customHeaderSize) throws Exception { // Close httpClient and THttpClient automatically on any failures try ( CloseableHttpClient httpClient = createHttpClient(); THttpClient tHttpClient = new THttpClient(url, httpClient) ) { tHttpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } tHttpClient.setCustomHeader(HttpHeaders.USER_AGENT, sb.toString()); } TProtocol prot = new TBinaryProtocol(tHttpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated) { TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } }
@Override protected void talkToThriftServer(String url, int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient(url); httpClient.open();
@Override public ThriftEventTransmissionService.Client makeObject(Object key) throws TTransportException { String[] keyElements = key.toString().split(AgentConstants.SEPARATOR); if (keyElements[0].equals(ReceiverConfiguration.Protocol.TCP.toString())) { String[] hostNameAndPort = keyElements[1].split(AgentConstants.HOSTNAME_AND_PORT_SEPARATOR); TTransport receiverTransport = null; try { receiverTransport = new TSocket(HostAddressFinder.findAddress(hostNameAndPort[0]), Integer.parseInt(hostNameAndPort[1])); } catch (SocketException ignored) { //already checked } TProtocol protocol = new TBinaryProtocol(receiverTransport); ThriftEventTransmissionService.Client client = new ThriftEventTransmissionService.Client(protocol); receiverTransport.open(); return client; } else { THttpClient client = new THttpClient("http://" + keyElements[1] + "/thriftReceiver"); TProtocol protocol = new TCompactProtocol(client); ThriftEventTransmissionService.Client publisherClient = new ThriftEventTransmissionService.Client(protocol); client.open(); return publisherClient; } }
public AuthQrcode loginWithQrCode() throws Exception { // Request QrCode from LINE server. // Map<String, String> json = null; boolean keepLoggedIn = false; THttpClient transport = new THttpClient(LINE_HTTP_URL, httpClient); transport.open(); TProtocol protocol = new TCompactProtocol(transport); this.client = new TalkService.Client(protocol); AuthQrcode result = this.client.getAuthQrcode(keepLoggedIn, systemName); setAuthToken(result.getVerifier()); System.out.println("Retrieved QR Code."); return result; // await for QR code to be certified, it will return a verifier afterward. // loginWithVerifier(); }
public void loginWithAuthToken(String authToken) throws Exception { THttpClient transport = new THttpClient(LINE_HTTP_IN_URL, httpClient); transport.setCustomHeader(X_LINE_ACCESS, authToken); transport.open(); TProtocol protocol = new TCompactProtocol(transport); setClient(new TalkService.Client(protocol)); setAuthToken(authToken); }
private boolean authenticate() throws EntitlementProxyException { boolean isAuthenticated; try { THttpClient client = new THttpClient(serverUrl); TProtocol protocol = new TCompactProtocol(client); AuthenticatorService.Client authClient = new AuthenticatorService.Client(protocol); client.open(); sessionId = authClient.authenticate(userName, password); client.close(); isAuthenticated = true; } catch (Exception e) { throw new EntitlementProxyException("Error while authenticating with ThriftAuthenticator", e); } return isAuthenticated; }
private boolean authenticate() throws EntitlementProxyException { boolean isAuthenticated; try { THttpClient client = new THttpClient(serverUrl); TProtocol protocol = new TCompactProtocol(client); AuthenticatorService.Client authClient = new AuthenticatorService.Client(protocol); client.open(); sessionId = authClient.authenticate(userName, password); client.close(); isAuthenticated = true; } catch (Exception e) { throw new EntitlementProxyException("Error while authenticating with ThriftAuthenticator", e); } return isAuthenticated; }
transport.open(); LoginResult result; TProtocol protocol = new TCompactProtocol(transport);
TProtocol protocol = new TCompactProtocol(tclient); ThriftSecureEventTransmissionService.Client authClient = new ThriftSecureEventTransmissionService.Client(protocol); tclient.open(); return authClient; } catch (Exception e) {
String url = "http://" + host + ":" + port; THttpClient httpClient = new THttpClient(url); httpClient.open(); TProtocol protocol = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(protocol);
public String getSessionId(String userName, String password) throws AuthenticationException { String sessionId = null; try { TProtocol protocol = new TCompactProtocol(client); AuthenticatorService.Client authClient = new AuthenticatorService.Client(protocol); client.open(); sessionId = authClient.authenticate(userName, password); client.close(); } catch (TTransportException e) { throw new AuthenticationException("Error in authenticating with thrift client..", e); } catch (TException e) { throw new AuthenticationException("Error in authenticating with thrift client..", e); } catch (AuthenticationException e) { throw new AuthenticationException("Error in authenticating with thrift client..", e); } finally { if (client != null) { client.close(); } } return sessionId; }
public String getSessionId(String userName, String password) throws AuthenticationException { try { //if (sessionId == null) { TProtocol protocol = new TCompactProtocol(client); AuthenticatorService.Client authClient = new AuthenticatorService.Client( protocol); client.open(); sessionId = authClient.authenticate(userName, password); client.close(); //} } catch (TTransportException e) { throw new AuthenticationException("Error in authenticating with thrift client.."); } catch (TException e) { throw new AuthenticationException("Error in authenticating with thrift client.."); } catch (AuthenticationException e) { throw new AuthenticationException("Error in authenticating with thrift client.."); } finally { if (client != null) { client.close(); } } return sessionId; }
private void talkToThriftServer(int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient( "http://"+ HConstants.LOCALHOST + ":" + port); httpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } httpClient.setCustomHeader("User-Agent", sb.toString()); } try { TProtocol prot; prot = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { httpClient.close(); } }
@Override void talkToThriftServer(String url, int customHeaderSize) throws Exception { // Close httpClient and THttpClient automatically on any failures try ( CloseableHttpClient httpClient = createHttpClient(); THttpClient tHttpClient = new THttpClient(url, httpClient) ) { tHttpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } tHttpClient.setCustomHeader(HttpHeaders.USER_AGENT, sb.toString()); } TProtocol prot = new TBinaryProtocol(tHttpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated) { TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } }
void talkToThriftServer(String url, int customHeaderSize) throws Exception { THttpClient httpClient = new THttpClient(url); httpClient.open(); if (customHeaderSize > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < customHeaderSize; i++) { sb.append("a"); } httpClient.setCustomHeader("User-Agent", sb.toString()); } try { TProtocol prot; prot = new TBinaryProtocol(httpClient); Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { httpClient.close(); } }