001 /**
002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 * You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software
010 * distributed under the License is distributed on an "AS IS" BASIS,
011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 * See the License for the specific language governing permissions and
013 * limitations under the License. See accompanying LICENSE file.
014 */
015 package org.apache.oozie.action.hadoop;
016
017 import java.io.IOException;
018
019 import org.apache.hadoop.mapred.JobClient;
020 import org.apache.hadoop.mapred.JobConf;
021 import org.apache.hadoop.util.ReflectionUtils;
022 import org.apache.oozie.service.HadoopAccessorService;
023 import org.apache.oozie.service.Services;
024
025 //TODO this class can go away once we use only 20.100+
026 public class AuthHelper {
027 private static Class<? extends AuthHelper> KLASS = null;
028
029 @SuppressWarnings("unchecked")
030 public synchronized static AuthHelper get() {
031 if (KLASS == null) {
032 HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
033 if (has.getClass() == HadoopAccessorService.class) {
034 KLASS = AuthHelper.class;
035 }
036 else {
037 try {
038 KLASS = (Class<? extends AuthHelper>) Class
039 .forName("org.apache.oozie.action.hadoop.KerberosAuthHelper");
040 }
041 catch (ClassNotFoundException e) {
042 throw new RuntimeException(e);
043 }
044 }
045 }
046 return ReflectionUtils.newInstance(KLASS, null);
047 }
048
049 public void set(JobClient jobClient, JobConf jobConf) throws IOException, InterruptedException {
050 }
051
052 }