Skip to content

Commit

Permalink
RANGER-3515: Enhance Ranger Java client SSL config to be configured u…
Browse files Browse the repository at this point in the history
…sing serviceType and AppId

Signed-off-by: Sailaja Polavarapu <spolavarapu@cloudera.com>
  • Loading branch information
kumaab authored and spolavarpau1 committed Nov 22, 2021
1 parent 5fb097f commit b56aa63
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions intg/src/main/java/org/apache/ranger/RangerClient.java
Expand Up @@ -19,6 +19,7 @@
package org.apache.ranger;

import com.sun.jersey.api.client.GenericType;
import org.apache.ranger.authorization.hadoop.config.RangerPluginConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.jersey.api.client.ClientResponse;
Expand Down Expand Up @@ -142,9 +143,7 @@ public class RangerClient {
private boolean isSecureMode = false;
private Subject sub = null;

public RangerClient(String hostName, String authType, String username, String password, String configFile) {
restClient = new RangerRESTClient(hostName, configFile, new Configuration());

private void authInit(String authType, String username, String password) {
if (AUTH_KERBEROS.equalsIgnoreCase(authType)) {
if (SecureClientLogin.isKerberosCredentialExists(username, password)) {
isSecureMode = true;
Expand All @@ -159,6 +158,17 @@ public RangerClient(String hostName, String authType, String username, String pa
}
}

public RangerClient(String hostName, String authType, String username, String password, String configFile) {
restClient = new RangerRESTClient(hostName, configFile, new Configuration());
authInit(authType, username, password);
}

public RangerClient(String hostname, String authType, String username, String password, String appId, String serviceType){
this(hostname, authType, username, password,
new RangerPluginConfig(serviceType, null,appId,null,null,null)
.get("ranger.plugin." + serviceType + ".policy.rest.ssl.config.file"));
}


public RangerClient(RangerRESTClient restClient) {
this.restClient = restClient;
Expand Down

0 comments on commit b56aa63

Please sign in to comment.