Package org.springframework.richclient.security

Examples of org.springframework.richclient.security.SecurityController


      if (logger.isDebugEnabled()) {
        logger.debug("Lookup SecurityController with id [" + controllerId + "]");
      }

      SecurityController controller = getSecurityControllerManager().getSecurityController(controllerId);

      // And add the object to the controlled object set
      if (controller != null) {
        if (logger.isDebugEnabled()) {
          logger.debug("configuring SecurityControllable [" + objectName + "]; security controller id='"
              + controllerId + "'");
        }
        controller.addControlledObject(controllable);
      }
      else {
        if (logger.isDebugEnabled()) {
          logger.debug("configuring SecurityControllable [" + objectName
              + "]; no security controller for id='" + controllerId + "'");
View Full Code Here


     * given id if it implements the SecurityController interface.
     * @param id of controller to retrieve
     * @return controller, null if not found
     */
    public SecurityController getSecurityController(String id) {
        SecurityController sc = (SecurityController) securityControllerMap.get( id );
        if( sc == null ) {
            // Try for a named bean
            try {
                sc = (SecurityController) Application.instance().getApplicationContext().getBean( id,
                    SecurityController.class );
View Full Code Here

    // create the required mock objects
    SecurityControllerManager controllerManager = (SecurityControllerManager) EasyMock
        .createMock(SecurityControllerManager.class);
    SecurityControllable controllable = (SecurityControllable) EasyMock.createMock(SecurityControllable.class);
    SecurityController controller = (SecurityController) EasyMock.createMock(SecurityController.class);

    // Create the configurer with the mock security controller manager
    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(null, null, null,
        controllerManager);

    // Set the expectations for this run. The security controller manager
    // has not been provided
    // with the controller for the given controller id yet so we don't
    // expect the controllable
    // to be added to the controllerManager as a controlled object
    EasyMock.expect(controllable.getSecurityControllerId()).andReturn(securityControllerId);
    EasyMock.expect(controllerManager.getSecurityController(securityControllerId)).andReturn(null);

    // switch to replay mode...
    EasyMock.replay(controllable);
    EasyMock.replay(controllerManager);
    EasyMock.replay(controller);

    // run the test...
    configurer.configure(controllable, objectName);

    // and verify the results...
    EasyMock.verify(controllable);
    EasyMock.verify(controllerManager);
    EasyMock.verify(controller);

    // reset the mocks for the next part of the test
    EasyMock.reset(controllable);
    EasyMock.reset(controllerManager);
    EasyMock.reset(controller);

    // Set the expectations for the next test. This time we want the
    // controller manager to find
    // the controller for the given id and we expect the controllable to be
    // added to the
    // controller manager as a controlled object
    EasyMock.expect(controllable.getSecurityControllerId()).andReturn(securityControllerId);
    EasyMock.expect(controllerManager.getSecurityController(securityControllerId)).andReturn(controller);
    controller.addControlledObject(controllable);

    // switch to replay mode...
    EasyMock.replay(controllable);
    EasyMock.replay(controllerManager);
    EasyMock.replay(controller);
View Full Code Here

    /**
     * Test alias registration
     */
    public void testRegisterSecurityControllerAlias() {
        SecurityController controller = new UserRoleSecurityController();
        manager.registerSecurityControllerAlias( "newAlias", controller );

        assertEquals( "Should be same controller", controller, manager.getSecurityController( "newAlias" ) );
    }
View Full Code Here

    /**
     * Test obtaining controllers
     */
    public void testGetSecurityController() {
        SecurityController write = (SecurityController) applicationContext.getBean( "writeController",
            SecurityController.class );
        SecurityController admin = (SecurityController) applicationContext.getBean( "adminController",
            SecurityController.class );

        // test defaulting to bean id if no alias registered
        assertEquals( "Should be same controller", write, manager.getSecurityController( "writeController" ) );
        assertEquals( "Should be same controller", admin, manager.getSecurityController( "adminController" ) );
View Full Code Here

TOP

Related Classes of org.springframework.richclient.security.SecurityController

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.