You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by na...@locus.apache.org on 2000/11/02 01:38:03 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/request JDBCRealm.java SimpleRealm.java

nacho       00/11/01 16:38:03

  Modified:    src/share/org/apache/tomcat/request JDBCRealm.java
                        SimpleRealm.java
  Log:
  Adjusting Realms to the new startup order
  
  Revision  Changes    Path
  1.23      +22 -20    jakarta-tomcat/src/share/org/apache/tomcat/request/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/JDBCRealm.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JDBCRealm.java	2000/10/23 15:17:57	1.22
  +++ JDBCRealm.java	2000/11/02 00:38:02	1.23
  @@ -1,7 +1,7 @@
  -/* 
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/JDBCRealm.java,v 1.22 2000/10/23 15:17:57 nacho Exp $
  - * $Revision: 1.22 $
  - * $Date: 2000/10/23 15:17:57 $
  +/*
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/JDBCRealm.java,v 1.23 2000/11/02 00:38:02 nacho Exp $
  + * $Revision: 1.23 $
  + * $Date: 2000/11/02 00:38:02 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -473,6 +473,7 @@
   	// Validate and update our current component state
         if (!started) {
             started = true;
  +      // set-up a per/container note for maps
             try {
               Class.forName(driverName);
               if ((connectionName == null || connectionName.equals("")) &&
  @@ -508,22 +509,6 @@
         }
       }
   
  -    public void setContextManager( ContextManager cm ) {
  -      super.setContextManager( cm );
  -
  -      this.cm=cm;
  -      // set-up a per/container note for maps
  -      try {
  -          // XXX make the name a "global" static - after everything is stable!
  -          reqRolesNote = cm.getNoteId( ContextManager.REQUEST_NOTE
  -                , "required.roles");
  -          reqRealmSignNote = cm.getNoteId( ContextManager.REQUEST_NOTE
  -                , "realm.sign");
  -      } catch( TomcatException ex ) {
  -          log("setting up note for " + cm, ex);
  -          throw new RuntimeException( "Invalid state ");
  -      }
  -    }
   
       public int authenticate( Request req, Response response ) {
           // Extract the credentials
  @@ -623,6 +608,23 @@
               }
           }
   
  +    }
  +
  +    /** Called when the ContextManger is started
  +     */
  +    public void engineInit(ContextManager cm) throws TomcatException {
  +        //TODO:  Override this org.apache.tomcat.core.BaseInterceptor method
  +        super.engineInit(cm);
  +        try {
  +          // XXX make the name a "global" static - after everything is stable!
  +          reqRolesNote = cm.getNoteId( ContextManager.REQUEST_NOTE
  +                , "required.roles");
  +          reqRealmSignNote = cm.getNoteId( ContextManager.REQUEST_NOTE
  +                , "realm.sign");
  +        } catch( TomcatException ex ) {
  +          log("setting up note for " + cm, ex);
  +          throw new RuntimeException( "Invalid state ");
  +        }
       }
   
   
  
  
  
  1.11      +36 -39    jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleRealm.java
  
  Index: SimpleRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleRealm.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SimpleRealm.java	2000/10/23 15:17:57	1.10
  +++ SimpleRealm.java	2000/11/02 00:38:02	1.11
  @@ -90,27 +90,7 @@
       public SimpleRealm() {
       }
   
  -    /** Set the context manager. To keep it simple we don't support
  -     *  dynamic add/remove for this interceptor.
  -     */
  -    public void setContextManager( ContextManager cm ) {
  -	super.setContextManager( cm );
  -
  -	this.cm=cm;
  -	// set-up a per/container note for maps
  -	try {
  -	    // XXX make the name a "global" static -
  -	    reqRolesNote = cm.getNoteId( ContextManager.REQUEST_NOTE,
  -					 "required.roles");
  -            reqRealmSignNote = cm.getNoteId( ContextManager.REQUEST_NOTE
  -                                   , "realm.sign");
  -	} catch( TomcatException ex ) {
  -	    log("getting note for " + cm, ex);
  -	    throw new RuntimeException( "Invalid state ");
  -	}
  -    }
  -
  -    public void contextInit( Context ctx)
  +    public void contextInit(Context ctx)
   	throws TomcatException
       {
   	if( memoryRealm==null) {
  @@ -148,16 +128,16 @@
   
       public int authorize( Request req, Response response, String roles[] )
       {
  -	if( roles==null || roles.length==0 ) {
  -	    // request doesn't need authentication
  -	    return 0;
  -	}
  +        if( roles==null || roles.length==0 ) {
  +            // request doesn't need authentication
  +            return 0;
  +        }
   
  -	Context ctx=req.getContext();
  +        Context ctx=req.getContext();
   
  -	String userRoles[]=null;
  -	String user=req.getRemoteUser();
  -	if( user==null )
  +        String userRoles[]=null;
  +        String user=req.getRemoteUser();
  +        if( user==null )
   	    return 401;
   
           if( ! this.equals(req.getNote(reqRealmSignNote)) ){
  @@ -166,19 +146,19 @@
   
   
   
  -	if( debug > 0 ) log( "Controled access for " + user + " " +
  -			     req + " " + req.getContainer() );
  +        if( debug > 0 ) log( "Controled access for " + user + " " +
  +                     req + " " + req.getContainer() );
   
  -	userRoles = memoryRealm.getUserRoles( user );
  -        if ( userRoles == null )
  -            return 0;
  -	req.setUserRoles( userRoles );
  +        userRoles = memoryRealm.getUserRoles( user );
  +            if ( userRoles == null )
  +                return 0;
  +        req.setUserRoles( userRoles );
   
  -	if( SecurityTools.haveRole( userRoles, roles ))
  -	    return 0;
  +        if( SecurityTools.haveRole( userRoles, roles ))
  +            return 0;
   
  -	if( debug > 0 ) log( "UnAuthorized " + roles[0] );
  - 	return 401;
  +        if( debug > 0 ) log( "UnAuthorized " + roles[0] );
  +        return 401;
       }
   
       public String getFilename() {
  @@ -187,6 +167,23 @@
   
       public void setFilename(String newFilename) {
           filename = newFilename;
  +    }
  +
  +    /** Called when the ContextManger is started
  +     */
  +    public void engineInit(ContextManager cm) throws TomcatException {
  +        super.engineInit(cm);
  +        // set-up a per/container note for maps
  +        try {
  +            // XXX make the name a "global" static -
  +            reqRolesNote = cm.getNoteId( ContextManager.REQUEST_NOTE,
  +                         "required.roles");
  +                reqRealmSignNote = cm.getNoteId( ContextManager.REQUEST_NOTE
  +                                       , "realm.sign");
  +        } catch( TomcatException ex ) {
  +            log("getting note for " + cm, ex);
  +            throw new RuntimeException( "Invalid state ");
  +        }
       }
   }