Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Merge r1346682 through r1354801 from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3092@1354832 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
szetszwo committed Jun 28, 2012
2 parents c78ed5c + 6883354 commit 6e42a23
Show file tree
Hide file tree
Showing 333 changed files with 8,654 additions and 5,121 deletions.
4 changes: 2 additions & 2 deletions dev-support/test-patch.sh
Expand Up @@ -418,8 +418,8 @@ checkJavacWarnings () {
echo "======================================================================" echo "======================================================================"
echo "" echo ""
echo "" echo ""
echo "$MVN clean test -DskipTests -D${PROJECT_NAME}PatchProcess -Ptest-patch > $PATCH_DIR/patchJavacWarnings.txt 2>&1" echo "$MVN clean test -DskipTests -D${PROJECT_NAME}PatchProcess -Pnative -Ptest-patch > $PATCH_DIR/patchJavacWarnings.txt 2>&1"
$MVN clean test -DskipTests -D${PROJECT_NAME}PatchProcess -Ptest-patch > $PATCH_DIR/patchJavacWarnings.txt 2>&1 $MVN clean test -DskipTests -D${PROJECT_NAME}PatchProcess -Pnative -Ptest-patch > $PATCH_DIR/patchJavacWarnings.txt 2>&1
if [[ $? != 0 ]] ; then if [[ $? != 0 ]] ; then
JIRA_COMMENT="$JIRA_COMMENT JIRA_COMMENT="$JIRA_COMMENT
Expand Down
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<assembly>
<id>hadoop-raid-dist</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!-- Configuration files -->
<fileSet>
<directory>${basedir}/src/main/conf</directory>
<outputDirectory>/etc/hadoop</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/sbin</directory>
<outputDirectory>/sbin</outputDirectory>
<includes>
<include>*</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/libexec</directory>
<outputDirectory>/libexec</outputDirectory>
<includes>
<include>*</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<!-- Documentation -->
<fileSet>
<directory>${project.build.directory}/site</directory>
<outputDirectory>/share/doc/hadoop/raid</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/share/hadoop/${hadoop.component}/lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
<useProjectArtifact>true</useProjectArtifact>
</dependencySet>
</dependencySets>
</assembly>
67 changes: 67 additions & 0 deletions hadoop-assemblies/src/main/resources/assemblies/hadoop-tools.xml
@@ -0,0 +1,67 @@
<!--
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.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>hadoop-tools</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>../hadoop-pipes/src/main/native/pipes/api/hadoop</directory>
<includes>
<include>*.hh</include>
</includes>
<outputDirectory>/include</outputDirectory>
</fileSet>
<fileSet>
<directory>../hadoop-pipes/src/main/native/utils/api/hadoop</directory>
<includes>
<include>*.hh</include>
</includes>
<outputDirectory>/include</outputDirectory>
</fileSet>
<fileSet>
<directory>../hadoop-pipes/target/native</directory>
<includes>
<include>*.a</include>
</includes>
<outputDirectory>lib/native</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/share/hadoop/${hadoop.component}/lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
<useProjectArtifact>false</useProjectArtifact>
<!-- Exclude hadoop artifacts. They will be found via HADOOP* env -->
<excludes>
<exclude>org.apache.hadoop:hadoop-common</exclude>
<exclude>org.apache.hadoop:hadoop-hdfs</exclude>
<exclude>org.apache.hadoop:hadoop-mapreduce</exclude>
<!-- pipes is native stuff, this just keeps pom from being package-->
<exclude>org.apache.hadoop:hadoop-pipes</exclude>
<!-- use slf4j from common to avoid multiple binding warnings -->
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
Expand Up @@ -21,6 +21,24 @@


/** /**
* Annotation to inform users of a package, class or method's intended audience. * Annotation to inform users of a package, class or method's intended audience.
* Currently the audience can be {@link Public}, {@link LimitedPrivate} or
* {@link Private}. <br>
* All public classes must have InterfaceAudience annotation. <br>
* <ul>
* <li>Public classes that are not marked with this annotation must be
* considered by default as {@link Private}.</li>
*
* <li>External applications must only use classes that are marked
* {@link Public}. Avoid using non public classes as these classes
* could be removed or change in incompatible ways.</li>
*
* <li>Hadoop projects must only use classes that are marked
* {@link LimitedPrivate} or {@link Public}</li>
*
* <li> Methods may have a different annotation that it is more restrictive
* compared to the audience classification of the class. Example: A class
* might be {@link Public}, but a method may be {@link LimitedPrivate}
* </li></ul>
*/ */
@InterfaceAudience.Public @InterfaceAudience.Public
@InterfaceStability.Evolving @InterfaceStability.Evolving
Expand Down
Expand Up @@ -19,9 +19,20 @@


import java.lang.annotation.Documented; import java.lang.annotation.Documented;


import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;

/** /**
* Annotation to inform users of how much to rely on a particular package, * Annotation to inform users of how much to rely on a particular package,
* class or method not changing over time. * class or method not changing over time. Currently the stability can be
* {@link Stable}, {@link Evolving} or {@link Unstable}. <br>
*
* <ul><li>All classes that are annotated with {@link Public} or
* {@link LimitedPrivate} must have InterfaceStability annotation. </li>
* <li>Classes that are {@link Private} are to be considered unstable unless
* a different InterfaceStability annotation states otherwise.</li>
* <li>Incompatible changes must not be made to classes marked as stable.</li>
*/ */
@InterfaceAudience.Public @InterfaceAudience.Public
@InterfaceStability.Evolving @InterfaceStability.Evolving
Expand Down
Expand Up @@ -266,6 +266,7 @@ public static void extractToken(HttpURLConnection conn, Token token) throws IOEx
} }
} }
} else { } else {
token.set(null);
throw new AuthenticationException("Authentication failed, status: " + conn.getResponseCode() + throw new AuthenticationException("Authentication failed, status: " + conn.getResponseCode() +
", message: " + conn.getResponseMessage()); ", message: " + conn.getResponseMessage());
} }
Expand Down
Expand Up @@ -341,45 +341,50 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
LOG.warn("AuthenticationToken ignored: " + ex.getMessage()); LOG.warn("AuthenticationToken ignored: " + ex.getMessage());
token = null; token = null;
} }
if (token == null) { if (authHandler.managementOperation(token, httpRequest, httpResponse)) {
if (LOG.isDebugEnabled()) { if (token == null) {
LOG.debug("Request [{}] triggering authentication", getRequestURL(httpRequest)); if (LOG.isDebugEnabled()) {
} LOG.debug("Request [{}] triggering authentication", getRequestURL(httpRequest));
token = authHandler.authenticate(httpRequest, httpResponse); }
if (token != null && token != AuthenticationToken.ANONYMOUS) { token = authHandler.authenticate(httpRequest, httpResponse);
token.setExpires(System.currentTimeMillis() + getValidity() * 1000); if (token != null && token.getExpires() != 0 &&
} token != AuthenticationToken.ANONYMOUS) {
newToken = true; token.setExpires(System.currentTimeMillis() + getValidity() * 1000);
} }
if (token != null) { newToken = true;
unauthorizedResponse = false;
if (LOG.isDebugEnabled()) {
LOG.debug("Request [{}] user [{}] authenticated", getRequestURL(httpRequest), token.getUserName());
} }
final AuthenticationToken authToken = token; if (token != null) {
httpRequest = new HttpServletRequestWrapper(httpRequest) { unauthorizedResponse = false;

if (LOG.isDebugEnabled()) {
@Override LOG.debug("Request [{}] user [{}] authenticated", getRequestURL(httpRequest), token.getUserName());
public String getAuthType() {
return authToken.getType();
} }
final AuthenticationToken authToken = token;
httpRequest = new HttpServletRequestWrapper(httpRequest) {


@Override @Override
public String getRemoteUser() { public String getAuthType() {
return authToken.getUserName(); return authToken.getType();
} }


@Override @Override
public Principal getUserPrincipal() { public String getRemoteUser() {
return (authToken != AuthenticationToken.ANONYMOUS) ? authToken : null; return authToken.getUserName();
}

@Override
public Principal getUserPrincipal() {
return (authToken != AuthenticationToken.ANONYMOUS) ? authToken : null;
}
};
if (newToken && !token.isExpired() && token != AuthenticationToken.ANONYMOUS) {
String signedToken = signer.sign(token.toString());
Cookie cookie = createCookie(signedToken);
httpResponse.addCookie(cookie);
} }
}; filterChain.doFilter(httpRequest, httpResponse);
if (newToken && token != AuthenticationToken.ANONYMOUS) {
String signedToken = signer.sign(token.toString());
Cookie cookie = createCookie(signedToken);
httpResponse.addCookie(cookie);
} }
filterChain.doFilter(httpRequest, httpResponse); } else {
unauthorizedResponse = false;
} }
} catch (AuthenticationException ex) { } catch (AuthenticationException ex) {
unauthorizedMsg = ex.toString(); unauthorizedMsg = ex.toString();
Expand Down
Expand Up @@ -58,6 +58,34 @@ public interface AuthenticationHandler {
*/ */
public void destroy(); public void destroy();


/**
* Performs an authentication management operation.
* <p/>
* This is useful for handling operations like get/renew/cancel
* delegation tokens which are being handled as operations of the
* service end-point.
* <p/>
* If the method returns <code>TRUE</code> the request will continue normal
* processing, this means the method has not produced any HTTP response.
* <p/>
* If the method returns <code>FALSE</code> the request will end, this means
* the method has produced the corresponding HTTP response.
*
* @param token the authentication token if any, otherwise <code>NULL</code>.
* @param request the HTTP client request.
* @param response the HTTP client response.
* @return <code>TRUE</code> if the request should be processed as a regular
* request,
* <code>FALSE</code> otherwise.
*
* @throws IOException thrown if an IO error occurred.
* @throws AuthenticationException thrown if an Authentication error occurred.
*/
public boolean managementOperation(AuthenticationToken token,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, AuthenticationException;

/** /**
* Performs an authentication step for the given HTTP client request. * Performs an authentication step for the given HTTP client request.
* <p/> * <p/>
Expand Down
Expand Up @@ -115,10 +115,10 @@ public void setExpires(long expires) {
*/ */
private void generateToken() { private void generateToken() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(USER_NAME).append("=").append(userName).append(ATTR_SEPARATOR); sb.append(USER_NAME).append("=").append(getUserName()).append(ATTR_SEPARATOR);
sb.append(PRINCIPAL).append("=").append(principal).append(ATTR_SEPARATOR); sb.append(PRINCIPAL).append("=").append(getName()).append(ATTR_SEPARATOR);
sb.append(TYPE).append("=").append(type).append(ATTR_SEPARATOR); sb.append(TYPE).append("=").append(getType()).append(ATTR_SEPARATOR);
sb.append(EXPIRES).append("=").append(expires); sb.append(EXPIRES).append("=").append(getExpires());
token = sb.toString(); token = sb.toString();
} }


Expand Down Expand Up @@ -165,7 +165,7 @@ public long getExpires() {
* @return if the token has expired. * @return if the token has expired.
*/ */
public boolean isExpired() { public boolean isExpired() {
return expires != -1 && System.currentTimeMillis() > expires; return getExpires() != -1 && System.currentTimeMillis() > getExpires();
} }


/** /**
Expand Down
Expand Up @@ -232,6 +232,27 @@ protected String getKeytab() {
return keytab; return keytab;
} }


/**
* This is an empty implementation, it always returns <code>TRUE</code>.
*
*
*
* @param token the authentication token if any, otherwise <code>NULL</code>.
* @param request the HTTP client request.
* @param response the HTTP client response.
*
* @return <code>TRUE</code>
* @throws IOException it is never thrown.
* @throws AuthenticationException it is never thrown.
*/
@Override
public boolean managementOperation(AuthenticationToken token,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, AuthenticationException {
return true;
}

/** /**
* It enforces the the Kerberos SPNEGO authentication sequence returning an {@link AuthenticationToken} only * It enforces the the Kerberos SPNEGO authentication sequence returning an {@link AuthenticationToken} only
* after the Kerberos SPNEGO sequence has completed successfully. * after the Kerberos SPNEGO sequence has completed successfully.
Expand Down
Expand Up @@ -93,6 +93,27 @@ public String getType() {
return TYPE; return TYPE;
} }


/**
* This is an empty implementation, it always returns <code>TRUE</code>.
*
*
*
* @param token the authentication token if any, otherwise <code>NULL</code>.
* @param request the HTTP client request.
* @param response the HTTP client response.
*
* @return <code>TRUE</code>
* @throws IOException it is never thrown.
* @throws AuthenticationException it is never thrown.
*/
@Override
public boolean managementOperation(AuthenticationToken token,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, AuthenticationException {
return true;
}

/** /**
* Authenticates an HTTP client request. * Authenticates an HTTP client request.
* <p/> * <p/>
Expand Down

0 comments on commit 6e42a23

Please sign in to comment.