Package example

Examples of example.SecureObject


    DynaopComponentAdapterFactory factory = new DynaopComponentAdapterFactory(new DefaultComponentAdapterFactory(), aspects);
    MutablePicoContainer container = new DefaultPicoContainer(factory);
    container.registerComponentImplementation(SecureObject.class, SecureObjectImpl.class);

    SecureObject object = (SecureObject) container.getComponentInstance(SecureObject.class);

    try {
      object.setName("NewTestName");
      fail("Access should be denied to method setName() for NotAllowedPrincipal");
    } catch (SecurityException e) {
      // System.out.println(e.getMessage());
    }
  }
View Full Code Here


        with(eq(principals),
            eq("example.SecureObject.setName"),
            ANYTHING).
        will(returnValue(false));

    SecureObject object = new SecureObjectImpl("TestName");
    SecureObject wrapped = (SecureObject) proxyFactory.wrap(object);

    try {
      wrapped.setName("NewTestName");
      fail("Access should be denied to method setName() for NotAllowedPrincipal");
    } catch (SecurityException e) {
      // System.out.println(e.getMessage());
    }
    assertEquals("Name not set by wrong principal.", "TestName", object.getName());
View Full Code Here

    aspects.interceptor(Pointcuts.instancesOf(SecureObject.class),
        Pointcuts.ALL_METHODS, new AccessInterceptor((MethodAccessManager) callAccessManager.proxy()));

    proxyFactory = ProxyFactory.getInstance(aspects);

    SecureObject object = new SecureObjectImpl("TestName");
    SecureObject wrapped = (SecureObject) proxyFactory.wrap(object);
    try {
      wrapped.setName("NewTestName");
      fail("Access should be denied to method setName() for NotAllowedPrincipal");
    } catch (SecurityException e) {
      // System.out.println(e.getMessage());
    }
    assertEquals("Name not set by wrong principal.", "TestName", object.getName());
View Full Code Here

TOP

Related Classes of example.SecureObject

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.