You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by taidan19 <ta...@gmail.com> on 2014/12/06 05:24:11 UTC

Re: Creating securitymanager from ini, cannot read file in classpath?

(Note that I'm not a Shiro developer, but here's my stab at answering the
question as a fellow Java developer)

Technically, you could put the shiro.ini file anywhere you want in your
project. But /where/ you put it will affect how you reference it in your
code.

If your JavaFX application is a Maven based project, I would place the
config file in src/main/resources. By putting it there, Maven would place
the file at the root of the JAR/WAR it generates, which would then allow you
to write the code as you originally have it:

Factory<SecurityManager> factory = new
IniSecurityManagerFactory("classpath:shiro.ini"); 

If it isn't a Maven application, then you could still place it at the root
of your project's source tree. Or you could create a conf/ folder or
somthing, and place it in there. Then the line above might look like this:

Factory<SecurityManager> factory = new
IniSecurityManagerFactory("classpath:conf/shiro.ini");





--
View this message in context: http://shiro-user.582556.n2.nabble.com/Creating-securitymanager-from-ini-cannot-read-file-in-classpath-tp7580331p7580353.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Creating securitymanager from ini, cannot read file in classpath?

Posted by KonradZuse <Th...@hotmail.com>.
>From what the FX forum said (which wasn't much) was that it should be the
same so I'm not sure what I could be doing wrong?  Does it have to sit at
the top of the classpath, or can we put it inside a directory and call that
specially?

Normally I thought for items in the classpath we just do ("image.png") or
something along those lines?  Is the ini different or am I missing something
here?

Thank you all!



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Creating-securitymanager-from-ini-cannot-read-file-in-classpath-tp7580331p7580388.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Creating securitymanager from ini, cannot read file in classpath?

Posted by KonradZuse <Th...@hotmail.com>.
Yeah I tried putting it in all sorts of places, including the root(Netbeans
calls this the "default package."  I'm not sure about the classloader, I
will post this on Oracle's FX section and see if someone has a comment
towards the classloader.

Thanks for the help Les!


Btw I had issues sending replies back to 2 email topics, this being one of
them, so sorry if people get 2 emails/ a double post on the forum(as of this
moment there is no other post).


It also just asked me if I was a subscriber when I tried to reply (not sure
if that's normal protocol).

Thanks all



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Creating-securitymanager-from-ini-cannot-read-file-in-classpath-tp7580331p7580362.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Creating securitymanager from ini, cannot read file in classpath?

Posted by Les Hazlewood <lh...@apache.org>.
classpath:shiro.ini indicates a shiro.ini file at the root of the classpath
- i.e. at the top of a .jar file and not in a directory.  If this doesn't
work, perhaps it's a JavaFX classloader issue?  Is there anything special
about JavaFX classloading? I'm not sure - I haven't tried this in JavaFX
myself.

--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282

On Sat, Dec 6, 2014 at 12:27 AM, Konrad Zuse <th...@hotmail.com>
wrote:

> Thanks for the help.
>
> I tried placing it in the default (which I'm assuming is the root?) and
> nothing, I will try this conf/ business.  I have it in another package, so
> I will try to see if the / will work.  I tried to do
> classpath:conf.shiro.ini as that's what we normally do when referencing a
> package/class.
>
> You mention folders though, so I don't know if I should be working in the
> file view and not the project view, but I believe it doesn't matter...
> right?
>
>
> Thanks again for the help, will try this out tomorrow when I'm more awake
> , and will email back the results :).
>
> > Date: Fri, 5 Dec 2014 21:24:11 -0700
> > From: taidan19@gmail.com
> > To: user@shiro.apache.org
> > Subject: Re: Creating securitymanager from ini, cannot read file in
> classpath?
>
> >
> > (Note that I'm not a Shiro developer, but here's my stab at answering the
> > question as a fellow Java developer)
> >
> > Technically, you could put the shiro.ini file anywhere you want in your
> > project. But /where/ you put it will affect how you reference it in your
> > code.
> >
> > If your JavaFX application is a Maven based project, I would place the
> > config file in src/main/resources. By putting it there, Maven would place
> > the file at the root of the JAR/WAR it generates, which would then allow
> you
> > to write the code as you originally have it:
> >
> > Factory<SecurityManager> factory = new
> > IniSecurityManagerFactory("classpath:shiro.ini");
> >
> > If it isn't a Maven application, then you could still place it at the
> root
> > of your project's source tree. Or you could create a conf/ folder or
> > somthing, and place it in there. Then the line above might look like
> this:
> >
> > Factory<SecurityManager> factory = new
> > IniSecurityManagerFactory("classpath:conf/shiro.ini");
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://shiro-user.582556.n2.nabble.com/Creating-securitymanager-from-ini-cannot-read-file-in-classpath-tp7580331p7580353.html
> > Sent from the Shiro User mailing list archive at Nabble.com.
>

RE: Creating securitymanager from ini, cannot read file in classpath?

Posted by Konrad Zuse <th...@hotmail.com>.
Thanks for the help.

I tried placing it in the default (which I'm assuming is the root?) and nothing, I will try this conf/ business.  I have it in another package, so I will try to see if the / will work.  I tried to do classpath:conf.shiro.ini as that's what we normally do when referencing a package/class.

You mention folders though, so I don't know if I should be working in the file view and not the project view, but I believe it doesn't matter... right?


Thanks again for the help, will try this out tomorrow when I'm more awake , and will email back the results :).
> Date: Fri, 5 Dec 2014 21:24:11 -0700
> From: taidan19@gmail.com
> To: user@shiro.apache.org
> Subject: Re: Creating securitymanager from ini, cannot read file in classpath?
> 
> (Note that I'm not a Shiro developer, but here's my stab at answering the
> question as a fellow Java developer)
> 
> Technically, you could put the shiro.ini file anywhere you want in your
> project. But /where/ you put it will affect how you reference it in your
> code.
> 
> If your JavaFX application is a Maven based project, I would place the
> config file in src/main/resources. By putting it there, Maven would place
> the file at the root of the JAR/WAR it generates, which would then allow you
> to write the code as you originally have it:
> 
> Factory<SecurityManager> factory = new
> IniSecurityManagerFactory("classpath:shiro.ini"); 
> 
> If it isn't a Maven application, then you could still place it at the root
> of your project's source tree. Or you could create a conf/ folder or
> somthing, and place it in there. Then the line above might look like this:
> 
> Factory<SecurityManager> factory = new
> IniSecurityManagerFactory("classpath:conf/shiro.ini");
> 
> 
> 
> 
> 
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Creating-securitymanager-from-ini-cannot-read-file-in-classpath-tp7580331p7580353.html
> Sent from the Shiro User mailing list archive at Nabble.com.