Package org.apache.tomcat.core

Examples of org.apache.tomcat.core.Context


    }

    /** Extract the credentails from req
     */
    public int authenticate( Request req , Response res ) {
  Context ctx=req.getContext();
  String login_type=ctx.getAuthMethod();
  if( "BASIC".equals( login_type )) {
      basicCredentials( req );
  }
  if( "FORM".equals( login_type )) {
      formCredentials( req );
View Full Code Here


     * servers. That makes this code very easy ( only need to deal with
     * the last component of the name ), but it's hard to integrate and you
     * have no way to use pathInfo.
     */
    Container matchExtension( Request req ) {
  Context ctx=req.getContext();
  String ctxP=ctx.getPath();
 
  // we haven't matched any prefix,
  String path = req.servletPath().toString();
  if( path == null ) return null;

  String extension=FileUtil.getExtension( path );
  if( extension == null ) return null;

  if(debug>0)
      cm.log("SM: Extension match " + ctxP +  " " +
       path + " " + extension );

  // Find extension maps for the context
  SimpleHashtable extM=(SimpleHashtable)ctx.
      getContainer().getNote( ctExtMapNote );
  if( extM==null ) return null;

  // Find the container associated with that extension
  if( ignoreCase ) extension=extension.toLowerCase();
View Full Code Here

  }
  req.servletPath().setString( s );

  if( ! "".equals(pathI))
      req.pathInfo().setString(pathI);
  Context ctx=container.getContext();
  req.setContext(ctx);
  req.setHandler( container.getHandler() );
  req.setContainer( container );
    }
View Full Code Here

    /** The session store hook
     */
    public ServerSession findSession( Request request,
              String sessionId, boolean create)
    {
  Context ctx=request.getContext();
  if( ctx==null ) return null;
 
  SimpleSessionManager sM = getManager( ctx );   
 
  ServerSession sess=sM.findSession( sessionId );
View Full Code Here

    /**
     */
    public void addContainer( Container ct )
  throws TomcatException
    {
  Context ctx=ct.getContext();
  Container ctxCt=ctx.getContainer();
  // XXX add the note only if we have a security constraint
  SecurityConstraints ctxSecurityC=(SecurityConstraints)ctxCt.
      getNote( secMapNote );
  if( ctxSecurityC==null) {
      ctxSecurityC= new SecurityConstraints();
      ctxCt.setNote( secMapNote, ctxSecurityC );
  }

  if( ct.getRoles()!=null || ct.getTransport()!=null ) {
      if( debug > 0 )
    log( "addContainer() " + ctx.getHost() + " " +
         ctx.getPath() + " " +
         ct.getPath() );
      ctxSecurityC.addContainer( ct );
  }
    }
View Full Code Here

    /** Check if this request requires auth, and if so check the roles.
     */
    public int requestMap( Request req )
    {
  Context ctx=req.getContext();
  SecurityConstraints ctxSec=(SecurityConstraints)ctx.getContainer().
      getNote( secMapNote );

  // do the check for the "special patterns"
  MessageBytes reqURIMB=req.requestURI();
  String ctxPath= ctx.getPath();
  int ctxPathLen=ctxPath.length();
 
  // quick test
  if( reqURIMB.startsWithIgnoreCase( "/META-INF", ctxPathLen) ||
                  reqURIMB.startsWithIgnoreCase( "/WEB-INF", ctxPathLen) ) {
View Full Code Here

    }

    public void doService(Request req, Response res)
  throws Exception
    {
  Context ctx=req.getContext();
  String realm=ctx.getRealmName();
  if(realm==null) realm="default";
  res.setStatus( 401 );
  res.setHeader( "WWW-Authenticate",
           "Basic realm=\"" + realm + "\"");
        // return some content to prevent error 500
View Full Code Here

    }

    public void doService(Request req, Response res)
  throws Exception
    {
  Context ctx=req.getContext();

  ServerSession session=req.getSession( false );
  // we didn't had a session
  boolean noSession= ( session==null );
  if( debug>0 ) log( "Form handler called with no session ");

  String page=ctx.getFormLoginPage();
  String errorPage=ctx.getFormErrorPage();
  // assert errorPage!=null ( AccessInterceptor will check
  // that and enable form login only if everything is ok

  session=(ServerSession)req.getSession( true );
  String username=(String)session.getAttribute( "j_username" );
View Full Code Here

  Parameters params=req.parameters();
 
  String username=params.getParameter( "j_username" );
  String password=params.getParameter( "j_password" );

  Context ctx=req.getContext();
  String errorPage=ctx.getFormErrorPage();
  // assert errorPage!=null ( AccessInterceptor will check
  // that and enable form login only if everything is ok
 
  if( debug > 0 )
      log( " user/pass= " + username + " " + password );
     
  ServerSession session=(ServerSession)req.getSession( false );
  if( session == null ) {
      ctx.log("From login without a session ");
      req.setAttribute("javax.servlet.error.message",
           errorPage );
      contextM.handleStatus( req, res, 302 ); // redirect
      return;
  }
View Full Code Here

        String user = (String)req.getNote(userNote);
        String password = (String)req.getNote(passwordNote);
        if (user == null) return DECLINED;
        if (checkPassword(user, password)) {
            if (debug > 0) log("Auth ok, user=" + user);
            Context ctx = req.getContext();
            if (ctx != null)
                req.setAuthType(ctx.getAuthMethod());
            if (user != null) {
                req.setRemoteUser(user);
                req.setUserPrincipal( getPrincipal( user ));
                String userRoles[] = getUserRoles(user);
                req.setUserRoles(userRoles);
View Full Code Here

TOP

Related Classes of org.apache.tomcat.core.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.