Package gabriel

Examples of gabriel.Subject


        Pointcuts.ALL_METHODS, new AccessInterceptor(methodAccessManager));

    ProxyFactory proxyFactory = ProxyFactory.getInstance(aspects);

    System.out.println("Setting our subject to \"We\" with empty principals.");
    Subject subject = new Subject("We");
    Set principals = new HashSet();
    subject.setPrincipals(principals);
    Subject.set(subject);

    // We create an object which has protected methods
    SecureObject object = (SecureObject) proxyFactory.wrap(new SecureObjectImpl("Dont change me!"));
    System.out.print("We try to call setName() on \""+object.getName()+"\" ... ");
    try {
      object.setName("Changed!");
    } catch (Exception e) {
      System.out.println("denied.");
    }
    System.out.println("object.name = " + object.getName());

    System.out.println("Adding \"ExampleUser\" to our principals.");
    // We are now member of group "ExampleUser
    principals.add(new Principal("ExampleUser"));
    // We have to set the principals again as they are copied not referenced
    // inside subject.
    subject.setPrincipals(principals);
    System.out.print("We try to call setName() on \""+object.getName()+"\" ... ");
    object.setName("changed!");
    System.out.println("changed.");
    System.out.println("object.name = " + object.getName());
  }
View Full Code Here


  public static Test suite() {
    return new TestSuite(SubjectTest.class);
  }

  public void testSetPrincipalsUsesNewSet() {
    Subject subject = new Subject("TestSubject");
    Set principals = new HashSet();
    subject.setPrincipals(principals);
    assertNotSame("Subject uses new set for principals", principals, subject.getPrincipals());
  }
View Full Code Here

    subject.setPrincipals(principals);
    assertNotSame("Subject uses new set for principals", principals, subject.getPrincipals());
  }

  public void testTheadLocal() {
    Subject subject = new Subject("TestSubject");

    // A better test should use a new thread and make sure
    // that each thread sees a differnt subject

    Subject.set(subject);
    Subject other = Subject.get();
    assertSame("Subject static returns same subject", subject, other);
  }
View Full Code Here

    super.setUp();
    this.contextCallAccessManager = mock(ContextMethodAccessManager.class);
    this.callAccessManager = mock(MethodAccessManager.class);

    principals = new HashSet();
    Subject subject = Subject.get();
    subject.setPrincipals(principals);

    aspects = new Aspects();
  }
View Full Code Here

TOP

Related Classes of gabriel.Subject

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.