Package com.tll.server

Source Code of com.tll.server.SecurityContextBootstrapper

/**
* The Logic Lab
* @author jpk
* Feb 4, 2009
*/
package com.tll.server;

import javax.servlet.ServletContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.AccessDecisionManager;
import org.springframework.security.AuthenticationManager;

import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;
import com.tll.di.AcegiModule;

/**
* SecurityContextBootstrapper - Sets the {@link SecurityContext} in the
* {@link ServletContext}.
* @author jpk
*/
public class SecurityContextBootstrapper implements IBootstrapHandler {

  private static final Log log = LogFactory.getLog(SecurityContextBootstrapper.class);

  @Override
  public void startup(Injector injector, ServletContext servletContext) {
    final AuthenticationManager authenticationManager = injector.getInstance(AuthenticationManager.class);
    final AccessDecisionManager httpRequesetAccessDecisionManager =
      injector.getInstance(Key.get(AccessDecisionManager.class, Names.named(AcegiModule.ADM_HTTP_REQUEST)));

    log.debug("Setting security context..");
    servletContext.setAttribute(SecurityContext.KEY, new SecurityContext(authenticationManager,
        httpRequesetAccessDecisionManager));
  }

  @Override
  public void shutdown(ServletContext servletContext) {
    // no-op
  }
}
TOP

Related Classes of com.tll.server.SecurityContextBootstrapper

TOP
Copyright © 2018 www.massapi.com. 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.