[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java JBossWebApplicationContext.java Jetty.java JettyResolver.java JettyService.java
User: jules_gosnell Date: 02/03/20 12:58:31 Modified:jetty/src/main/org/jboss/jetty Tag: Branch_2_4 JBossUserRealm.java JBossWebApplicationContext.java Jetty.java JettyResolver.java JettyService.java Log: going for a release on Jetty 3.1.7 (with one fix) this is mainly backporting from JBoss3/Jetty4 src Revision ChangesPath No revision No revision 1.2.2.7 +6 -5 contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java,v retrieving revision 1.2.2.6 retrieving revision 1.2.2.7 diff -u -r1.2.2.6 -r1.2.2.7 --- JBossUserRealm.java 28 Feb 2002 19:21:13 - 1.2.2.6 +++ JBossUserRealm.java 20 Mar 2002 20:58:31 - 1.2.2.7 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.2.2.6 2002/02/28 19:21:13 danch Exp $ +// $Id: JBossUserRealm.java,v 1.2.2.7 2002/03/20 20:58:31 jules_gosnell Exp $ package org.jboss.jetty; @@ -15,6 +15,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.apache.log4j.Category; +import org.jboss.logging.Logger; import org.jboss.security.AuthenticationManager; import org.jboss.security.RealmMapping; import org.jboss.security.SecurityAssociation; @@ -26,7 +27,7 @@ /** An implementation of UserRealm that integrates with the JBossSX * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.2.2.6 $ + * @version $Revision: 1.2.2.7 $ * * pbRevisions:/b * @@ -38,7 +39,7 @@ */ public class JBossUserRealm implements UserRealm { - private Category _log; + private Logger _log; private String _realmName; private AuthenticationManager _securityMgr; private RealmMapping _realmMapping; @@ -116,8 +117,8 @@ } } - public JBossUserRealm(Category log, String realmName) { - _log = log; + public JBossUserRealm(String realmName) { + _log = Logger.getLogger(JBossUserRealm.class.getName() + # + _realmName); _realmName = realmName; _log.info(Security- created JBossUserRealm: +_realmName); } 1.34.2.2 +305 -31 contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java Index: JBossWebApplicationContext.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java,v retrieving revision 1.34.2.1 retrieving revision 1.34.2.2 diff -u -r1.34.2.1 -r1.34.2.2 --- JBossWebApplicationContext.java 20 Mar 2002 00:30:24 - 1.34.2.1 +++ JBossWebApplicationContext.java 20 Mar 2002 20:58:31 - 1.34.2.2 @@ -5,71 +5,345 @@ * See terms of license at gnu.org. */ -// $Id: JBossWebApplicationContext.java,v 1.34.2.1 2002/03/20 00:30:24 jules_gosnell Exp $ +// $Id: JBossWebApplicationContext.java,v 1.34.2.2 2002/03/20 20:58:31 jules_gosnell Exp $ // A Jetty HttpServer with the interface expected by JBoss' // J2EEDeployer... +//-- + package org.jboss.jetty; -import org.apache.log4j.Category; +//-- + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import javax.xml.parsers.DocumentBuilder; +import org.jboss.jetty.JBossUserRealm; +import org.jboss.logging.Logger; import org.jboss.web.AbstractWebContainer.WebDescriptorParser; import org.jboss.web.WebApplication; +import org.mortbay.http.ContextLoader; import org.mortbay.http.HttpServer; +import org.mortbay.http.handler.SecurityHandler; import org.mortbay.jetty.servlet.WebApplicationContext; -import org.w3c.dom.Element; +import org.mortbay.util.Resource; +import org.xml.sax.InputSource; + +import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; + +//-- public class JBossWebApplicationContext extends WebApplicationContext { - Category_log; + Logger _log; + Jetty _jetty; WebDescriptorParser _descriptorParser; WebApplication _webApp; + DocumentBuilder _parser; + // String _subjAttrName=j_subject; public -JBossWebApplicationContext(HttpServer httpServer, +JBossWebApplicationContext(Jetty jetty,
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java
User: danch Date: 02/02/28 11:21:13 Modified:jetty/src/main/org/jboss/jetty Tag: Branch_2_4 JBossUserRealm.java Log: finished the 'fix' for the NotSerializableException Revision ChangesPath No revision No revision 1.2.2.6 +7 -5 contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -u -r1.2.2.5 -r1.2.2.6 --- JBossUserRealm.java 22 Feb 2002 19:24:03 - 1.2.2.5 +++ JBossUserRealm.java 28 Feb 2002 19:21:13 - 1.2.2.6 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.2.2.5 2002/02/22 19:24:03 danch Exp $ +// $Id: JBossUserRealm.java,v 1.2.2.6 2002/02/28 19:21:13 danch Exp $ package org.jboss.jetty; @@ -26,7 +26,7 @@ /** An implementation of UserRealm that integrates with the JBossSX * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.2.2.5 $ + * @version $Revision: 1.2.2.6 $ * * pbRevisions:/b * @@ -77,12 +77,13 @@ String userName = this.getName(); // needs disambiguation // Get the JBoss security manager from the ENC context - if (_securityMgr != null _securityMgr.isValid(this, password)) { + SimplePrincipal propogationPrincipal = new SimplePrincipal(userName); + if (_securityMgr != null _securityMgr.isValid(propogationPrincipal, password.toCharArray())) { authenticated = true; _log.info(Security- User: +userName + is authenticated); // work around the fact that we are not serialisable - thanks Anatoly // SecurityAssociation.setPrincipal(this); - SecurityAssociation.setPrincipal(new SimplePrincipal(userName)); + SecurityAssociation.setPrincipal(propogationPrincipal); SecurityAssociation.setCredential(password.toCharArray()); } else { _log.warn(Security- User: +userName + is NOT authenticated); @@ -97,8 +98,9 @@ // Get the JBoss security manager from the ENC context SimplePrincipal rolePrincipal = new SimplePrincipal(role); + SimplePrincipal propogationPrincipal = new SimplePrincipal(userName); Set requiredRoles = Collections.singleton(rolePrincipal); - if (_realmMapping.doesUserHaveRole(this, requiredRoles)) { + if (_realmMapping.doesUserHaveRole(propogationPrincipal, requiredRoles)) { isUserInRole = true; _log.info(Security- User: +userName + is in Role: +role); } else { ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java
User: danch Date: 02/02/22 11:24:03 Modified:jetty/src/main/org/jboss/jetty Tag: Branch_2_4 JBossUserRealm.java Log: beautified and back-ported the fix for the 'not serializable' problem from the 3.0 main Revision ChangesPath No revision No revision 1.2.2.5 +136 -159 contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- JBossUserRealm.java 2 Dec 2001 02:08:53 - 1.2.2.4 +++ JBossUserRealm.java 22 Feb 2002 19:24:03 - 1.2.2.5 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.2.2.4 2001/12/02 02:08:53 starksm Exp $ +// $Id: JBossUserRealm.java,v 1.2.2.5 2002/02/22 19:24:03 danch Exp $ package org.jboss.jetty; @@ -26,165 +26,142 @@ /** An implementation of UserRealm that integrates with the JBossSX * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.2.2.4 $ + * @version $Revision: 1.2.2.5 $ + * + * pbRevisions:/b + * + * pb20020220 danch:/b + * ul + * li beautified 8^})/li + * li Back-port '... not Serializable ' fix by Anatoly Akkerman + * /ul */ -public class JBossUserRealm - implements UserRealm -{ - private Category _log; - private String _realmName; - private AuthenticationManager _securityMgr; - private RealmMapping _realmMapping; - private HashMap_users = new HashMap(); - - class User -extends SimplePrincipal -implements UserPrincipal - { -User(String name) -{ - super(name); - _log.info(Security- created JBossUserRealm::User: +name); -} - -public boolean - equals(Object o) -{ - if (o==this) - return true; - - if (o==null) - return false; - - if (getClass()!=o.getClass()) - return false; - - String myName =this.getName(); - String yourName=((User)o).getName(); - - if (myName==null yourName==null) - return true; - - if (myName!=null myName.equals(yourName)) - return true; - - return false; -} - -public boolean - authenticate(String password, HttpRequest request) -{ - boolean authenticated = false; - String userName = this.getName(); // needs disambiguation - - // Get the JBoss security manager from the ENC context - if(_securityMgr!=null _securityMgr.isValid(this, password)) - { - authenticated = true; - _log.info(Security- User: +userName+ is authenticated); - SecurityAssociation.setPrincipal(this); - SecurityAssociation.setCredential(password.toCharArray()); - } - else - { - _log.warn(Security- User: +userName+ is NOT authenticated); - } - - return authenticated; -} - -public boolean - isUserInRole(String role) -{ - boolean isUserInRole = false; - String userName = this.getName(); - - // Get the JBoss security manager from the ENC context - SimplePrincipal rolePrincipal = new SimplePrincipal(role); - Set requiredRoles = Collections.singleton(rolePrincipal); - if(_realmMapping.doesUserHaveRole(this, requiredRoles)) - { - isUserInRole = true; - _log.info(Security- User: +userName+ is in Role: +role); - } - else - { - _log.warn(Security- User: +userName+ is NOT in Role: +role); - } - - return isUserInRole; -} - -public UserRealm - getUserRealm() -{ - return JBossUserRealm.this; -} - } - - public -JBossUserRealm(Category log, String realmName) - { -_log = log; -_realmName = realmName; -_log.info(Security- created JBossUserRealm: +_realmName); - } - - public String -getName() - { -return _realmName; - } - - /** - * @deprecated - */ - public UserPrincipal -getUser(String userName, HttpRequest request) - { -return getUser(userName); - } - - // - - private synchronized User -ensureUser(String userName) - { -User user = (User)_users.get(userName); - -if (user==null) -{ - user=new User(userName); - _users.put(userName, user); -} - -return user; - } - - public UserPrincipal -getUser(String userName) - { -if
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java
User: jules_gosnell Date: 02/01/02 03:10:55 Modified:jetty/src/main/org/jboss/jetty JBossUserRealm.java Log: can't check this yet because my build doesn't run - but should be better than what was there before Revision ChangesPath 1.11 +40 -10contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JBossUserRealm.java 2001/12/09 06:05:49 1.10 +++ JBossUserRealm.java 2002/01/02 11:10:55 1.11 @@ -5,10 +5,12 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.10 2001/12/09 06:05:49 user57 Exp $ +// $Id: JBossUserRealm.java,v 1.11 2002/01/02 11:10:55 jules_gosnell Exp $ package org.jboss.jetty; +import java.io.IOException; +import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Set; @@ -16,7 +18,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import javax.security.auth.Subject; - +import org.jboss.logging.Logger; import org.jboss.security.AuthenticationManager; import org.jboss.security.RealmMapping; import org.jboss.security.SecurityAssociation; @@ -26,22 +28,20 @@ import org.mortbay.http.UserPrincipal; import org.mortbay.http.UserRealm; -import org.jboss.logging.Logger; - /** An implementation of UserRealm that integrates with the JBossSX * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ // TODO public class JBossUserRealm - implements UserRealm + implements UserRealm, Serializable { class JBossUserPrincipal extends SimplePrincipal // The JBoss API -implements UserPrincipal // The Jetty API +implements UserPrincipal,Serializable // The Jetty API { JBossUserPrincipal(String name) { @@ -98,7 +98,6 @@ Subject subject = _subjectMgr.getActiveSubject(); request.setAttribute(_subjectAttributeName, subject); } - } else { @@ -133,11 +132,17 @@ { return JBossUserRealm.this; } + +public boolean + isAuthenticated() +{ + return false; // TODO +} } - private Logger _log; + private Logger _log; private String _realmName; - private AuthenticationManager _securityMgr; + private AuthenticationManager _securityMgr; private RealmMapping _realmMapping; private HashMap_users = new HashMap(); private String _subjectAttributeName = j_subject; // needs accessors - TODO @@ -146,6 +151,12 @@ public JBossUserRealm(String realmName) { +initialise(realmName); + } + + protected void +initialise(String realmName) + { _realmName = realmName; _log = Logger.getLogger(JBossUserRealm.class.getName() + # + _realmName); @@ -210,4 +221,23 @@ } // + // Serializable + + private void writeObject(java.io.ObjectOutputStream out) +throws IOException + { +out.writeObject(_realmName); +// out.writebject(_log); +// out.writebject(_securityMgr); +// out.writebject(_realmMapping); +// out.writebject(_users); +// out.writebject(_subjectAttributeName); +// out.writebject(_subjectMgr); + } + + private void readObject(java.io.ObjectInputStream in) +throws IOException, ClassNotFoundException + { +initialise((String)in.readObject()); + } } ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java
User: jules_gosnell Date: 02/01/02 09:09:45 Modified:jetty/src/main/org/jboss/jetty JBossUserRealm.java Log: remove Serializable stuff - this was only a incomplete and temporary hack allow Greg to use isAuthenticated() to recheck authentication status tidy up Revision ChangesPath 1.12 +71 -96contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- JBossUserRealm.java 2002/01/02 11:10:55 1.11 +++ JBossUserRealm.java 2002/01/02 17:09:45 1.12 @@ -5,12 +5,10 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.11 2002/01/02 11:10:55 jules_gosnell Exp $ +// $Id: JBossUserRealm.java,v 1.12 2002/01/02 17:09:45 jules_gosnell Exp $ package org.jboss.jetty; -import java.io.IOException; -import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Set; @@ -31,17 +29,17 @@ /** An implementation of UserRealm that integrates with the JBossSX * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.11 $ + * @version $Revision: 1.12 $ */ // TODO public class JBossUserRealm - implements UserRealm, Serializable + implements UserRealm // Jetty API { class JBossUserPrincipal -extends SimplePrincipal // The JBoss API -implements UserPrincipal,Serializable // The Jetty API +extends SimplePrincipal // JBoss API +implements UserPrincipal // Jetty API { JBossUserPrincipal(String name) { @@ -49,6 +47,32 @@ _log.info(created JBossUserRealm::JBossUserPrincipal: +name); } +protected boolean + isAuthenticated(String password) +{ + String userName = this.getName(); // needs disambiguation because our outer class + boolean authenticated = false; + + if (password==null) + password=; + + char[] passwordChars = password.toCharArray(); + _log.info(authenticating: Name:+userName+ Password:+password); + if(_authMgr!=null _authMgr.isValid(this, passwordChars)) + { + _log.info(JBossUserPrincipal: +userName+ is authenticated); + SecurityAssociation.setPrincipal(this); + SecurityAssociation.setCredential(passwordChars); + authenticated=true; + } + else + { + _log.warn(JBossUserPrincipal: +userName+ is NOT authenticated); + } + + return authenticated; +} + public boolean equals(Object o) { @@ -73,41 +97,43 @@ return false; } +// +// SimplePrincipal - for JBoss + +// +// UserPrincipal - for Jetty + public boolean authenticate(String password, HttpRequest request) { - boolean authenticated = false; - String userName = this.getName(); // needs disambiguation because our outer class - - if (password==null) - password=; - - char[] passwordChars = password.toCharArray(); - _log.info(authenticating: Name:+userName+ Password:+password); - if(_securityMgr!=null _securityMgr.isValid(this, passwordChars)) + _password=password; + boolean authenticated=false; + authenticated=isAuthenticated(_password); + + // This doesn't mean anything to Jetty - but may to some + // Servlets - confirm later... + if (authenticated _subjSecMgr!=null) { - _log.info(JBossUserPrincipal: +userName+ is authenticated); - SecurityAssociation.setPrincipal(this); - SecurityAssociation.setCredential(passwordChars); - authenticated=true; - - // This doesn't mean anything to Jetty - but may to some - // Servlets - confirm later... - if (_subjectMgr!=null) - { - Subject subject = _subjectMgr.getActiveSubject(); - request.setAttribute(_subjectAttributeName, subject); - } + Subject subject = _subjSecMgr.getActiveSubject(); + request.setAttribute(_subjAttrName, subject); } - else - { - _log.warn(JBossUserPrincipal: +userName+ is NOT authenticated); - } return authenticated; } public boolean + isAuthenticated() +{ + return isAuthenticated(_password); +} + +public UserRealm + getUserRealm() +{ + return JBossUserRealm.this; +} + +public boolean isUserInRole(String role) { boolean isUserInRole =
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java JBossWebApplicationContext.java
User: starksm Date: 01/12/02 20:15:51 Modified:jetty/src/main/org/jboss/jetty JBossUserRealm.java JBossWebApplicationContext.java Log: Change EJBSecurityMgr to AuthenticationManager Revision ChangesPath 1.9 +5 -5 contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JBossUserRealm.java 2001/11/21 23:13:01 1.8 +++ JBossUserRealm.java 2001/12/03 04:15:51 1.9 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.8 2001/11/21 23:13:01 jules_gosnell Exp $ +// $Id: JBossUserRealm.java,v 1.9 2001/12/03 04:15:51 starksm Exp $ package org.jboss.jetty; @@ -17,7 +17,7 @@ import javax.naming.NamingException; import javax.security.auth.Subject; import org.apache.log4j.Category; -import org.jboss.security.EJBSecurityManager; +import org.jboss.security.AuthenticationManager; import org.jboss.security.RealmMapping; import org.jboss.security.SecurityAssociation; import org.jboss.security.SimplePrincipal; @@ -29,7 +29,7 @@ /** An implementation of UserRealm that integrates with the JBossSX * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ // TODO @@ -135,7 +135,7 @@ private Category _log=Category.getInstance(Jetty); private String _realmName; - private EJBSecurityManager _securityMgr; + private AuthenticationManager _securityMgr; private RealmMapping _realmMapping; private HashMap_users = new HashMap(); private String _subjectAttributeName = j_subject; // needs accessors - TODO @@ -153,7 +153,7 @@ InitialContext iniCtx = new InitialContext(); // do we need the 'java:comp/env' prefix ? TODO Context securityCtx =(Context) iniCtx.lookup(java:comp/env/security); - _securityMgr =(EJBSecurityManager) securityCtx.lookup(securityMgr); + _securityMgr =(AuthenticationManager) securityCtx.lookup(securityMgr); _realmMapping =(RealmMapping) securityCtx.lookup(realmMapping); iniCtx=null; 1.6 +1 -2 contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java Index: JBossWebApplicationContext.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JBossWebApplicationContext.java 2001/12/03 00:28:45 1.5 +++ JBossWebApplicationContext.java 2001/12/03 04:15:51 1.6 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossWebApplicationContext.java,v 1.5 2001/12/03 00:28:45 jules_gosnell Exp $ +// $Id: JBossWebApplicationContext.java,v 1.6 2001/12/03 04:15:51 starksm Exp $ // A Jetty HttpServer with the interface expected by JBoss' // J2EEDeployer... @@ -24,7 +24,6 @@ import javax.naming.Context; import javax.naming.InitialContext; -import org.jboss.security.EJBSecurityManager; import org.jboss.security.RealmMapping; import org.jboss.security.SimplePrincipal; import org.jboss.security.SecurityAssociation; ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java Jetty.java JettyService.java JettyServiceMBean.java
User: starksm Date: 01/12/01 18:08:53 Modified:jetty/src/main/org/jboss/jetty Tag: Branch_2_4 JBossUserRealm.java Jetty.java JettyService.java JettyServiceMBean.java Log: Synch up with changes for 2.4.4 and fix incorrect role type passed to RealmMapping.doesUserHaveRole Revision ChangesPath No revision No revision 1.2.2.4 +190 -189 contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -u -r1.2.2.3 -r1.2.2.4 --- JBossUserRealm.java 2001/10/30 22:45:12 1.2.2.3 +++ JBossUserRealm.java 2001/12/02 02:08:53 1.2.2.4 @@ -1,189 +1,190 @@ -/* - * jBoss, the OpenSource EJB server - * - * Distributable under GPL license. - * See terms of license at gnu.org. - */ - -// $Id: JBossUserRealm.java,v 1.2.2.3 2001/10/30 22:45:12 jules_gosnell Exp $ - -package org.jboss.jetty; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Set; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.apache.log4j.Category; -import org.jboss.security.EJBSecurityManager; -import org.jboss.security.RealmMapping; -import org.jboss.security.SecurityAssociation; -import org.jboss.security.SimplePrincipal; -import org.mortbay.http.HttpRequest; -import org.mortbay.http.UserPrincipal; -import org.mortbay.http.UserRealm; - -/** An implementation of UserRealm that integrates with the JBossSX - * security manager associted with the web application. - * @author [EMAIL PROTECTED] - * @version $Revision: 1.2.2.3 $ - */ - -public class JBossUserRealm - implements UserRealm -{ - private Category _log; - private String _realmName; - private EJBSecurityManager _securityMgr; - private RealmMapping _realmMapping; - private HashMap_users = new HashMap(); - - class User -extends SimplePrincipal -implements UserPrincipal - { -User(String name) -{ - super(name); - _log.info(Security- created JBossUserRealm::User: +name); -} - -public boolean - equals(Object o) -{ - if (o==this) - return true; - - if (o==null) - return false; - - if (getClass()!=o.getClass()) - return false; - - String myName =this.getName(); - String yourName=((User)o).getName(); - - if (myName==null yourName==null) - return true; - - if (myName!=null myName.equals(yourName)) - return true; - - return false; -} - -public boolean - authenticate(String password, HttpRequest request) -{ - boolean authenticated = false; - String userName = this.getName(); // needs disambiguation - - // Get the JBoss security manager from the ENC context - if(_securityMgr!=null _securityMgr.isValid(this, password)) - { - authenticated = true; - _log.info(Security- User: +userName+ is authenticated); - SecurityAssociation.setPrincipal(this); - SecurityAssociation.setCredential(password.toCharArray()); - } - else - { - _log.warn(Security- User: +userName+ is NOT authenticated); - } - - return authenticated; -} - -public boolean - isUserInRole(String role) -{ - boolean isUserInRole = false; - String userName = this.getName(); - - // Get the JBoss security manager from the ENC context - Set requiredRoles = Collections.singleton(role); - if(_realmMapping.doesUserHaveRole(this, requiredRoles)) - { - isUserInRole = true; - _log.info(Security- User: +userName+ is in Role: +role); - } - else - { - _log.warn(Security- User: +userName+ is NOT in Role: +role); - } - - return isUserInRole; -} - -public UserRealm - getUserRealm() -{ - return JBossUserRealm.this; -} - } - - public -JBossUserRealm(Category log, String realmName) - { -_log = log; -_realmName = realmName; -_log.info(Security- created JBossUserRealm: +_realmName); - } - - public String -getName() - { -return _realmName; - } - - /** - * @deprecated - */ - public UserPrincipal -getUser(String userName, HttpRequest request) - { -return getUser(userName); - } - - // - - private synchronized User -ensureUser(String userName) - {
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java JettyMBean.java JettyResolver.java
User: jules_gosnell Date: 01/09/17 16:07:47 Modified:jetty/src/main/org/jboss/jetty JBossUserRealm.java JettyMBean.java JettyResolver.java Log: share src between 2.4 and 3.0 Revision ChangesPath 1.7 +4 -5 contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JBossUserRealm.java 2001/09/16 17:14:17 1.6 +++ JBossUserRealm.java 2001/09/17 23:07:47 1.7 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossUserRealm.java,v 1.6 2001/09/16 17:14:17 jules_gosnell Exp $ +// $Id: JBossUserRealm.java,v 1.7 2001/09/17 23:07:47 jules_gosnell Exp $ package org.jboss.jetty; @@ -22,11 +22,10 @@ import org.mortbay.http.UserPrincipal; import org.mortbay.http.UserRealm; -/** An implementation of UserRealm that integrates with the JBossSX security -manager associted with the web application. - +/** An implementation of UserRealm that integrates with the JBossSX + * security manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class JBossUserRealm implements UserRealm 1.4 +1 -1 contrib/jetty/src/main/org/jboss/jetty/JettyMBean.java Index: JettyMBean.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JettyMBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 1.3 +1 -1 contrib/jetty/src/main/org/jboss/jetty/JettyResolver.java Index: JettyResolver.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JettyResolver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java
User: jules_gosnell Date: 01/06/13 16:00:23 Modified:jetty/src/main/org/jboss/jetty JBossUserRealm.java Log: cut down slightly on debug Revision ChangesPath 1.2 +3 -3 contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JBossUserRealm.java 2001/06/10 21:37:45 1.1 +++ JBossUserRealm.java 2001/06/13 23:00:23 1.2 @@ -18,7 +18,7 @@ manager associted with the web application. * @author [EMAIL PROTECTED] - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class JBossUserRealm implements UserRealm { @@ -37,7 +37,7 @@ { boolean authenticated = false; String username = this.getName(); -System.out.println(Authenticating access, username: + username + +request); + //System.out.println(Authenticating access, username: + username + +request); try { // Get the JBoss security manager from the ENC context @@ -76,7 +76,7 @@ { boolean isUserInRole = false; String username = this.getName(); -System.out.println(Authorizing access, username: + username + +request); + //System.out.println(Authorizing access, username: + username + +request); try { // Get the JBoss security manager from the ENC context ___ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: contrib/jetty/src/main/org/jboss/jetty JBossUserRealm.java
User: jules_gosnell Date: 01/06/10 14:37:45 Added: jetty/src/main/org/jboss/jetty JBossUserRealm.java Log: Scott's new JAAS integration - first cut - thanks Scott! Revision ChangesPath 1.1 contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java Index: JBossUserRealm.java === package org.jboss.jetty; import java.util.HashSet; import javax.naming.InitialContext; import javax.naming.NamingException; import com.mortbay.HTTP.HttpRequest; import com.mortbay.HTTP.UserPrincipal; import com.mortbay.HTTP.UserRealm; import org.jboss.security.EJBSecurityManager; import org.jboss.security.RealmMapping; import org.jboss.security.SimplePrincipal; import org.jboss.security.SecurityAssociation; import org.jboss.security.SubjectSecurityManager; /** An implementation of UserRealm that integrates with the JBossSX security manager associted with the web application. * @author [EMAIL PROTECTED] * @version $Revision: 1.1 $ */ public class JBossUserRealm implements UserRealm { private String realmName; class User extends SimplePrincipal implements UserPrincipal { HttpRequest request; User(String name, HttpRequest request) { super(name); this.request = request; } public boolean authenticate(String password) { boolean authenticated = false; String username = this.getName(); System.out.println(Authenticating access, username: + username + +request); try { // Get the JBoss security manager from the ENC context InitialContext iniCtx = new InitialContext(); EJBSecurityManager securityMgr = (EJBSecurityManager) iniCtx.lookup(java:comp/env/security/securityMgr); if( securityMgr.isValid(this, password) ) { authenticated = true; request.setAttribute(UserPrincipal.__ATTR, this); System.out.println(User: +username+ is authenticated); SecurityAssociation.setPrincipal(this); SecurityAssociation.setCredential(password.toCharArray()); /* if( useJAAS == true securityMgr instanceof SubjectSecurityManager ) { SubjectSecurityManager subjectMgr = (SubjectSecurityManager) securityMgr; Subject subject = subjectMgr.getActiveSubject(); request.setAttribute(subjectAttributeName, subject); } */ } else { System.out.println(User: +username+ is NOT authenticated); } } catch(NamingException e) { System.err.println(Error during authenticate); e.printStackTrace(); } return authenticated; } public boolean isUserInRole(String role) { boolean isUserInRole = false; String username = this.getName(); System.out.println(Authorizing access, username: + username + +request); try { // Get the JBoss security manager from the ENC context InitialContext iniCtx = new InitialContext(); RealmMapping securityMgr = (RealmMapping) iniCtx.lookup(java:comp/env/security/realmMapping); HashSet requiredRoles = new HashSet(); requiredRoles.add(role); if( securityMgr.doesUserHaveRole(this, requiredRoles) ) { isUserInRole = true; System.out.println(User: +username+ is authorized); } else { System.out.println(User: +username+ is NOT authorized, requiredRoles=+requiredRoles); } } catch(NamingException e) { System.err.println(Error during authorization); e.printStackTrace(); } return isUserInRole; } public UserRealm getUserRealm() { return JBossUserRealm.this; } } /** Creates new JBossUserRealm */ public JBossUserRealm(String realmName) { this.realmName = realmName; System.out.println(+++ Created JBossUserRealm, realmName=+realmName); } public String getName() { return realmName; } public UserPrincipal getUser(String username, HttpRequest