User documentation
[One minute description]
Two minute tutorial
[Five minute introduction]
|
|||||
|
|||||
User documentation[One minute description] |
Two minute tutorial
This very short tutorial should get you up to speed with Gabriel in 2 minutes. Configure permissionsaccess.acl mapping principals to permissions ExampleUser { CHANGE }
methods.acl mapping permissions to method access CHANGE { example.SecureObject.setName }
Create access componentsMethodAccessManager methodAccessManager = new DefaultMethodAccessManager();
Create aspects to wrap our object// The we setup our aop to wrap objects Aspects aspects = new Aspects(); aspects.interceptor(Pointcuts.instancesOf(SecureObject.class), Pointcuts.ALL_METHODS, new AccessInterceptor(methodAccessManager)); ProxyFactory proxyFactory = ProxyFactory.getInstance(aspects); Set our credentialsSystem.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); Try to access the object// 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()); |
||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||