FileDocCategorySizeDatePackage
SecurityLifecycle.javaAPI DocGlassfish v2 API6596Fri May 04 22:35:24 BST 2007com.sun.enterprise.security

SecurityLifecycle

public class SecurityLifecycle extends com.sun.appserv.server.ServerLifecycleImpl
This class extends default implementation of ServerLifecycle interface. It provides security initialization and setup for the server.
author
Shing Wai Chan

Fields Summary
private static final Logger
_logger
Constructors Summary
public SecurityLifecycle()


      
	try {
            // security manager is set here so that it can be accessed from
            // other lifecycles, like PEWebContainer

            SecurityManager secMgr = System.getSecurityManager();
            if (secMgr != null &&
                    !(J2EESecurityManager.class.equals(secMgr.getClass()))) {
                J2EESecurityManager mgr = new J2EESecurityManager();
                System.setSecurityManager(mgr);
            }
            
            if (_logger.isLoggable(Level.INFO)) {
                if (secMgr != null) {
                    _logger.info("security.secmgron");
                } else {
                    _logger.info("security.secmgroff");
                }
            }
	} catch(Exception ex) {
            _logger.log(Level.SEVERE, "java_security.init_securitylifecycle_fail", ex);
            throw new RuntimeException(ex.toString(), ex);
	}
    
Methods Summary
private voidinitializeJMAC()


	// define default factory if it is not already defined
	// factory will be constructed on first getFactory call.

	String defaultFactory = Security.getProperty
	    (AuthConfigFactory.DEFAULT_FACTORY_SECURITY_PROPERTY);
	if (defaultFactory == null) {
	    Security.setProperty
		(AuthConfigFactory.DEFAULT_FACTORY_SECURITY_PROPERTY,
		 GFAuthConfigFactory.class.getName());
 	}
    
public voidonInitialization(com.sun.enterprise.server.ServerContext sc)


        try {
            // init SSL store
            // need this for jaxr https for PE
            // need this for webcore, etc for SE
            SSLUtils.initStoresAtStartup();

            //jmac
            initializeJMAC();

            // jacc
            registerPolicyHandlers();
            PolicyLoader policyLoader = PolicyLoader.getInstance();
            policyLoader.loadPolicy();

            // create realms rather than creating RemoteObject RealmManager
            // which will init ORB prematurely
            RealmConfig.createRealms();

            // start the audit mechanism
            AuditManagerFactory amf = AuditManagerFactory.getInstance();
            amf.getAuditManagerInstance().loadAuditModules();

            // initRoleMapperFactory is in J2EEServer.java and not moved to here
            // this is because a DummyRoleMapperFactory is register due
            // to invocation of ConnectorRuntime.createActiveResourceAdapter
            // initRoleMapperFactory is called after it
        } catch(Exception ex) {
            throw new ServerLifecycleException(ex);
        }
    
private voidregisterPolicyHandlers()

        PolicyContextHandler pch = PolicyContextHandlerImpl.getInstance();
        PolicyContext.registerHandler(PolicyContextHandlerImpl.ENTERPRISE_BEAN,
            pch, true);
        PolicyContext.registerHandler(PolicyContextHandlerImpl.SUBJECT, pch, true);
        PolicyContext.registerHandler(PolicyContextHandlerImpl.EJB_ARGUMENTS,
            pch, true);
        PolicyContext.registerHandler(PolicyContextHandlerImpl.SOAP_MESSAGE,
            pch, true);
        PolicyContext.registerHandler(PolicyContextHandlerImpl.HTTP_SERVLET_REQUEST,
            pch, true);
        PolicyContext.registerHandler(PolicyContextHandlerImpl.REUSE, pch, true);