Revert "HADOOP-14799. Update nimbus-jose-jwt to 4.41.1. (rchiang)"

This reverts commit 557d6f2814.
This commit is contained in:
Kihwal Lee 2018-02-14 15:22:05 -06:00
parent 557d6f2814
commit 5b4725fb04
4 changed files with 23 additions and 16 deletions

View File

@ -28,7 +28,6 @@ import java.text.ParseException;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.hadoop.security.authentication.client.AuthenticationException;
import org.apache.hadoop.security.authentication.util.CertificateUtil; import org.apache.hadoop.security.authentication.util.CertificateUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -217,8 +216,7 @@ public class JWTRedirectAuthenticationHandler extends
* @param request for getting the original request URL * @param request for getting the original request URL
* @return url to use as login url for redirect * @return url to use as login url for redirect
*/ */
@VisibleForTesting protected String constructLoginURL(HttpServletRequest request) {
String constructLoginURL(HttpServletRequest request) {
String delimiter = "?"; String delimiter = "?";
if (authenticationProviderUrl.contains("?")) { if (authenticationProviderUrl.contains("?")) {
delimiter = "&"; delimiter = "&";

View File

@ -47,7 +47,7 @@ import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT; import com.nimbusds.jwt.SignedJWT;
import com.nimbusds.jose.crypto.RSASSASigner; import com.nimbusds.jose.crypto.RSASSASigner;
public class TestJWTRedirectAuthenticationHandler extends public class TestJWTRedirectAuthentictionHandler extends
KerberosSecurityTestcase { KerberosSecurityTestcase {
private static final String SERVICE_URL = "https://localhost:8888/resource"; private static final String SERVICE_URL = "https://localhost:8888/resource";
private static final String REDIRECT_LOCATION = private static final String REDIRECT_LOCATION =
@ -392,7 +392,7 @@ public class TestJWTRedirectAuthenticationHandler extends
new StringBuffer(SERVICE_URL)); new StringBuffer(SERVICE_URL));
Mockito.when(request.getQueryString()).thenReturn("name=value"); Mockito.when(request.getQueryString()).thenReturn("name=value");
String loginURL = handler.constructLoginURL(request); String loginURL = ((TestJWTRedirectAuthenticationHandler)handler).testConstructLoginURL(request);
Assert.assertNotNull("loginURL should not be null.", loginURL); Assert.assertNotNull("loginURL should not be null.", loginURL);
Assert.assertEquals("https://localhost:8443/authserver?originalUrl=" + SERVICE_URL + "?name=value", loginURL); Assert.assertEquals("https://localhost:8443/authserver?originalUrl=" + SERVICE_URL + "?name=value", loginURL);
} }
@ -409,7 +409,7 @@ public class TestJWTRedirectAuthenticationHandler extends
new StringBuffer(SERVICE_URL)); new StringBuffer(SERVICE_URL));
Mockito.when(request.getQueryString()).thenReturn(null); Mockito.when(request.getQueryString()).thenReturn(null);
String loginURL = handler.constructLoginURL(request); String loginURL = ((TestJWTRedirectAuthenticationHandler)handler).testConstructLoginURL(request);
Assert.assertNotNull("LoginURL should not be null.", loginURL); Assert.assertNotNull("LoginURL should not be null.", loginURL);
Assert.assertEquals("https://localhost:8443/authserver?originalUrl=" + SERVICE_URL, loginURL); Assert.assertEquals("https://localhost:8443/authserver?originalUrl=" + SERVICE_URL, loginURL);
} }
@ -425,7 +425,7 @@ public class TestJWTRedirectAuthenticationHandler extends
publicKey = (RSAPublicKey) kp.getPublic(); publicKey = (RSAPublicKey) kp.getPublic();
privateKey = (RSAPrivateKey) kp.getPrivate(); privateKey = (RSAPrivateKey) kp.getPrivate();
handler = new JWTRedirectAuthenticationHandler(); handler = new TestJWTRedirectAuthenticationHandler();
} }
protected void setupKerberosRequirements() throws Exception { protected void setupKerberosRequirements() throws Exception {
@ -453,16 +453,15 @@ public class TestJWTRedirectAuthenticationHandler extends
protected SignedJWT getJWT(String sub, Date expires, RSAPrivateKey privateKey) protected SignedJWT getJWT(String sub, Date expires, RSAPrivateKey privateKey)
throws Exception { throws Exception {
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder() JWTClaimsSet claimsSet = new JWTClaimsSet();
.subject(sub) claimsSet.setSubject(sub);
.issueTime(new Date(new Date().getTime())) claimsSet.setIssueTime(new Date(new Date().getTime()));
.issuer("https://c2id.com") claimsSet.setIssuer("https://c2id.com");
.claim("scope", "openid") claimsSet.setCustomClaim("scope", "openid");
.audience("bar") claimsSet.setExpirationTime(expires);
.expirationTime(expires)
.build();
List<String> aud = new ArrayList<String>(); List<String> aud = new ArrayList<String>();
aud.add("bar"); aud.add("bar");
claimsSet.setAudience("bar");
JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.RS256).build(); JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.RS256).build();
@ -473,4 +472,10 @@ public class TestJWTRedirectAuthenticationHandler extends
return signedJWT; return signedJWT;
} }
class TestJWTRedirectAuthenticationHandler extends JWTRedirectAuthenticationHandler {
public String testConstructLoginURL(HttpServletRequest req) {
return constructLoginURL(req);
}
};
} }

View File

@ -25,7 +25,9 @@ import java.net.HttpURLConnection;
import org.apache.hadoop.fs.ChecksumException; import org.apache.hadoop.fs.ChecksumException;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.MapOutputFile;
import org.apache.hadoop.mapreduce.MRJobConfig; import org.apache.hadoop.mapreduce.MRJobConfig;
import org.apache.hadoop.mapreduce.TaskID;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
@ -64,6 +66,8 @@ import org.junit.Test;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import com.nimbusds.jose.util.StringUtils;
/** /**
* Test that the Fetcher does what we expect it to. * Test that the Fetcher does what we expect it to.
*/ */

View File

@ -1139,7 +1139,7 @@
<dependency> <dependency>
<groupId>com.nimbusds</groupId> <groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId> <artifactId>nimbus-jose-jwt</artifactId>
<version>4.41.1</version> <version>3.9</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>