View Full Version : Problem with attributes sample (Bank)
mazir
Sep 23rd, 2004, 10:11 AM
Hello,
I set up the bank sample in eclipse, and got it to run ok, both as a Junit test and as a java app, using the Main class supplied. Both give me access denied although in both cases I'm using the code as is.
This is the exception I get:
net.sf.acegisecurity.AccessDeniedException: Access is denied.
at net.sf.acegisecurity.vote.UnanimousBased.decide(Un animousBased.java:120)
at net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor.interceptor(AbstractSecurityInterceptor.j ava:302)
at net.sf.acegisecurity.intercept.method.MethodSecuri tyInterceptor.invoke(MethodSecurityInterceptor.jav a:82)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy0.listAccounts(Unknown Source)
at sample.attributes.Main.main(Main.java:46)
Any ideas what the problem is?
Thanks.
Ben Alex
Sep 23rd, 2004, 06:27 PM
I'd suggest it's a configuration issue between your Spring application context and/or the absence of the Commons Attributes generated subclasses. Does it work if you just use a console prompt and the ACEGI_SECURITY/samples/attributes/build.xml "all" target? If it does, try comparing that build file and application context against your configuration.
mazir
Sep 25th, 2004, 09:51 AM
Thank you for the information.
moritz
Feb 10th, 2005, 04:37 PM
I seem to have the reverse problem. The DeniedAccess test does not throw an exception when running JUnit from within Eclipse and fails. It works well when run with Maven. Could you please elaborate which configuration issues I should be looking for or point me somehow in the right direction? It must be something with the Commons Attribute. I'm having trouble getting the Ant built running correctly as well. It shows the same behavior as Eclipse.
Thanks,
Andreas
Ben Alex
Feb 11th, 2005, 12:29 AM
I haven't setup the Acegi Security Eclipse project file to support execution of the BankTests unit test within the IDE, as it relies on generation of the /samples/attributes/target/commons-attributes/ directory, which contains the BankService$__attributeRepository.java file. If you (i) add that directory as a source folder to the Eclipse project and (ii) add MAVEN_REPO/commons-attributes/jars/commons-attributes-api-2.1.jar, it will work fine (I just ran it against CVS head with the steps described):
2005-02-11 06:28:25,975 DEBUG net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor - Secure object: Invocation: method 'balance', arguments [1]; target is of class [sample.attributes.BankServiceImpl]; ConfigAttributes: [ROLE_TELLER, ROLE_PERMISSION_BALANCE]
2005-02-11 06:28:25,975 DEBUG net.sf.acegisecurity.providers.ProviderManager - Authentication attempt using net.sf.acegisecurity.providers.TestingAuthenticati onProvider
2005-02-11 06:28:25,975 DEBUG net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor - Authenticated: net.sf.acegisecurity.providers.TestingAuthenticati onToken@12d7a10: Username: test; Password: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_TELLER, ROLE_PERMISSION_LIST
2005-02-11 06:28:25,991 DEBUG net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor - Secure object: Invocation: method 'listAccounts', arguments []; target is of class [sample.attributes.BankServiceImpl]; ConfigAttributes: [ROLE_TELLER, ROLE_PERMISSION_LIST]
2005-02-11 06:28:26,007 DEBUG net.sf.acegisecurity.providers.ProviderManager - Authentication attempt using net.sf.acegisecurity.providers.TestingAuthenticati onProvider
2005-02-11 06:28:26,007 DEBUG net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor - Authenticated: net.sf.acegisecurity.providers.TestingAuthenticati onToken@6d084b: Username: test; Password: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_TELLER, ROLE_PERMISSION_LIST
2005-02-11 06:28:26,007 DEBUG net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor - Authorization successful
2005-02-11 06:28:26,007 DEBUG net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor - RunAsManager did not change Authentication object
moritz
Feb 11th, 2005, 12:34 PM
Cool. Works like a charm now. Thanks.
Andreas
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.