I am facing a similar challenge. Only I would like to inject my custom spring beans into the SecurityRule implementation class
I have created a spring PluginLifecycle implementation as per spring docs<http://docs.spring.io/spring-data/neo4j/docs/2.0.0.RC1/api/org/springframework/data/neo4j/server/SpringPluginInitializer.html> public class SpringContextInitializer extends SpringPluginInitializer { public SpringContextInitializer() { super(new String[]{"config/my-spring-config1.xml","config/my-spring-config2.xml"}, Pair.of("customBeanName1",MyCustomClass.class), Pair.of("customBeanName2",MyCustomClass.class)); } } .. and also created a custom SecurityRule. How do I inject the above beans (customBeanName1 and customBeanName2) into the SecurityRule class? The spring documentation only mentions that the exposed beans can be accessed via the @Context annotation from the jax-rs resources, but doesn't say how you can access them elsewhere within the plugin. Thanks, Austin On Friday, January 6, 2012 10:12:01 AM UTC-8, Jim Webber wrote: > > Hi Brendan, > > Sorry for taking so long to solve this, it's not a bug. The database is > injected when the isAuthorized(…) method is called on a SecurityRule > implementation. > > The relevant method is in the interface > org.neo4j.server.rest.security.SecurityRule: > > boolean isAuthorized(javax.servlet.http.HttpServletRequest > httpServletRequest, org.neo4j.graphdb.GraphDatabaseService > graphDatabaseService); > > So instead of getting a reference to the database when your SecurityRule > class is instantiated, it should wait until isAuthoriszed() gets called. > > You can't use @Context to inject it - @Context is only permitted for > resource classes I believe. > > HTH, > > Jim > > On 10 Dec 2011, at 11:08, Peter Neubauer wrote: > > > From: "Brendan" <[email protected] <javascript:>> > > Date: Dec 10, 2011 11:33 AM > > Subject: How to get @Context from Security Authorization rule class? > > To: <[email protected] <javascript:>> > > > > Hi, > > > > I want to use @Context to bring the database service to my extended > > SecurityRule class. But I found it won't be loaded. > > Is this a bug? > > > > Here is my code: > > > > public class AccountSecurityRule implements SecurityRule { > > > > > > private static final Logger log = Logger > > > > .getLogger(AccountSecurityRule.class); > > > > > > private final GraphDatabaseService database; > > > > > > public AccountSecurityRule(@Context GraphDatabaseService database) { > > > > this.database = database; > > > > } > > and the server log file shows: > > > > Dec 9, 2011 12:47:39 PM org.neo4j.server.logging.Logger log > > INFO: Mounting static content at [/webadmin] from [webadmin-html] > > Dec 9, 2011 12:47:39 PM org.mortbay.log.Slf4jLog info > > INFO: jetty-6.1.25 > > Dec 9, 2011 12:47:39 PM org.mortbay.log.Slf4jLog info > > INFO: NO JSP Support for /webadmin, did not find > > org.apache.jasper.servlet.JspServlet > > Dec 9, 2011 12:47:40 PM com.sun.jersey.api.core.PackagesResourceConfig > init > > INFO: Scanning for root resource and provider classes in the packages: > > hk.itags.core.neo4j.graph.server.resources > > Dec 9, 2011 12:47:40 PM com.sun.jersey.api.core.ScanningResourceConfig > > logClasses > > INFO: Root resource classes found: > > class hk.itags.core.neo4j.graph.server.resources.Setup > > class hk.itags.core.neo4j.graph.server.resources.Register > > class hk.itags.core.neo4j.graph.server.resources.Person > > Dec 9, 2011 12:47:40 PM com.sun.jersey.api.core.ScanningResourceConfig > init > > INFO: No provider classes found. > > Dec 9, 2011 12:47:40 PM > > com.sun.jersey.server.impl.application.WebApplicationImpl _initiate > > INFO: Initiating Jersey application, version 'Jersey: 1.10 11/02/2011 > 04:41 > > PM' > > ding statistic-filter to / > > Dec 9, 2011 12:47:42 PM org.neo4j.server.logging.Logger log > > INFO: Server started on [http://0.0.0.0:7474/] > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
