You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 21:25:56 UTC
svn commit: r1187756 [1/2] - in /tomcat/trunk/java/org/apache/catalina: ./
authenticator/ core/ ha/authenticator/ ha/session/ ha/tcp/ startup/ valves/
Author: markt
Date: Sat Oct 22 19:25:55 2011
New Revision: 1187756
URL: http://svn.apache.org/viewvc?rev=1187756&view=rev
Log:
Remove info and getInfo() from the Valves
Also includes automatic clean-up - mainly whitespace
Modified:
tomcat/trunk/java/org/apache/catalina/Valve.java
tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java
tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java
tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java
tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java
tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java
tomcat/trunk/java/org/apache/catalina/core/StandardEngineValve.java
tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java
tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
tomcat/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java
tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java
tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java
tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java
tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java
tomcat/trunk/java/org/apache/catalina/valves/RemoteIpValve.java
tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java
tomcat/trunk/java/org/apache/catalina/valves/SemaphoreValve.java
tomcat/trunk/java/org/apache/catalina/valves/StuckThreadDetectionValve.java
tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java
Modified: tomcat/trunk/java/org/apache/catalina/Valve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Valve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Valve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Valve.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -49,13 +49,6 @@ public interface Valve {
//-------------------------------------------------------------- Properties
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- public String getInfo();
-
-
/**
* Return the next Valve in the pipeline containing this Valve, if any.
*/
@@ -131,7 +124,7 @@ public interface Valve {
public void invoke(Request request, Response response)
throws IOException, ServletException;
-
+
/**
* Process a Comet event.
*
@@ -146,8 +139,8 @@ public interface Valve {
public void event(Request request, Response response, CometEvent event)
throws IOException, ServletException;
-
+
public boolean isAsyncSupported();
-
+
}
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -71,8 +71,6 @@ import org.apache.tomcat.util.res.String
* @author Craig R. McClanahan
* @version $Id$
*/
-
-
public abstract class AuthenticatorBase extends ValveBase
implements Authenticator {
@@ -105,7 +103,7 @@ public abstract class AuthenticatorBase
* for combinations such as BASIC authentication used with the JNDIRealm or
* DataSourceRealms. However there will also be the performance cost of
* creating and GC'ing the session. By default, a session will not be
- * created.
+ * created.
*/
protected boolean alwaysUseSession = false;
@@ -122,7 +120,7 @@ public abstract class AuthenticatorBase
* authentication to prevent a session fixation attack?
*/
protected boolean changeSessionIdOnAuthentication = true;
-
+
/**
* The Context to which this Valve is attached.
*/
@@ -130,12 +128,6 @@ public abstract class AuthenticatorBase
/**
- * Descriptive information about this implementation.
- */
- protected static final String info =
- "org.apache.catalina.authenticator.AuthenticatorBase/1.0";
-
- /**
* Flag to determine if we disable proxy caching, or leave the issue
* up to the webapp developer.
*/
@@ -146,7 +138,7 @@ public abstract class AuthenticatorBase
* with IE.
*/
protected boolean securePagesWithPragma = false;
-
+
/**
* The Java class name of the secure random number generator class to be
* used when generating SSO session identifiers. The random number generator
@@ -255,9 +247,10 @@ public abstract class AuthenticatorBase
@Override
public void setContainer(Container container) {
- if (container != null && !(container instanceof Context))
+ if (container != null && !(container instanceof Context)) {
throw new IllegalArgumentException
(sm.getString("authenticator.notContext"));
+ }
super.setContainer(container);
this.context = (Context) container;
@@ -266,17 +259,6 @@ public abstract class AuthenticatorBase
/**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
- /**
* Return the flag that states if we add headers to disable caching by
* proxies.
*/
@@ -287,13 +269,13 @@ public abstract class AuthenticatorBase
/**
* Set the value of the flag that states if we add headers to disable
* caching by proxies.
- * @param nocache <code>true</code> if we add headers to disable proxy
+ * @param nocache <code>true</code> if we add headers to disable proxy
* caching, <code>false</code> if we leave the headers alone.
*/
public void setDisableProxyCaching(boolean nocache) {
disableProxyCaching = nocache;
}
-
+
/**
* Return the flag that states, if proxy caching is disabled, what headers
* we add to disable the caching.
@@ -305,18 +287,18 @@ public abstract class AuthenticatorBase
/**
* Set the value of the flag that states what headers we add to disable
* proxy caching.
- * @param securePagesWithPragma <code>true</code> if we add headers which
+ * @param securePagesWithPragma <code>true</code> if we add headers which
* are incompatible with downloading office documents in IE under SSL but
* which fix a caching problem in Mozilla.
*/
public void setSecurePagesWithPragma(boolean securePagesWithPragma) {
this.securePagesWithPragma = securePagesWithPragma;
- }
+ }
/**
* Return the flag that states if we should change the session ID of an
* existing session upon successful authentication.
- *
+ *
* @return <code>true</code> to change session ID upon successful
* authentication, <code>false</code> to do not perform the change.
*/
@@ -327,7 +309,7 @@ public abstract class AuthenticatorBase
/**
* Set the value of the flag that states if we should change the session ID
* of an existing session upon successful authentication.
- *
+ *
* @param changeSessionIdOnAuthentication
* <code>true</code> to change session ID upon successful
* authentication, <code>false</code> to do not perform the
@@ -415,9 +397,10 @@ public abstract class AuthenticatorBase
public void invoke(Request request, Response response)
throws IOException, ServletException {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Security checking request " +
request.getMethod() + " " + request.getRequestURI());
+ }
LoginConfig config = this.context.getLoginConfig();
// Have we got a cached authenticated Principal to record?
@@ -428,11 +411,12 @@ public abstract class AuthenticatorBase
if (session != null) {
principal = session.getPrincipal();
if (principal != null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("We have cached auth type " +
session.getAuthType() +
" for principal " +
session.getPrincipal());
+ }
request.setAuthType(session.getAuthType());
request.setUserPrincipal(principal);
}
@@ -448,8 +432,9 @@ public abstract class AuthenticatorBase
if (requestURI.startsWith(contextPath) &&
requestURI.endsWith(Constants.FORM_ACTION)) {
if (!authenticate(request, response, config)) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(" Failed authenticate() test ??" + requestURI );
+ }
return;
}
}
@@ -465,17 +450,18 @@ public abstract class AuthenticatorBase
// Is this request URI subject to a security constraint?
SecurityConstraint [] constraints
= realm.findSecurityConstraints(request, this.context);
-
+
if (constraints == null && !context.getPreemptiveAuthentication()) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug(" Not subject to any constraint");
+ }
getNext().invoke(request, response);
return;
}
// Make sure that constrained resources are not cached by web proxies
// or browsers as caching can provide a security hole
- if (constraints != null && disableProxyCaching &&
+ if (constraints != null && disableProxyCaching &&
!"POST".equalsIgnoreCase(request.getMethod())) {
if (securePagesWithPragma) {
// Note: These can cause problems with downloading files with IE
@@ -537,7 +523,7 @@ public abstract class AuthenticatorBase
authRequired = certs != null && certs.length > 0;
}
- if(authRequired) {
+ if(authRequired) {
if (log.isDebugEnabled()) {
log.debug(" Calling authenticate()");
}
@@ -551,10 +537,10 @@ public abstract class AuthenticatorBase
* special
*/
return;
- }
-
+ }
+
}
-
+
if (constraints != null) {
if (log.isDebugEnabled()) {
log.debug(" Calling accessControl()");
@@ -573,7 +559,7 @@ public abstract class AuthenticatorBase
return;
}
}
-
+
// Any and all specified constraints have been satisfied
if (log.isDebugEnabled()) {
log.debug(" Successfully passed all security constraints");
@@ -595,8 +581,9 @@ public abstract class AuthenticatorBase
*/
protected void associate(String ssoId, Session session) {
- if (sso == null)
+ if (sso == null) {
return;
+ }
sso.associate(ssoId, session);
}
@@ -632,8 +619,9 @@ public abstract class AuthenticatorBase
*/
protected boolean reauthenticateFromSSO(String ssoId, Request request) {
- if (sso == null || ssoId == null)
+ if (sso == null || ssoId == null) {
return false;
+ }
boolean reauthenticated = false;
@@ -677,7 +665,7 @@ public abstract class AuthenticatorBase
String username, String password) {
if (log.isDebugEnabled()) {
- String name = (principal == null) ? "none" : principal.getName();
+ String name = (principal == null) ? "none" : principal.getName();
log.debug("Authenticated '" + name + "' with type '" + authType +
"'");
}
@@ -687,7 +675,7 @@ public abstract class AuthenticatorBase
request.setUserPrincipal(principal);
Session session = request.getSessionInternal(false);
-
+
if (session != null) {
if (changeSessionIdOnAuthentication) {
Manager manager = request.getContext().getManager();
@@ -703,20 +691,23 @@ public abstract class AuthenticatorBase
if (session != null) {
session.setAuthType(authType);
session.setPrincipal(principal);
- if (username != null)
+ if (username != null) {
session.setNote(Constants.SESS_USERNAME_NOTE, username);
- else
+ } else {
session.removeNote(Constants.SESS_USERNAME_NOTE);
- if (password != null)
+ }
+ if (password != null) {
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
- else
+ } else {
session.removeNote(Constants.SESS_PASSWORD_NOTE);
+ }
}
}
// Construct a cookie to be returned to the client
- if (sso == null)
+ if (sso == null) {
return;
+ }
// Only create a new SSO entry if the SSO did not already set a note
// for an existing entry (as it would do with subsequent requests
@@ -728,7 +719,7 @@ public abstract class AuthenticatorBase
Cookie cookie = new Cookie(Constants.SINGLE_SIGN_ON_COOKIE, ssoId);
cookie.setMaxAge(-1);
cookie.setPath("/");
-
+
// Bugzilla 41217
cookie.setSecure(request.isSecure());
@@ -743,7 +734,7 @@ public abstract class AuthenticatorBase
request.getContext().getUseHttpOnly()) {
cookie.setHttpOnly(true);
}
-
+
response.addCookie(cookie);
// Register this principal with our SSO valve
@@ -767,8 +758,9 @@ public abstract class AuthenticatorBase
// associated sessions are destroyed; if a new SSO entry is created
// above for this request and the user never revisits the context, the
// SSO entry will never be cleared if we don't associate the session
- if (session == null)
+ if (session == null) {
session = request.getSessionInternal(true);
+ }
sso.associate(ssoId, session);
}
@@ -785,7 +777,7 @@ public abstract class AuthenticatorBase
/**
* Process the login request.
- *
+ *
* @param request Associated request
* @param username The user
* @param password The password
@@ -817,7 +809,7 @@ public abstract class AuthenticatorBase
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
-
+
// Look up the SingleSignOn implementation in our request processing
// path, if there is one
Container parent = context.getParent();
@@ -829,14 +821,16 @@ public abstract class AuthenticatorBase
break;
}
}
- if (sso == null)
+ if (sso == null) {
parent = parent.getParent();
+ }
}
if (log.isDebugEnabled()) {
- if (sso != null)
+ if (sso != null) {
log.debug("Found SingleSignOn Valve at " + sso);
- else
+ } else {
log.debug("No SingleSignOn Valve is present");
+ }
}
sessionIdGenerator = new SessionIdGenerator();
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -48,33 +48,9 @@ public class BasicAuthenticator
extends AuthenticatorBase {
private static final Log log = LogFactory.getLog(BasicAuthenticator.class);
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Descriptive information about this implementation.
- */
- protected static final String info =
- "org.apache.catalina.authenticator.BasicAuthenticator/1.0";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
// --------------------------------------------------------- Public Methods
-
/**
* Authenticate the user making this request, based on the specified
* login configuration. Return <code>true</code> if any specified
@@ -98,37 +74,41 @@ public class BasicAuthenticator
Principal principal = request.getUserPrincipal();
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (principal != null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Already authenticated '" + principal.getName() + "'");
+ }
// Associate the session with any existing SSO session
- if (ssoId != null)
+ if (ssoId != null) {
associate(ssoId, request.getSessionInternal(true));
+ }
return (true);
}
// Is there an SSO session against which we can try to reauthenticate?
if (ssoId != null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("SSO Id " + ssoId + " set; attempting " +
"reauthentication");
+ }
/* Try to reauthenticate using data cached by SSO. If this fails,
either the original SSO logon was of DIGEST or SSL (which
we can't reauthenticate ourselves because there is no
cached username and password), or the realm denied
the user's reauthentication for some reason.
In either case we have to prompt the user for a logon */
- if (reauthenticateFromSSO(ssoId, request))
+ if (reauthenticateFromSSO(ssoId, request)) {
return true;
+ }
}
// Validate any credentials already included with this request
String username = null;
String password = null;
- MessageBytes authorization =
+ MessageBytes authorization =
request.getCoyoteRequest().getMimeHeaders()
.getValue("authorization");
-
+
if (authorization != null) {
authorization.toBytes();
ByteChunk authorizationBC = authorization.getByteChunk();
@@ -136,10 +116,10 @@ public class BasicAuthenticator
authorizationBC.setOffset(authorizationBC.getOffset() + 6);
// FIXME: Add trimming
// authorizationBC.trim();
-
+
CharChunk authorizationCC = authorization.getCharChunk();
Base64.decode(authorizationBC, authorizationCC);
-
+
// Get username and password
int colon = authorizationCC.indexOf(':');
if (colon < 0) {
@@ -147,10 +127,10 @@ public class BasicAuthenticator
} else {
char[] buf = authorizationCC.getBuffer();
username = new String(buf, 0, colon);
- password = new String(buf, colon + 1,
+ password = new String(buf, colon + 1,
authorizationCC.getEnd() - colon - 1);
}
-
+
authorizationBC.setOffset(authorizationBC.getOffset() - 6);
}
@@ -161,7 +141,7 @@ public class BasicAuthenticator
return (true);
}
}
-
+
StringBuilder value = new StringBuilder(16);
value.append("Basic realm=\"");
if (config.getRealmName() == null) {
@@ -169,7 +149,7 @@ public class BasicAuthenticator
} else {
value.append(config.getRealmName());
}
- value.append('\"');
+ value.append('\"');
response.setHeader(AUTH_HEADER_NAME, value.toString());
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return (false);
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -64,13 +64,6 @@ public class DigestAuthenticator extends
/**
- * Descriptive information about this implementation.
- */
- protected static final String info =
- "org.apache.catalina.authenticator.DigestAuthenticator/1.0";
-
-
- /**
* Tomcat's DIGEST implementation only supports auth quality of protection.
*/
protected static final String QOP = "auth";
@@ -81,8 +74,9 @@ public class DigestAuthenticator extends
public DigestAuthenticator() {
super();
try {
- if (md5Helper == null)
+ if (md5Helper == null) {
md5Helper = MessageDigest.getInstance("MD5");
+ }
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new IllegalStateException();
@@ -139,17 +133,6 @@ public class DigestAuthenticator extends
// ------------------------------------------------------------- Properties
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
public int getCnonceCacheSize() {
return cnonceCacheSize;
}
@@ -225,13 +208,15 @@ public class DigestAuthenticator extends
Principal principal = request.getUserPrincipal();
//String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (principal != null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Already authenticated '" + principal.getName() + "'");
+ }
// Associate the session with any existing SSO session in order
// to get coordinated session invalidation at logout
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
- if (ssoId != null)
+ if (ssoId != null) {
associate(ssoId, request.getSessionInternal(true));
+ }
return (true);
}
@@ -268,7 +253,7 @@ public class DigestAuthenticator extends
if (digestInfo.validate(request, authorization, config)) {
principal = digestInfo.authenticate(context.getRealm());
}
-
+
if (principal != null) {
String username = parseUsername(authorization);
register(request, response, principal,
@@ -311,10 +296,12 @@ public class DigestAuthenticator extends
protected String parseUsername(String authorization) {
// Validate the authorization credentials format
- if (authorization == null)
+ if (authorization == null) {
return (null);
- if (!authorization.startsWith("Digest "))
+ }
+ if (!authorization.startsWith("Digest ")) {
return (null);
+ }
authorization = authorization.substring(7).trim();
StringTokenizer commaTokenizer =
@@ -323,14 +310,16 @@ public class DigestAuthenticator extends
while (commaTokenizer.hasMoreTokens()) {
String currentToken = commaTokenizer.nextToken();
int equalSign = currentToken.indexOf('=');
- if (equalSign < 0)
+ if (equalSign < 0) {
return null;
+ }
String currentTokenName =
currentToken.substring(0, equalSign).trim();
String currentTokenValue =
currentToken.substring(equalSign + 1).trim();
- if ("username".equals(currentTokenName))
+ if ("username".equals(currentTokenName)) {
return (removeQuotes(currentTokenValue));
+ }
}
return (null);
@@ -373,7 +362,7 @@ public class DigestAuthenticator extends
long currentTime = System.currentTimeMillis();
-
+
String ipTimeKey =
request.getRemoteAddr() + ":" + currentTime + ":" + getKey();
@@ -422,8 +411,9 @@ public class DigestAuthenticator extends
// Get the realm name
String realmName = config.getRealmName();
- if (realmName == null)
+ if (realmName == null) {
realmName = REALM_NAME;
+ }
String authenticateHeader;
if (isNonceStale) {
@@ -442,21 +432,21 @@ public class DigestAuthenticator extends
// ------------------------------------------------------- Lifecycle Methods
-
+
@Override
protected synchronized void startInternal() throws LifecycleException {
super.startInternal();
-
+
// Generate a random secret key
if (getKey() == null) {
setKey(sessionIdGenerator.generateSessionId());
}
-
+
// Generate the opaque string the same way
if (getOpaque() == null) {
setOpaque(sessionIdGenerator.generateSessionId());
}
-
+
cnonces = new LinkedHashMap<String, DigestAuthenticator.NonceInfo>() {
private static final long serialVersionUID = 1L;
@@ -484,13 +474,13 @@ public class DigestAuthenticator extends
}
};
}
-
+
private static class DigestInfo {
- private String opaque;
- private long nonceValidity;
- private String key;
- private Map<String,NonceInfo> cnonces;
+ private final String opaque;
+ private final long nonceValidity;
+ private final String key;
+ private final Map<String,NonceInfo> cnonces;
private boolean validateUri = true;
private String userName = null;
@@ -534,8 +524,9 @@ public class DigestAuthenticator extends
for (int i = 0; i < tokens.length; i++) {
String currentToken = tokens[i];
- if (currentToken.length() == 0)
+ if (currentToken.length() == 0) {
continue;
+ }
int equalSign = currentToken.indexOf('=');
if (equalSign < 0) {
@@ -545,24 +536,33 @@ public class DigestAuthenticator extends
currentToken.substring(0, equalSign).trim();
String currentTokenValue =
currentToken.substring(equalSign + 1).trim();
- if ("username".equals(currentTokenName))
+ if ("username".equals(currentTokenName)) {
userName = removeQuotes(currentTokenValue);
- if ("realm".equals(currentTokenName))
+ }
+ if ("realm".equals(currentTokenName)) {
realmName = removeQuotes(currentTokenValue, true);
- if ("nonce".equals(currentTokenName))
+ }
+ if ("nonce".equals(currentTokenName)) {
nonce = removeQuotes(currentTokenValue);
- if ("nc".equals(currentTokenName))
+ }
+ if ("nc".equals(currentTokenName)) {
nc = removeQuotes(currentTokenValue);
- if ("cnonce".equals(currentTokenName))
+ }
+ if ("cnonce".equals(currentTokenName)) {
cnonce = removeQuotes(currentTokenValue);
- if ("qop".equals(currentTokenName))
+ }
+ if ("qop".equals(currentTokenName)) {
qop = removeQuotes(currentTokenValue);
- if ("uri".equals(currentTokenName))
+ }
+ if ("uri".equals(currentTokenName)) {
uri = removeQuotes(currentTokenValue);
- if ("response".equals(currentTokenName))
+ }
+ if ("response".equals(currentTokenName)) {
response = removeQuotes(currentTokenValue);
- if ("opaque".equals(currentTokenName))
+ }
+ if ("opaque".equals(currentTokenName)) {
opaque = removeQuotes(currentTokenValue);
+ }
}
if ( (userName == null) || (realmName == null) || (nonce == null)
@@ -592,7 +592,7 @@ public class DigestAuthenticator extends
if (!lcRealm.equals(realmName)) {
return false;
}
-
+
// Validate the opaque string
if (!this.opaque.equals(opaque)) {
return false;
@@ -695,19 +695,19 @@ public class DigestAuthenticator extends
private static class NonceInfo {
private volatile long count;
private volatile long timestamp;
-
+
public void setCount(long l) {
count = l;
}
-
+
public long getCount() {
return count;
}
-
+
public void setTimestamp(long l) {
timestamp = l;
}
-
+
public long getTimestamp() {
return timestamp;
}
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java Sat Oct 22 19:25:55 2011
@@ -58,14 +58,8 @@ public class FormAuthenticator
private static final Log log = LogFactory.getLog(FormAuthenticator.class);
- // ----------------------------------------------------- Instance Variables
-
- /**
- * Descriptive information about this implementation.
- */
- protected static final String info =
- "org.apache.catalina.authenticator.FormAuthenticator/1.0";
+ // ----------------------------------------------------- Instance Variables
/**
* Character encoding to use to read the username and password parameters
@@ -81,19 +75,8 @@ public class FormAuthenticator
*/
protected String landingPage = null;
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
+ // ------------------------------------------------------------- Properties
/**
* Return the character encoding to use to read the username and password.
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java Sat Oct 22 19:25:55 2011
@@ -5,17 +5,15 @@
* 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.
*/
-
-
package org.apache.catalina.authenticator;
@@ -35,33 +33,7 @@ import org.apache.catalina.deploy.LoginC
* @author Craig R. McClanahan
* @version $Id$
*/
-
-public final class NonLoginAuthenticator
- extends AuthenticatorBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Descriptive information about this implementation.
- */
- private static final String info =
- "org.apache.catalina.authenticator.NonLoginAuthenticator/1.0";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
+public final class NonLoginAuthenticator extends AuthenticatorBase {
// --------------------------------------------------------- Public Methods
@@ -94,9 +66,10 @@ public final class NonLoginAuthenticator
if (ssoId != null)
associate(ssoId, getSession(request, true));
*/
-
- if (containerLog.isDebugEnabled())
+
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("User authentication is not required");
+ }
return (true);
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java Sat Oct 22 19:25:55 2011
@@ -5,20 +5,17 @@
* 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.
*/
-
-
package org.apache.catalina.authenticator;
-
import java.io.IOException;
import java.security.Principal;
import java.security.cert.X509Certificate;
@@ -30,8 +27,6 @@ import org.apache.catalina.connector.Req
import org.apache.catalina.deploy.LoginConfig;
import org.apache.coyote.ActionCode;
-
-
/**
* An <b>Authenticator</b> and <b>Valve</b> implementation of authentication
* that utilizes SSL certificates to identify client users.
@@ -39,35 +34,10 @@ import org.apache.coyote.ActionCode;
* @author Craig R. McClanahan
* @version $Id$
*/
-
-public class SSLAuthenticator
- extends AuthenticatorBase {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Descriptive information about this implementation.
- */
- protected static final String info =
- "org.apache.catalina.authenticator.SSLAuthenticator/1.0";
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
+public class SSLAuthenticator extends AuthenticatorBase {
// --------------------------------------------------------- Public Methods
-
/**
* Authenticate the user by checking for the existence of a certificate
* chain, validating it against the trust manager for the connector and then
@@ -90,13 +60,15 @@ public class SSLAuthenticator
Principal principal = request.getUserPrincipal();
//String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (principal != null) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Already authenticated '" + principal.getName() + "'");
+ }
// Associate the session with any existing SSO session in order
// to get coordinated session invalidation at logout
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
- if (ssoId != null)
+ if (ssoId != null) {
associate(ssoId, request.getSessionInternal(true));
+ }
return (true);
}
@@ -126,8 +98,9 @@ public class SSLAuthenticator
*/
// Retrieve the certificate chain for this client
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" Looking up certificates");
+ }
X509Certificate certs[] = (X509Certificate[])
request.getAttribute(Globals.CERTIFICATES_ATTR);
@@ -145,8 +118,9 @@ public class SSLAuthenticator
request.getAttribute(Globals.CERTIFICATES_ATTR);
}
if ((certs == null) || (certs.length < 1)) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" No certificates included with this request");
+ }
response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
sm.getString("authenticator.certificates"));
return (false);
@@ -155,8 +129,9 @@ public class SSLAuthenticator
// Authenticate the specified certificate chain
principal = context.getRealm().authenticate(certs);
if (principal == null) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" Realm.authenticate() returned false");
+ }
response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
sm.getString("authenticator.unauthorized"));
return (false);
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -77,13 +77,6 @@ public class SingleSignOn extends ValveB
/**
- * Descriptive information about this Valve implementation.
- */
- protected static final String info =
- "org.apache.catalina.authenticator.SingleSignOn";
-
-
- /**
* Indicates whether this valve should require a downstream Authenticator to
* reauthenticate each request, or if it itself can bind a UserPrincipal
* and AuthType object to the request.
@@ -215,20 +208,23 @@ public class SingleSignOn extends ValveB
// We only care about session destroyed events
if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())
- && (!Session.SESSION_PASSIVATED_EVENT.equals(event.getType())))
+ && (!Session.SESSION_PASSIVATED_EVENT.equals(event.getType()))) {
return;
+ }
// Look up the single session id associated with this session (if any)
Session session = event.getSession();
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Process session destroyed on " + session);
+ }
String ssoId = null;
synchronized (reverse) {
ssoId = reverse.get(session);
}
- if (ssoId == null)
+ if (ssoId == null) {
return;
+ }
// Was the session destroyed as the result of a timeout?
// If so, we'll just remove the expired session from the
@@ -236,12 +232,12 @@ public class SingleSignOn extends ValveB
// of all session associated with the SSO.
if (((session.getMaxInactiveInterval() > 0)
&& (System.currentTimeMillis() - session.getThisAccessedTimeInternal() >=
- session.getMaxInactiveInterval() * 1000))
+ session.getMaxInactiveInterval() * 1000))
|| (Session.SESSION_PASSIVATED_EVENT.equals(event.getType()))) {
removeSession(ssoId, session);
} else {
// The session was logged out.
- // Deregister this single session id, invalidating
+ // Deregister this single session id, invalidating
// associated sessions
deregister(ssoId);
}
@@ -251,18 +247,6 @@ public class SingleSignOn extends ValveB
// ---------------------------------------------------------- Valve Methods
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
/**
* Perform single-sign-on support processing for this request.
*
@@ -279,23 +263,27 @@ public class SingleSignOn extends ValveB
request.removeNote(Constants.REQ_SSOID_NOTE);
// Has a valid user already been authenticated?
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Process request for '" + request.getRequestURI() + "'");
+ }
if (request.getUserPrincipal() != null) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" Principal '" + request.getUserPrincipal().getName() +
"' has already been authenticated");
+ }
getNext().invoke(request, response);
return;
}
// Check for the single sign on cookie
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" Checking for SSO cookie");
+ }
Cookie cookie = null;
Cookie cookies[] = request.getCookies();
- if (cookies == null)
+ if (cookies == null) {
cookies = new Cookie[0];
+ }
for (int i = 0; i < cookies.length; i++) {
if (Constants.SINGLE_SIGN_ON_COOKIE.equals(cookies[i].getName())) {
cookie = cookies[i];
@@ -303,21 +291,24 @@ public class SingleSignOn extends ValveB
}
}
if (cookie == null) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" SSO cookie is not present");
+ }
getNext().invoke(request, response);
return;
}
// Look up the cached Principal associated with this cookie value
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" Checking for cached principal for " + cookie.getValue());
+ }
SingleSignOnEntry entry = lookup(cookie.getValue());
if (entry != null) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" Found cached principal '" +
(entry.getPrincipal() != null ? entry.getPrincipal().getName() : "") + "' with auth type '" +
entry.getAuthType() + "'");
+ }
request.setNote(Constants.REQ_SSOID_NOTE, cookie.getValue());
// Only set security elements if reauthentication is not required
if (!getRequireReauthentication()) {
@@ -325,8 +316,9 @@ public class SingleSignOn extends ValveB
request.setUserPrincipal(entry.getPrincipal());
}
} else {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug(" No cached principal found, erasing SSO cookie");
+ }
cookie.setMaxAge(0);
response.addCookie(cookie);
}
@@ -349,12 +341,14 @@ public class SingleSignOn extends ValveB
*/
protected void associate(String ssoId, Session session) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Associate sso id " + ssoId + " with session " + session);
+ }
SingleSignOnEntry sso = lookup(ssoId);
- if (sso != null)
+ if (sso != null) {
sso.addSession(this, session);
+ }
synchronized (reverse) {
reverse.put(session, ssoId);
}
@@ -375,8 +369,9 @@ public class SingleSignOn extends ValveB
}
SingleSignOnEntry sso = lookup(ssoId);
- if (sso == null)
+ if (sso == null) {
return;
+ }
sso.removeSession(session);
@@ -399,8 +394,9 @@ public class SingleSignOn extends ValveB
*/
protected void deregister(String ssoId) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Deregistering sso id '" + ssoId + "'");
+ }
// Look up and remove the corresponding SingleSignOnEntry
SingleSignOnEntry sso = null;
@@ -408,14 +404,16 @@ public class SingleSignOn extends ValveB
sso = cache.remove(ssoId);
}
- if (sso == null)
+ if (sso == null) {
return;
+ }
// Expire any associated sessions
Session sessions[] = sso.findSessions();
for (int i = 0; i < sessions.length; i++) {
- if (containerLog.isTraceEnabled())
+ if (containerLog.isTraceEnabled()) {
containerLog.trace(" Invalidating session " + sessions[i]);
+ }
// Remove from reverse cache first to avoid recursion
synchronized (reverse) {
reverse.remove(sessions[i]);
@@ -438,8 +436,8 @@ public class SingleSignOn extends ValveB
* <p>
* If reauthentication is successful, the <code>Principal</code> and
* authorization type associated with the SSO session will be bound
- * to the given <code>Request</code> object via calls to
- * {@link Request#setAuthType Request.setAuthType()} and
+ * to the given <code>Request</code> object via calls to
+ * {@link Request#setAuthType Request.setAuthType()} and
* {@link Request#setUserPrincipal Request.setUserPrincipal()}
* </p>
*
@@ -448,27 +446,28 @@ public class SingleSignOn extends ValveB
* @param realm Realm implementation against which the caller is to
* be authenticated
* @param request the request that needs to be authenticated
- *
+ *
* @return <code>true</code> if reauthentication was successful,
* <code>false</code> otherwise.
*/
protected boolean reauthenticate(String ssoId, Realm realm,
Request request) {
- if (ssoId == null || realm == null)
+ if (ssoId == null || realm == null) {
return false;
+ }
boolean reauthenticated = false;
SingleSignOnEntry entry = lookup(ssoId);
if (entry != null && entry.getCanReauthenticate()) {
-
+
String username = entry.getUsername();
if (username != null) {
Principal reauthPrincipal =
- realm.authenticate(username, entry.getPassword());
- if (reauthPrincipal != null) {
- reauthenticated = true;
+ realm.authenticate(username, entry.getPassword());
+ if (reauthPrincipal != null) {
+ reauthenticated = true;
// Bind the authorization credentials to the request
request.setAuthType(entry.getAuthType());
request.setUserPrincipal(reauthPrincipal);
@@ -494,9 +493,10 @@ public class SingleSignOn extends ValveB
protected void register(String ssoId, Principal principal, String authType,
String username, String password) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Registering sso id '" + ssoId + "' for user '" +
(principal != null ? principal.getName() : "") + "' with auth type '" + authType + "'");
+ }
synchronized (cache) {
cache.put(ssoId, new SingleSignOnEntry(principal, authType,
@@ -536,8 +536,9 @@ public class SingleSignOn extends ValveB
SingleSignOnEntry sso = lookup(ssoId);
if (sso != null && !sso.getCanReauthenticate()) {
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("Update sso id " + ssoId + " to auth type " + authType);
+ }
synchronized(sso) {
sso.updateCredentials(principal, authType, username, password);
@@ -561,7 +562,7 @@ public class SingleSignOn extends ValveB
}
-
+
/**
* Remove a single Session from a SingleSignOn. Called when
* a session is timed out and no longer active.
@@ -571,14 +572,16 @@ public class SingleSignOn extends ValveB
*/
protected void removeSession(String ssoId, Session session) {
- if (containerLog.isDebugEnabled())
- containerLog.debug("Removing session " + session.toString() + " from sso id " +
+ if (containerLog.isDebugEnabled()) {
+ containerLog.debug("Removing session " + session.toString() + " from sso id " +
ssoId );
+ }
// Get a reference to the SingleSignOn
SingleSignOnEntry entry = lookup(ssoId);
- if (entry == null)
+ if (entry == null) {
return;
+ }
// Remove the inactive session from SingleSignOnEntry
entry.removeSession(session);
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -53,7 +53,7 @@ import org.ietf.jgss.Oid;
public class SpnegoAuthenticator extends AuthenticatorBase {
private static final Log log = LogFactory.getLog(SpnegoAuthenticator.class);
-
+
private String loginConfigName = Constants.DEFAULT_LOGIN_MODULE_NAME;
public String getLoginConfigName() {
return loginConfigName;
@@ -79,12 +79,6 @@ public class SpnegoAuthenticator extends
@Override
- public String getInfo() {
- return "org.apache.catalina.authenticator.SpnegoAuthenticator/1.0";
- }
-
-
- @Override
protected void initInternal() throws LifecycleException {
super.initInternal();
@@ -107,7 +101,7 @@ public class SpnegoAuthenticator extends
System.setProperty(Constants.JAAS_CONF_PROPERTY,
jaasConfFile.getAbsolutePath());
}
-
+
// This property must be false for SPNEGO to work
System.setProperty(Constants.USE_SUBJECT_CREDS_ONLY_PROPERTY, "false");
}
@@ -121,33 +115,37 @@ public class SpnegoAuthenticator extends
Principal principal = request.getUserPrincipal();
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (principal != null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Already authenticated '" + principal.getName() + "'");
+ }
// Associate the session with any existing SSO session
- if (ssoId != null)
+ if (ssoId != null) {
associate(ssoId, request.getSessionInternal(true));
+ }
return true;
}
// Is there an SSO session against which we can try to reauthenticate?
if (ssoId != null) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("SSO Id " + ssoId + " set; attempting " +
"reauthentication");
+ }
/* Try to reauthenticate using data cached by SSO. If this fails,
either the original SSO logon was of DIGEST or SSL (which
we can't reauthenticate ourselves because there is no
cached username and password), or the realm denied
the user's reauthentication for some reason.
In either case we have to prompt the user for a logon */
- if (reauthenticateFromSSO(ssoId, request))
+ if (reauthenticateFromSSO(ssoId, request)) {
return true;
+ }
}
- MessageBytes authorization =
+ MessageBytes authorization =
request.getCoyoteRequest().getMimeHeaders()
.getValue("authorization");
-
+
if (authorization == null) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("authenticator.noAuthHeader"));
@@ -156,7 +154,7 @@ public class SpnegoAuthenticator extends
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return false;
}
-
+
authorization.toBytes();
ByteChunk authorizationBC = authorization.getByteChunk();
@@ -173,7 +171,7 @@ public class SpnegoAuthenticator extends
authorizationBC.setOffset(authorizationBC.getOffset() + 10);
// FIXME: Add trimming
// authorizationBC.trim();
-
+
ByteChunk decoded = new ByteChunk();
Base64.decode(authorizationBC, decoded);
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java Sat Oct 22 19:25:55 2011
@@ -5,9 +5,9 @@
* 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.
@@ -45,45 +45,23 @@ import org.apache.tomcat.util.buf.Messag
*/
final class StandardContextValve extends ValveBase {
-
+
//------------------------------------------------------ Constructor
public StandardContextValve() {
super(true);
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.core.StandardContextValve/1.0";
+ // ----------------------------------------------------- Instance Variables
private StandardContext context = null;
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
// --------------------------------------------------------- Public Methods
-
/**
* Cast to a StandardContext right away, as it will be needed later.
- *
+ *
* @see org.apache.catalina.Contained#setContainer(org.apache.catalina.Container)
*/
@Override
@@ -92,7 +70,7 @@ final class StandardContextValve extends
context = (StandardContext) container;
}
-
+
/**
* Select the appropriate child Wrapper to process this request,
* based on the specified request URI. If no matching Wrapper can
@@ -162,7 +140,7 @@ final class StandardContextValve extends
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
-
+
if (request.isAsyncSupported()) {
request.setAsyncSupported(wrapper.getPipeline().isAsyncSupported());
}
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardEngineValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardEngineValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardEngineValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardEngineValve.java Sat Oct 22 19:25:55 2011
@@ -5,20 +5,17 @@
* 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.
*/
-
-
package org.apache.catalina.core;
-
import java.io.IOException;
import javax.servlet.ServletException;
@@ -31,7 +28,6 @@ import org.apache.catalina.connector.Res
import org.apache.catalina.valves.ValveBase;
import org.apache.tomcat.util.res.StringManager;
-
/**
* Valve that implements the default basic behavior for the
* <code>StandardEngine</code> container implementation.
@@ -43,8 +39,7 @@ import org.apache.tomcat.util.res.String
* @version $Id$
*/
-final class StandardEngineValve
- extends ValveBase {
+final class StandardEngineValve extends ValveBase {
//------------------------------------------------------ Constructor
public StandardEngineValve() {
@@ -54,14 +49,6 @@ final class StandardEngineValve
// ----------------------------------------------------- Instance Variables
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.core.StandardEngineValve/1.0";
-
-
/**
* The string manager for this package.
*/
@@ -69,23 +56,8 @@ final class StandardEngineValve
StringManager.getManager(Constants.Package);
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
// --------------------------------------------------------- Public Methods
-
/**
* Select the appropriate child Host to process this request,
* based on the requested server name. If no matching Host can
@@ -106,7 +78,7 @@ final class StandardEngineValve
if (host == null) {
response.sendError
(HttpServletResponse.SC_BAD_REQUEST,
- sm.getString("standardEngine.noHost",
+ sm.getString("standardEngine.noHost",
request.getServerName()));
return;
}
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Sat Oct 22 19:25:55 2011
@@ -66,7 +66,7 @@ final class StandardHostValve extends Va
static {
STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
-
+
String accessSession = System.getProperty(
"org.apache.catalina.core.StandardHostValve.ACCESS_SESSION");
if (accessSession == null) {
@@ -82,15 +82,8 @@ final class StandardHostValve extends Va
super(true);
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The descriptive information related to this implementation.
- */
- private static final String info =
- "org.apache.catalina.core.StandardHostValve/1.0";
+ // ----------------------------------------------------- Instance Variables
/**
* The string manager for this package.
@@ -99,23 +92,8 @@ final class StandardHostValve extends Va
StringManager.getManager(Constants.Package);
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
-
// --------------------------------------------------------- Public Methods
-
/**
* Select the appropriate child Context to process this request,
* based on the specified request URI. If no matching Context can
@@ -147,7 +125,7 @@ final class StandardHostValve extends Va
if (Globals.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(
context.getLoader().getClassLoader());
- AccessController.doPrivileged(pa);
+ AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClassLoader
(context.getLoader().getClassLoader());
@@ -160,7 +138,7 @@ final class StandardHostValve extends Va
// Don't fire listeners during async processing
// If a request init listener throws an exception, the request is
// aborted
- boolean asyncAtStart = request.isAsync();
+ boolean asyncAtStart = request.isAsync();
if (asyncAtStart || context.fireRequestInitEvent(request)) {
// Ask this Context to process this request
@@ -171,7 +149,7 @@ final class StandardHostValve extends Va
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
throwable(request, response, t);
}
-
+
// If the request was async at the start and an error occurred then
// the async error handling will kick-in and that will fire the
// request destroyed event *after* the error handling has taken
@@ -183,16 +161,16 @@ final class StandardHostValve extends Va
if (context.getState().isAvailable()) {
// Error page processing
response.setSuspended(false);
-
+
Throwable t = (Throwable) request.getAttribute(
RequestDispatcher.ERROR_EXCEPTION);
-
+
if (t != null) {
throwable(request, response, t);
} else {
status(request, response);
}
-
+
context.fireRequestDestroyEvent(request);
}
}
@@ -208,7 +186,7 @@ final class StandardHostValve extends Va
if (Globals.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(
StandardHostValve.class.getClassLoader());
- AccessController.doPrivileged(pa);
+ AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClassLoader
(StandardHostValve.class.getClassLoader());
@@ -244,7 +222,7 @@ final class StandardHostValve extends Va
// Ask this Context to process this request
context.getPipeline().getFirst().event(request, response, event);
-
+
// Error page processing
response.setSuspended(false);
@@ -287,16 +265,18 @@ final class StandardHostValve extends Va
// Handle a custom error page for this status code
Context context = request.getContext();
- if (context == null)
+ if (context == null) {
return;
+ }
/* Only look for error pages when isError() is set.
* isError() is set when response.sendError() is invoked. This
* allows custom error pages without relying on default from
* web.xml.
*/
- if (!response.isError())
+ if (!response.isError()) {
return;
+ }
ErrorPage errorPage = context.findErrorPage(statusCode);
if (errorPage != null) {
@@ -305,8 +285,9 @@ final class StandardHostValve extends Va
Integer.valueOf(statusCode));
String message = response.getMessage();
- if (message == null)
+ if (message == null) {
message = "";
+ }
request.setAttribute(RequestDispatcher.ERROR_MESSAGE, message);
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
@@ -316,9 +297,10 @@ final class StandardHostValve extends Va
Wrapper wrapper = request.getWrapper();
- if (wrapper != null)
+ if (wrapper != null) {
request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
wrapper.getName());
+ }
request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
request.getRequestURI());
if (custom(request, response, errorPage)) {
@@ -348,8 +330,9 @@ final class StandardHostValve extends Va
private void throwable(Request request, Response response,
Throwable throwable) {
Context context = request.getContext();
- if (context == null)
+ if (context == null) {
return;
+ }
Throwable realError = throwable;
@@ -389,9 +372,10 @@ final class StandardHostValve extends Va
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION,
realError);
Wrapper wrapper = request.getWrapper();
- if (wrapper != null)
+ if (wrapper != null) {
request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
wrapper.getName());
+ }
request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
request.getRequestURI());
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE,
@@ -432,8 +416,9 @@ final class StandardHostValve extends Va
private boolean custom(Request request, Response response,
ErrorPage errorPage) {
- if (container.getLogger().isDebugEnabled())
+ if (container.getLogger().isDebugEnabled()) {
container.getLogger().debug("Processing " + errorPage);
+ }
request.setPathInfo(errorPage.getLocation());
@@ -446,7 +431,7 @@ final class StandardHostValve extends Va
if (response.isCommitted()) {
// Response is committed - including the error page is the
- // best we can do
+ // best we can do
rd.include(request.getRequest(), response.getResponse());
} else {
// Reset the response (keeping the real error code and message)
@@ -483,17 +468,20 @@ final class StandardHostValve extends Va
private static ErrorPage findErrorPage
(Context context, Throwable exception) {
- if (exception == null)
+ if (exception == null) {
return (null);
+ }
Class<?> clazz = exception.getClass();
String name = clazz.getName();
while (!Object.class.equals(clazz)) {
ErrorPage errorPage = context.findErrorPage(name);
- if (errorPage != null)
+ if (errorPage != null) {
return (errorPage);
+ }
clazz = clazz.getSuperclass();
- if (clazz == null)
+ if (clazz == null) {
break;
+ }
name = clazz.getName();
}
return (null);
@@ -503,7 +491,7 @@ final class StandardHostValve extends Va
private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
- private ClassLoader cl;
+ private final ClassLoader cl;
PrivilegedSetTccl(ClassLoader cl) {
this.cl = cl;
Modified: tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java?rev=1187756&r1=1187755&r2=1187756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOn.java Sat Oct 22 19:25:55 2011
@@ -54,20 +54,10 @@ import org.apache.tomcat.util.ExceptionU
*
* @author Fabien Carrion
*/
-
-public class ClusterSingleSignOn
- extends SingleSignOn {
-
+public class ClusterSingleSignOn extends SingleSignOn {
// ----------------------------------------------------- Instance Variables
-
- /**
- * Descriptive information about this Valve implementation.
- */
- protected static final String info =
- "org.apache.catalina.ha.authenticator.ClusterSingleSignOn";
-
protected int messageNumber = 0;
private ClusterSingleSignOnListener clusterSSOListener = null;
@@ -76,29 +66,9 @@ public class ClusterSingleSignOn
// ------------------------------------------------------------- Properties
private CatalinaCluster cluster = null;
-
-
-
- /**
- * Return descriptive information about this Valve implementation.
- */
- @Override
- public String getInfo() {
-
- return (info);
-
- }
-
- public CatalinaCluster getCluster() {
-
- return cluster;
-
- }
-
+ public CatalinaCluster getCluster() { return cluster; }
public void setCluster(CatalinaCluster cluster) {
-
this.cluster = cluster;
-
}
@@ -114,7 +84,7 @@ public class ClusterSingleSignOn
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
-
+
clusterSSOListener = new ClusterSingleSignOnListener();
clusterSSOListener.setClusterSSO(this);
@@ -197,16 +167,18 @@ public class ClusterSingleSignOn
new SingleSignOnMessage(cluster.getLocalMember(),
ssoId, session.getId());
Manager mgr = session.getManager();
- if ((mgr != null) && (mgr instanceof ClusterManager))
+ if ((mgr != null) && (mgr instanceof ClusterManager)) {
msg.setContextName(((ClusterManager) mgr).getName());
+ }
msg.setAction(SingleSignOnMessage.ADD_SESSION);
cluster.send(msg);
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("SingleSignOnMessage Send with action "
+ msg.getAction());
+ }
}
associateLocal(ssoId, session);
@@ -237,15 +209,17 @@ public class ClusterSingleSignOn
new SingleSignOnMessage(cluster.getLocalMember(),
ssoId, session.getId());
Manager mgr = session.getManager();
- if ((mgr != null) && (mgr instanceof ClusterManager))
+ if ((mgr != null) && (mgr instanceof ClusterManager)) {
msg.setContextName(((ClusterManager) mgr).getName());
+ }
msg.setAction(SingleSignOnMessage.DEREGISTER_SESSION);
cluster.send(msg);
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("SingleSignOnMessage Send with action "
+ msg.getAction());
+ }
}
deregisterLocal(ssoId, session);
@@ -277,9 +251,10 @@ public class ClusterSingleSignOn
msg.setAction(SingleSignOnMessage.LOGOUT_SESSION);
cluster.send(msg);
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("SingleSignOnMessage Send with action "
+ msg.getAction());
+ }
}
deregisterLocal(ssoId);
@@ -319,9 +294,10 @@ public class ClusterSingleSignOn
msg.setPassword(password);
cluster.send(msg);
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("SingleSignOnMessage Send with action "
+ msg.getAction());
+ }
}
registerLocal(ssoId, principal, authType, username, password);
@@ -377,9 +353,10 @@ public class ClusterSingleSignOn
msg.setPassword(password);
cluster.send(msg);
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("SingleSignOnMessage Send with action "
+ msg.getAction());
+ }
}
updateLocal(ssoId, principal, authType, username, password);
@@ -411,15 +388,17 @@ public class ClusterSingleSignOn
ssoId, session.getId());
Manager mgr = session.getManager();
- if ((mgr != null) && (mgr instanceof ClusterManager))
+ if ((mgr != null) && (mgr instanceof ClusterManager)) {
msg.setContextName(((ClusterManager) mgr).getName());
+ }
msg.setAction(SingleSignOnMessage.REMOVE_SESSION);
cluster.send(msg);
- if (containerLog.isDebugEnabled())
+ if (containerLog.isDebugEnabled()) {
containerLog.debug("SingleSignOnMessage Send with action "
+ msg.getAction());
+ }
}
removeSessionLocal(ssoId, session);
@@ -428,7 +407,7 @@ public class ClusterSingleSignOn
protected void removeSessionLocal(String ssoId, Session session) {
super.removeSession(ssoId, session);
-
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org