Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1027#discussion_r50314937
  
    --- Diff: storm-core/src/jvm/org/apache/storm/messaging/netty/Login.java ---
    @@ -0,0 +1,411 @@
    +/**
    + * 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.storm.messaging.netty;
    +
    +/**
    + * This class is responsible for refreshing Kerberos credentials for
    + * logins for both Zookeeper client and server.
    + * See ZooKeeperSaslServer for server-side usage.
    + * See ZooKeeperSaslClient for client-side usage.
    + * This class is a copied from 
https://github.com/apache/zookeeper/blob/branch-3.4/src/java/main/org/apache/zookeeper/Login.java
    + * with the difference that refresh thread does not die.
    + */
    +
    +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 javax.security.auth.callback.CallbackHandler;
    +
    +import org.apache.log4j.Logger;
    +import org.apache.zookeeper.Shell;
    +import org.apache.zookeeper.client.ZooKeeperSaslClient;
    +import javax.security.auth.kerberos.KerberosTicket;
    +import javax.security.auth.Subject;
    +import java.util.Date;
    +import java.util.Random;
    +import java.util.Set;
    +
    +public class Login {
    +    Logger LOG = Logger.getLogger(Login.class);
    +    public CallbackHandler callbackHandler;
    +
    +    // LoginThread will sleep until 80% of time from last refresh to
    +    // ticket's expiry has been reached, at which time it will wake
    +    // and try to renew the ticket.
    +    private static final float TICKET_RENEW_WINDOW = 0.80f;
    +
    +    /**
    +     * Percentage of random jitter added to the renewal time
    +     */
    +    private static final float TICKET_RENEW_JITTER = 0.05f;
    +
    +    // Regardless of TICKET_RENEW_WINDOW setting above and the ticket 
expiry time,
    +    // thread will not sleep between refresh attempts any less than 1 
minute (60*1000 milliseconds = 1 minute).
    +    // Change the '1' to e.g. 5, to change this to 5 minutes.
    +    private static final long MIN_TIME_BEFORE_RELOGIN = 1 * 60 * 1000L;
    +
    +    private Subject subject = null;
    +    private Thread t = null;
    +    private boolean isKrbTicket = false;
    +    private boolean isUsingTicketCache = false;
    +    private boolean isUsingKeytab = false;
    +
    +    /** Random number generator */
    +    private static Random rng = new Random();
    +
    +    private LoginContext login = null;
    +    private String loginContextName = null;
    +    private String keytabFile = null;
    +    private String principal = null;
    +
    +    private long lastLogin = 0;
    +
    +    /**
    +     * LoginThread constructor. The constructor starts the thread used
    --- End diff --
    
    I'm not sure we want to push this back to zookeeper.  Login feels like it 
was an internal class not meant for others to use.  We probably never should 
have used it, and forking it is the right thing to do long term.  Even if we do 
push a fix back to zookeeper.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to