/*
 * Copyright 2016 Spotify AB.
 *
 * Licensed 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.google.cloud.dataflow.contrib.hadoop;

import com.google.common.base.Preconditions;

/**
 * Utils for Hadoop/HDFS Authentication.
 */
public class HadoopUserUtils {
  /**
   * Set username for Simple Authentication.
   */
  public static void setSimpleAuthUser(String user) {
    Preconditions.checkNotNull(user);
    Preconditions.checkArgument(!user.isEmpty());

    // Keep in mind that this has to happen before Filesystem object is created.
    System.setProperty("HADOOP_USER_NAME", user);
  }
}

@@ -694,144 +694,749 @@
 s;%0A%0A
-/**%0A * Utils for Hadoop/HDFS Authentication.%0A */%0Apublic class HadoopUserUtils %7B%0A  /**%0A   * Set username for Simple Authentication.%0A   */
+import java.io.Externalizable;%0Aimport java.io.IOException;%0Aimport java.io.ObjectInput;%0Aimport java.io.ObjectOutput;%0A%0A/**%0A * Utils for Hadoop/HDFS Authentication. It's externalizable so that we can pass it around%0A * as part of Source/Bundles.%0A */%0Apublic class HadoopUserUtils implements Externalizable %7B%0A  private static String user;%0A%0A  private static final String DEFAULT_USERNAME = %22default_username%22;%0A  private static final String HADOOP_USER_NAME_KEY = %22HADOOP_USER_NAME%22;%0A%0A  static %7B%0A    String localUser = System.getProperty(%22user.name%22);%0A    if (localUser == null %7C%7C localUser.isEmpty()) %7B%0A      user = DEFAULT_USERNAME;%0A    %7D else %7B%0A      user = localUser;%0A    %7D%0A  %7D%0A%0A  public static String getSimpleAuthUser() %7B%0A    return user;%0A  %7D%0A
 %0A  p
@@ -1679,17 +1679,16 @@
 roperty(
-%22
 HADOOP_U
@@ -1695,17 +1695,421 @@
 SER_NAME
-%22
+_KEY, user);%0A    HadoopUserUtils.user = user;%0A  %7D%0A%0A  @Override%0A  public void writeExternal(ObjectOutput out) throws IOException %7B%0A    out.writeUTF(user);%0A  %7D%0A%0A  @Override%0A  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException %7B%0A    HadoopUserUtils.user = in.readUTF();%0A    // set property on deserialization to keep jvm up to date%0A    System.setProperty(HADOOP_USER_NAME_KEY
 , user);

Make HadoopUserUtils externalizable