apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidyan74 <...@git.apache.org>
Subject [GitHub] incubator-apex-core pull request: APEXCORE-397 Allow configurabili...
Date Tue, 22 Mar 2016 17:56:12 GMT
Github user davidyan74 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/277#discussion_r57036460
  
    --- Diff: engine/src/main/java/com/datatorrent/stram/util/SecurityUtils.java ---
    @@ -0,0 +1,74 @@
    +/**
    + * 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 com.datatorrent.stram.util;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.security.UserGroupInformation;
    +
    +import com.datatorrent.api.Context;
    +import com.datatorrent.api.Context.StramHTTPAuthentication;
    +
    +/**
    + *
    + */
    +public class SecurityUtils
    +{
    +
    +  public static final String HADOOP_HTTP_AUTH_PROP = "hadoop.http.authentication.type";
    +  private static final String HADOOP_HTTP_AUTH_VALUE_SIMPLE = "simple";
    +
    +  private static boolean stramWebSecurityEnabled;
    +  private static boolean hadoopWebSecurityEnabled;
    +
    +  // If not initialized explicitly default to Hadoop auth
    +  static {
    +    hadoopWebSecurityEnabled = stramWebSecurityEnabled = UserGroupInformation.isSecurityEnabled();
    +  }
    +
    +  public static void init(Configuration configuration, StramHTTPAuthentication stramHTTPAuth)
    +  {
    +    hadoopWebSecurityEnabled = false;
    +    String authValue = configuration.get(HADOOP_HTTP_AUTH_PROP);
    +    if ((authValue != null) && !authValue.equals(HADOOP_HTTP_AUTH_VALUE_SIMPLE))
{
    +      hadoopWebSecurityEnabled = true;
    +    }
    +    // Stram http auth may not be specified and is null but still set a default
    +    boolean authDefault = false;
    +    if (stramHTTPAuth != null) {
    +      if (stramHTTPAuth == Context.StramHTTPAuthentication.FOLLOW_HADOOP_HTTP_AUTH) {
    +        stramWebSecurityEnabled = hadoopWebSecurityEnabled;
    +      } else if (stramHTTPAuth == StramHTTPAuthentication.FOLLOW_HADOOP_AUTH) {
    +        stramWebSecurityEnabled = UserGroupInformation.isSecurityEnabled();
    +      } else if (stramHTTPAuth == StramHTTPAuthentication.ENABLE) {
    +        stramWebSecurityEnabled = true;
    +      } else if (stramHTTPAuth == StramHTTPAuthentication.DISABLE) {
    +        stramWebSecurityEnabled = false;
    +      }
    +    }
    +  }
    +
    +  public static boolean isHadoopWebSecurityEnabled() {
    --- End diff --
    
    open curly brace following definition should be on a newline


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message