Author: jboynes
Date: Sat Sep 18 11:33:11 2004
New Revision: 46299
Added:
geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/PasswordCallbackHandler.java
Modified:
geronimo/trunk/etc/version-info.ent
geronimo/trunk/modules/assembly/project.xml
geronimo/trunk/modules/jetty/project.xml
geronimo/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml
geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java
Log:
Update Jetty 5.0.0 release
Remove dependency on jaas module from Jetty-Plus by adding our own CallbackHandler
Modified: geronimo/trunk/etc/version-info.ent
==============================================================================
--- geronimo/trunk/etc/version-info.ent (original)
+++ geronimo/trunk/etc/version-info.ent Sat Sep 18 11:33:11 2004
@@ -33,7 +33,7 @@
<!ENTITY howl-version "0.1.7">
<!ENTITY hsqldb-version "1.7.1">
<!ENTITY jelly-velocity-tags-version "SNAPSHOT">
-<!ENTITY jetty-version "5.0.RC0">
+<!ENTITY jetty-version "5.0.0">
<!ENTITY jaxb-ri-version "SNAPSHOT">
<!ENTITY junit-version "3.8">
<!ENTITY log4j-version "1.2.8">
Modified: geronimo/trunk/modules/assembly/project.xml
==============================================================================
--- geronimo/trunk/modules/assembly/project.xml (original)
+++ geronimo/trunk/modules/assembly/project.xml Sat Sep 18 11:33:11 2004
@@ -508,15 +508,6 @@
</properties>
</dependency>
- <dependency>
- <groupId>jetty</groupId>
- <artifactId>org.mortbay.jaas</artifactId>
- <version>&jetty-version;</version>
- <properties>
- <repository>true</repository>
- </properties>
- </dependency>
-
<!-- for jsps -->
<dependency>
<groupId>tomcat</groupId>
Modified: geronimo/trunk/modules/jetty/project.xml
==============================================================================
--- geronimo/trunk/modules/jetty/project.xml (original)
+++ geronimo/trunk/modules/jetty/project.xml Sat Sep 18 11:33:11 2004
@@ -161,12 +161,6 @@
</dependency>
<dependency>
- <groupId>jetty</groupId>
- <artifactId>org.mortbay.jaas</artifactId>
- <version>&jetty-version;</version>
- </dependency>
-
- <dependency>
<groupId>mx4j</groupId>
<artifactId>mx4j</artifactId>
<version>&mx4j-version;</version>
Modified: geronimo/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml
==============================================================================
--- geronimo/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml (original)
+++ geronimo/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml Sat Sep 18 11:33:11
2004
@@ -18,10 +18,7 @@
<service xmlns="http://geronimo.apache.org/xml/ns/deployment">
<dependency>
- <uri>jetty/jars/org.mortbay.jetty-5.0.RC0.jar</uri>
- </dependency>
- <dependency>
- <uri>jetty/jars/org.mortbay.jaas-5.0.RC0.jar</uri>
+ <uri>jetty/jars/org.mortbay.jetty-5.0.0.jar</uri>
</dependency>
<dependency>
<uri>tomcat/jars/jasper-compiler-5.0.16.jar</uri>
Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java Sat
Sep 18 11:33:11 2004
@@ -16,29 +16,23 @@
*/
package org.apache.geronimo.jetty;
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-import javax.security.jacc.WebRoleRefPermission;
import java.security.AccessControlContext;
import java.security.AccessControlException;
-import java.security.AccessController;
import java.security.Principal;
import java.util.HashMap;
-import java.util.Stack;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import javax.security.jacc.WebRoleRefPermission;
-import org.mortbay.http.HttpRequest;
-import org.mortbay.http.UserRealm;
-import org.mortbay.jaas.callback.DefaultCallbackHandler;
-import org.mortbay.util.LogSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.gbean.WaitingException;
import org.apache.geronimo.security.ContextManager;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.UserRealm;
/**
@@ -74,7 +68,6 @@
}
public Principal authenticate(String username, Object credentials, HttpRequest request)
{
-
try {
JAASJettyPrincipal userPrincipal = (JAASJettyPrincipal) userMap.get(username);
@@ -85,16 +78,20 @@
}
- DefaultCallbackHandler callbackHandler = new DefaultCallbackHandler();
-
- callbackHandler.setUserName(username);
- callbackHandler.setCredential(credentials);
+ char[] password;
+ if (credentials instanceof char[]) {
+ password = (char[])credentials;
+ } else if (credentials instanceof String) {
+ password = ((String)credentials).toCharArray();
+ } else {
+ throw new LoginException("Cannot extract credentials from class: " + credentials.getClass().getName());
+ }
+ PasswordCallbackHandler callbackHandler = new PasswordCallbackHandler(username,
password);
//set up the login context
- LoginContext loginContext = new LoginContext(loginModuleName,
- callbackHandler);
-
+ LoginContext loginContext = new LoginContext(loginModuleName, callbackHandler);
loginContext.login();
+ callbackHandler.clear();
ContextManager.registerSubject(loginContext.getSubject());
ContextManager.setCurrentCaller(loginContext.getSubject());
Added: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/PasswordCallbackHandler.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/PasswordCallbackHandler.java
Sat Sep 18 11:33:11 2004
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.geronimo.jetty;
+
+import java.util.Arrays;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class PasswordCallbackHandler implements CallbackHandler {
+ private final String username;
+ private final char[] password;
+
+ public PasswordCallbackHandler(String username, char[] password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ Callback callback = callbacks[i];
+ if (callback instanceof NameCallback) {
+ NameCallback nc = (NameCallback) callback;
+ nc.setName(username);
+ } else if (callback instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback) callback;
+ pc.setPassword(password);
+ } else {
+ throw new UnsupportedCallbackException(callback);
+ }
+ }
+ }
+
+ public void clear() {
+ Arrays.fill(password, '\0');
+ }
+}
|