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.");