yangyichao-mango commented on a change in pull request #3264:
URL: 
https://github.com/apache/incubator-dolphinscheduler/pull/3264#discussion_r461521420



##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClient.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.common.utils;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * kerberos http client
+ */
+public class KerberosHttpClient {
+
+    public static final Logger logger = 
LoggerFactory.getLogger(KerberosHttpClient.class);
+
+    private String principal;
+    private String keyTabLocation;
+
+    public KerberosHttpClient(String principal, String keyTabLocation) {
+       super();
+       this.principal = principal;
+       this.keyTabLocation = keyTabLocation;
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, boolean 
isDebug) {
+       this(principal, keyTabLocation);
+       if (isDebug) {
+           System.setProperty("sun.security.spnego.debug", "true");
+           System.setProperty("sun.security.krb5.debug", "true");
+       }
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, String 
krb5Location, boolean isDebug) {
+       this(principal, keyTabLocation, isDebug);
+       System.setProperty("java.security.krb5.conf", krb5Location);
+    }

Review comment:
       ```suggestion
       public KerberosHttpClient(String principal, String keyTabLocation) {
           this(principal, keyTabLocation, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
boolean isDebug) {
        this(principal, keyTabLocation, StringUtils.EMPTY, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
String krb5Location, boolean isDebug) {
           this.principal = principal;
        this.keyTabLocation = keyTabLocation;
        System.setProperty("java.security.krb5.conf", krb5Location);
        if (isDebug) {
            System.setProperty("sun.security.spnego.debug", "true");
            System.setProperty("sun.security.krb5.debug", "true");
        }
       }
   ```

##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClient.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.common.utils;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * kerberos http client
+ */
+public class KerberosHttpClient {
+
+    public static final Logger logger = 
LoggerFactory.getLogger(KerberosHttpClient.class);
+
+    private String principal;
+    private String keyTabLocation;
+
+    public KerberosHttpClient(String principal, String keyTabLocation) {
+       super();
+       this.principal = principal;
+       this.keyTabLocation = keyTabLocation;
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, boolean 
isDebug) {
+       this(principal, keyTabLocation);
+       if (isDebug) {
+           System.setProperty("sun.security.spnego.debug", "true");
+           System.setProperty("sun.security.krb5.debug", "true");
+       }
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, String 
krb5Location, boolean isDebug) {
+       this(principal, keyTabLocation, isDebug);
+       System.setProperty("java.security.krb5.conf", krb5Location);
+    }

Review comment:
       ```suggestion
       public KerberosHttpClient(String principal, String keyTabLocation) {
           this(principal, keyTabLocation, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
boolean isDebug) {
        this(principal, keyTabLocation, StringUtils.EMPTY, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
String krb5Location, boolean isDebug) {
        this.principal = principal;
        this.keyTabLocation = keyTabLocation;
        System.setProperty("java.security.krb5.conf", krb5Location);
        if (isDebug) {
            System.setProperty("sun.security.spnego.debug", "true");
            System.setProperty("sun.security.krb5.debug", "true");
        }
       }
   ```

##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClient.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.common.utils;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * kerberos http client
+ */
+public class KerberosHttpClient {
+
+    public static final Logger logger = 
LoggerFactory.getLogger(KerberosHttpClient.class);
+
+    private String principal;
+    private String keyTabLocation;
+
+    public KerberosHttpClient(String principal, String keyTabLocation) {
+       super();
+       this.principal = principal;
+       this.keyTabLocation = keyTabLocation;
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, boolean 
isDebug) {
+       this(principal, keyTabLocation);
+       if (isDebug) {
+           System.setProperty("sun.security.spnego.debug", "true");
+           System.setProperty("sun.security.krb5.debug", "true");
+       }
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, String 
krb5Location, boolean isDebug) {
+       this(principal, keyTabLocation, isDebug);
+       System.setProperty("java.security.krb5.conf", krb5Location);
+    }

Review comment:
       ```suggestion
       public KerberosHttpClient(String principal, String keyTabLocation) {
           this(principal, keyTabLocation, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
boolean isDebug) {
        this(principal, keyTabLocation, StringUtils.EMPTY, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
String krb5Location, boolean isDebug) {
         this.principal = principal;
        this.keyTabLocation = keyTabLocation;
        System.setProperty("java.security.krb5.conf", krb5Location);
        if (isDebug) {
            System.setProperty("sun.security.spnego.debug", "true");
            System.setProperty("sun.security.krb5.debug", "true");
        }
       }
   ```

##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClient.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.common.utils;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * kerberos http client
+ */
+public class KerberosHttpClient {
+
+    public static final Logger logger = 
LoggerFactory.getLogger(KerberosHttpClient.class);
+
+    private String principal;
+    private String keyTabLocation;
+
+    public KerberosHttpClient(String principal, String keyTabLocation) {
+       super();
+       this.principal = principal;
+       this.keyTabLocation = keyTabLocation;
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, boolean 
isDebug) {
+       this(principal, keyTabLocation);
+       if (isDebug) {
+           System.setProperty("sun.security.spnego.debug", "true");
+           System.setProperty("sun.security.krb5.debug", "true");
+       }
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, String 
krb5Location, boolean isDebug) {
+       this(principal, keyTabLocation, isDebug);
+       System.setProperty("java.security.krb5.conf", krb5Location);
+    }

Review comment:
       ```suggestion
       public KerberosHttpClient(String principal, String keyTabLocation) {
           this(principal, keyTabLocation, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
boolean isDebug) {
        this(principal, keyTabLocation, StringUtils.EMPTY, false);
       }
   
       public KerberosHttpClient(String principal, String keyTabLocation, 
String krb5Location, boolean isDebug) {
         this.principal = principal;
        this.keyTabLocation = keyTabLocation;
        if (StringUtils.isNotEmpty(krb5Location)) {
            System.setProperty("java.security.krb5.conf", krb5Location);
        }
        if (isDebug) {
            System.setProperty("sun.security.spnego.debug", "true");
            System.setProperty("sun.security.krb5.debug", "true");
        }
       }
   ```

##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClient.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.common.utils;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * kerberos http client
+ */
+public class KerberosHttpClient {
+
+    public static final Logger logger = 
LoggerFactory.getLogger(KerberosHttpClient.class);
+
+    private String principal;
+    private String keyTabLocation;
+
+    public KerberosHttpClient(String principal, String keyTabLocation) {
+       super();
+       this.principal = principal;
+       this.keyTabLocation = keyTabLocation;
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, boolean 
isDebug) {
+       this(principal, keyTabLocation);
+       if (isDebug) {
+           System.setProperty("sun.security.spnego.debug", "true");
+           System.setProperty("sun.security.krb5.debug", "true");
+       }
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, String 
krb5Location, boolean isDebug) {
+       this(principal, keyTabLocation, isDebug);
+       System.setProperty("java.security.krb5.conf", krb5Location);
+    }

Review comment:
       The other part LGTM.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to