Skip to content

Commit

Permalink
Extract SystemProperties into plugin-toolkit module
Browse files Browse the repository at this point in the history
Allows reduction of boilerplate related to system properties
  • Loading branch information
grantatspothero authored and hashhar committed Feb 24, 2022
1 parent 5b3d68e commit b738961
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import static com.google.common.base.Preconditions.checkState;
import static com.google.common.net.HttpHeaders.AUTHORIZATION;
import static io.trino.plugin.base.util.SystemProperties.setJavaSecurityKrb5Conf;
import static io.trino.server.security.UserMapping.createUserMapping;
import static java.util.Objects.requireNonNull;
import static javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
Expand All @@ -70,14 +69,7 @@ public KerberosAuthenticator(KerberosConfig config)
requireNonNull(config, "config is null");
this.userMapping = createUserMapping(config.getUserMappingPattern(), config.getUserMappingFile());

String newValue = config.getKerberosConfig().getAbsolutePath();
String currentValue = System.getProperty("java.security.krb5.conf");
checkState(
currentValue == null || Objects.equals(currentValue, newValue),
"Refusing to set system property 'java.security.krb5.conf' to '%s', it is already set to '%s'",
newValue,
currentValue);
System.setProperty("java.security.krb5.conf", newValue);
setJavaSecurityKrb5Conf(config.getKerberosConfig().getAbsolutePath());

try {
String hostname = Optional.ofNullable(config.getPrincipalHostname())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.plugin.kudu;
package io.trino.plugin.base.util;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

import static io.airlift.configuration.ConditionalModule.conditionalModule;
import static io.airlift.configuration.ConfigBinder.configBinder;
import static io.trino.plugin.base.util.SystemProperties.setJavaSecurityKrb5Conf;
import static io.trino.plugin.kudu.KuduAuthenticationConfig.KuduAuthenticationType.KERBEROS;
import static io.trino.plugin.kudu.KuduAuthenticationConfig.KuduAuthenticationType.NONE;
import static io.trino.plugin.kudu.SystemProperties.setJavaSecurityKrb5Conf;
import static java.util.Objects.requireNonNull;
import static org.apache.kudu.client.KuduClient.KuduClientBuilder;

Expand Down

0 comments on commit b738961

Please sign in to comment.