/**
   * Test of authenticate method, of class
   * com.rift.coad.lib.interceptor.authenticator.UserPasswordAuthenticator.
   */
  public void testAuthenticate() throws Exception {
    System.out.println("authenticate");

    // init the session information
    ThreadsPermissionContainer permissions = new ThreadsPermissionContainer();
    SessionManager.init(permissions);
    UserStoreManager userStoreManager = new UserStoreManager();
    UserSessionManager sessionManager = new UserSessionManager(permissions, userStoreManager);
    LoginManager.init(sessionManager, userStoreManager);
    // instanciate the thread manager
    CoadunationThreadGroup threadGroup =
        new CoadunationThreadGroup(sessionManager, userStoreManager);

    // add a user to the session for the current thread
    RoleManager.getInstance();

    InterceptorFactory.init(permissions, sessionManager, userStoreManager);

    TestInterceptor testInterceptor = new TestInterceptor();

    Login login = new Login("test", "112233");

    testInterceptor.createSession(login);

    ThreadPermissionSession threadSession = permissions.getSession();

    if (!threadSession.getUser().getName().equals("test")) {
      fail("The user name is not test");
    }

    testInterceptor.release();
  }
示例#2
0
  /** Creates a new instance of Main */
  public Runner() throws CoadException {
    // Validate the class loader
    System.out.println("Check the class loader");
    if (!(this.getClass().getClassLoader() instanceof com.rift.coad.BaseClassLoader)) {
      log.error("Invalid class loader");
      System.exit(-1);
    }
    System.out.println("Try and init");
    try {
      Configuration config = ConfigurationFactory.getInstance().getConfig(Runner.class);

      // instanciate the user permissions
      log.info("Init the master class loader");
      MasterClassLoader.init();

      // instanciate the user permissions
      log.info("Init thread permissions");
      permissionContainer = new ThreadsPermissionContainer();
      ThreadsPermissionContainerAccessor.init(permissionContainer);
      log.info("Init session manager");
      SessionManager.init(permissionContainer);
      log.info("Init user store");
      userStoreManager = new UserStoreManager();
      UserStoreManagerAccessor.init(userStoreManager);
      log.info("Init user session manager");
      sessionManager = new UserSessionManager(permissionContainer, userStoreManager);
      sessionManager.startCleanup();
      UserSessionManagerAccessor.init(sessionManager);
      log.info("Init login module");
      LoginManager.init(sessionManager, userStoreManager);

      // add a user to the session for the current thread
      log.info("Init roles");
      RoleManager.getInstance().startBackgroundThread();

      // setup a default user for the current thread
      log.info("Init the default user for the runner");
      Long threadId = new Long(Thread.currentThread().getId());
      permissionContainer.putSession(
          threadId,
          new ThreadPermissionSession(
              threadId, userStoreManager.getUserInfo(config.getString(RUNNER_USER))));

      // instanciate the thread manager
      log.info("Init thread group");
      threadGroup = new CoadunationThreadGroup(sessionManager, userStoreManager);

      // init the interceptor factory
      log.info("Init the interceptor factory");
      InterceptorFactory.init(permissionContainer, sessionManager, userStoreManager);

      // setup the current thread class loader
      log.info("Init the naming director");
      NamingDirector.init(threadGroup);

      log.info("Init the transaction director");
      TransactionDirector.init();

      // instanciate the cache registry
      log.info("Init the cache registry");
      CacheRegistry.init(threadGroup);

      // instanciate the database sources
      log.info("Init data stources");
      DBSourceManager.init();

      // instanciate the bean manager
      log.info("Init coadunation beans");
      beanManager = new BeanManager(permissionContainer, threadGroup);
      BeanConnector.init(beanManager);

      // instanciate the jmx bean manager
      log.info("Init JMX Beans");
      jmxBeanManager = new JMXBeanManager(permissionContainer, threadGroup);
      JMXBeanConnector.init(jmxBeanManager);

      // instanciate the axis engine
      log.info("Init AXIS");
      AxisManager.init();

      // instanciate the web service manager
      log.info("Init Web Service management");
      webServiceManager = new WebServiceManager();
      WebServiceConnector.init(webServiceManager);

      // instanciate the thread manager
      log.info("Init Deployment Loader");
      deploymentManager =
          new DeploymentManager(threadGroup, beanManager, jmxBeanManager, webServiceManager);

      // instanciate the http daemon
      log.info("Init Web Service HTTPD");
      httpDaemon = new HttpDaemon(threadGroup);

    } catch (Exception ex) {
      System.out.println("Failed to start coadunation : " + ex.getMessage());
      ex.printStackTrace(System.out);
      log.error("Failed to start coadunation : " + ex.getMessage(), ex);
      throw new CoadException("Failed start the Coadunation base because : " + ex.getMessage(), ex);
    }
  }