From b7428fe63d80ce150a964fae427f13c161f39164 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Sat, 8 Mar 2014 02:16:01 +0000 Subject: [PATCH] HADOOP-10393. Fix the javac warnings in hadoop-auth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1575470 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/KerberosAuthenticator.java | 2 +- .../client/TestKerberosAuthenticator.java | 10 ++++---- .../client/TestPseudoAuthenticator.java | 12 ++++----- .../server/TestAuthenticationFilter.java | 25 +++++++++++-------- .../hadoop-common/CHANGES.txt | 2 ++ .../org/apache/hadoop/minikdc/MiniKdc.java | 18 +++++++------ 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/KerberosAuthenticator.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/KerberosAuthenticator.java index 29f7c5d62e..e4ebf1b0d9 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/KerberosAuthenticator.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/KerberosAuthenticator.java @@ -313,7 +313,7 @@ public Void run() throws Exception { /* * Sends the Kerberos token to the server. */ - private void sendToken(byte[] outToken) throws IOException, AuthenticationException { + private void sendToken(byte[] outToken) throws IOException { String token = base64.encodeToString(outToken); conn = (HttpURLConnection) url.openConnection(); if (connConfigurator != null) { diff --git a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java index fd4b57258b..53d23c467a 100644 --- a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java +++ b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java @@ -57,7 +57,7 @@ public void testFallbacktoPseudoAuthenticator() throws Exception { Properties props = new Properties(); props.setProperty(AuthenticationFilter.AUTH_TYPE, "simple"); props.setProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "false"); - auth.setAuthenticationHandlerConfig(props); + AuthenticatorTestCase.setAuthenticationHandlerConfig(props); auth._testAuthentication(new KerberosAuthenticator(), false); } @@ -67,14 +67,14 @@ public void testFallbacktoPseudoAuthenticatorAnonymous() throws Exception { Properties props = new Properties(); props.setProperty(AuthenticationFilter.AUTH_TYPE, "simple"); props.setProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "true"); - auth.setAuthenticationHandlerConfig(props); + AuthenticatorTestCase.setAuthenticationHandlerConfig(props); auth._testAuthentication(new KerberosAuthenticator(), false); } @Test(timeout=60000) public void testNotAuthenticated() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration()); + AuthenticatorTestCase.setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration()); auth.start(); try { URL url = new URL(auth.getBaseURL()); @@ -90,7 +90,7 @@ public void testNotAuthenticated() throws Exception { @Test(timeout=60000) public void testAuthentication() throws Exception { final AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration()); KerberosTestUtils.doAsClient(new Callable() { @Override @@ -104,7 +104,7 @@ public Void call() throws Exception { @Test(timeout=60000) public void testAuthenticationPost() throws Exception { final AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration()); KerberosTestUtils.doAsClient(new Callable() { @Override diff --git a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java index 20ec587ac8..1bb9274644 100644 --- a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java +++ b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java @@ -40,7 +40,7 @@ public void testGetUserName() throws Exception { @Test public void testAnonymousAllowed() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(true)); auth.start(); try { @@ -56,7 +56,7 @@ public void testAnonymousAllowed() throws Exception { @Test public void testAnonymousDisallowed() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth.start(); try { @@ -72,7 +72,7 @@ public void testAnonymousDisallowed() throws Exception { @Test public void testAuthenticationAnonymousAllowed() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(true)); auth._testAuthentication(new PseudoAuthenticator(), false); } @@ -80,7 +80,7 @@ public void testAuthenticationAnonymousAllowed() throws Exception { @Test public void testAuthenticationAnonymousDisallowed() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth._testAuthentication(new PseudoAuthenticator(), false); } @@ -88,7 +88,7 @@ public void testAuthenticationAnonymousDisallowed() throws Exception { @Test public void testAuthenticationAnonymousAllowedWithPost() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(true)); auth._testAuthentication(new PseudoAuthenticator(), true); } @@ -96,7 +96,7 @@ public void testAuthenticationAnonymousAllowedWithPost() throws Exception { @Test public void testAuthenticationAnonymousDisallowedWithPost() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); - auth.setAuthenticationHandlerConfig( + AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth._testAuthentication(new PseudoAuthenticator(), true); } diff --git a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java index dcadf15f51..a876a88ac8 100644 --- a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java +++ b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java @@ -13,15 +13,11 @@ */ package org.apache.hadoop.security.authentication.server; -import org.apache.hadoop.security.authentication.client.AuthenticatedURL; -import org.apache.hadoop.security.authentication.client.AuthenticationException; -import org.apache.hadoop.security.authentication.util.Signer; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Properties; +import java.util.Vector; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -31,8 +27,15 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; + +import org.apache.hadoop.security.authentication.client.AuthenticatedURL; +import org.apache.hadoop.security.authentication.client.AuthenticationException; +import org.apache.hadoop.security.authentication.util.Signer; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; public class TestAuthenticationFilter { diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index aba471af17..0120ad0ad4 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -411,6 +411,8 @@ Release 2.4.0 - UNRELEASED HADOOP-10353. FsUrlStreamHandlerFactory is not thread safe. (Tudor Scurtu via cnauroth) + HADOOP-10393. Fix the javac warnings in hadoop-auth. (szetszwo) + BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS HADOOP-10185. FileSystem API for ACLs. (cnauroth) diff --git a/hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java b/hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java index 8eb24e9fc3..7dc082b107 100644 --- a/hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java +++ b/hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java @@ -41,6 +41,7 @@ import org.apache.directory.server.kerberos.shared.keytab.KeytabEntry; import org.apache.directory.server.protocol.shared.transport.TcpTransport; import org.apache.directory.server.protocol.shared.transport.UdpTransport; +import org.apache.directory.server.xdbm.Index; import org.apache.directory.shared.kerberos.KerberosTime; import org.apache.directory.shared.kerberos.codec.types.EncryptionType; import org.apache.directory.shared.kerberos.components.EncryptionKey; @@ -134,7 +135,7 @@ public static void main(String[] args) throws Exception { r.close(); } } - for (Map.Entry entry : userConf.entrySet()) { + for (Map.Entry entry : userConf.entrySet()) { conf.put(entry.getKey(), entry.getValue()); } final MiniKdc miniKdc = new MiniKdc(conf, workDir); @@ -250,7 +251,7 @@ public MiniKdc(Properties conf, File workDir) throws Exception { } LOG.info("Configuration:"); LOG.info("---------------------------------------------------------------"); - for (Map.Entry entry : conf.entrySet()) { + for (Map.Entry entry : conf.entrySet()) { LOG.info(" {}: {}", entry.getKey(), entry.getValue()); } LOG.info("---------------------------------------------------------------"); @@ -311,7 +312,6 @@ public synchronized void start() throws Exception { initKDCServer(); } - @SuppressWarnings("unchecked") private void initDirectoryService() throws Exception { ds = new DefaultDirectoryService(); ds.setInstanceLayout(new InstanceLayout(workDir)); @@ -364,7 +364,7 @@ private void initDirectoryService() throws Exception { partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain)); ds.addPartition(partition); // indexes - Set indexedAttributes = new HashSet(); + Set> indexedAttributes = new HashSet>(); indexedAttributes.add(new JdbmIndex("objectClass", false)); indexedAttributes.add(new JdbmIndex("dc", false)); indexedAttributes.add(new JdbmIndex("ou", false)); @@ -398,9 +398,13 @@ private void initKDCServer() throws Exception { SchemaManager schemaManager = ds.getSchemaManager(); final String content = StrSubstitutor.replace(IOUtils.toString(is), map); LdifReader reader = new LdifReader(new StringReader(content)); - for (LdifEntry ldifEntry : reader) { - ds.getAdminSession().add(new DefaultEntry(schemaManager, - ldifEntry.getEntry())); + try { + for (LdifEntry ldifEntry : reader) { + ds.getAdminSession().add(new DefaultEntry(schemaManager, + ldifEntry.getEntry())); + } + } finally { + reader.close(); } kdc = new KdcServer();