sentence
stringlengths
1
1.38k
label
stringclasses
3 values
Quick and easy: CODESNIPPET_JAVA1 .
p
I get java.io.StreamCorruptedException: invalid stream header.
n
ObjectInputStream is about deserialization, and the stream have to respect the serialization protocol to work, which may not always true in the context of this question.
o
Shiro vs. SpringSecurity.
o
I have currently evaluating Java based security frameworks, I am a Spring 3.0 user so it seemed that SpringSecurity would be the right Choice, but Spring security seems to suffer from excessive complexity, it certainly does not seem like it is making security easier to implement, Shiro seems to be much more coherent and easier to understand.
n
I am looking for lists of pros and cons between these two frameworks.
o
I too agree that Spring Security feels too complicated (to me).
o
Sure, they have done things to reduce complexity, like creating custom XML namespaces to reduce the quantity of XML configuration, but for me, these don't address _my_ personal fundamental issue with Spring Security: its names and concepts are often confusing in general to me.
n
It's hard to just 'get it'.
n
The second you start using Shiro though, you just 'get it'.
o
What was hard to understand in the security world is just that much easier to understand.
o
Things that are unbearably difficult to use in the JDK (e.g.
n
Ciphers) are simplified to a level that is not just bearable, but often a joy to use.
n
For example, how do you hash+salt a password and base64 encode it in Java or Spring Security?
o
Neither are as simple and intuitive as Shiro's solution: CODESNIPPET_JAVA1 .
p
No need for commons-codec or anything else.
o
Just the Shiro jar.
o
Now with regards to Spring environments, most of the Shiro developers use Spring as their primary application environment.
o
That means Shiro's Spring integration is superb and it all works exceptionally well.
p
You can rest assured that if you're writing a Spring app, you'll have a well-rounded security experience.
p
For example, consider the Spring XML config example in another post in this thread.
o
Here's how you'd do (essentially) the same thing in Shiro: CODESNIPPET_JAVA2 .
o
Although slightly more verbose than the other Spring example, it is easier to read IMO.
n
You'll also find using Shiro's filter chain definitions are probably the easiest way to define general filter chains and web-based security rules ever!
p
Much nicer than defining them in web.xml.
p
Finally, Shiro offers extreme 'pluggability' as well.
p
You'll see that you can configure and/or replace just about anything because of Shiro's POJO /injection-friendly architecture.
o
Shiro defaults almost everything to sane defaults and you can override or configure only what you need.
p
At the end of the day, I think choosing either of these two is more about your mental model - which of the two make more sense and is more intuitive for you?
o
For some it will be Shiro, for others it will be Spring Security.
o
Shiro works great in Spring environments, so I would say choose based on which of the two you enjoy more and makes the most sense to you.
p
For more on Shiro's Spring integration: URL_http://shiro.apache.org/spring.html [ URL_http://shiro.apache.org/spring.html ] .
o
I've read all this before start using shiro.
o
Shiro annotations seem to suffer some issues in spring.Information on how to solve it are very har and there are various posts in stackoverflow (1 or 2 posted by myself) which most of the time found no answers.
o
I was seriously thinking i should go spring security despite it said complication, with that i'm sure i can have people to point me to the right direction.
o
I don't have experience using Shiro, and I "partly" agree with what you said about Spring Security.
o
Prior to Spring Security 3.x, Spring Security (or Acegi) was very painful to set up.
o
A simple role-based configuration will take at least 140 lines of cryptic XML configuration...
n
I know this because I actually counted the lines myself.
o
It was something where you set up one time, and you pray that it will work forever without you touching the configuration again, because you can assure you have forgotten what all the configuration means.
p
:) With Spring Security 3.x, it has tremendously improved upon.
p
It introduces CODETERM1 namespace that drastically shorten the configuration from 140 lines to ~30 lines.
n
Here's an example of Spring Security 3.x of one of my projects:- CODESNIPPET_JAVA1 .
o
The beauty of Spring Security 3.x is it is extremely configurable, which contributes to one of the main cons: too complicated to understand.
p
The documentation isn't easy to read either because I'm only partially familiar with the some of the terms Spring Security used.
n
However, the options are there if you need to create your custom configuration or control how granular you want your security to be.
o
Or else, you can stick with the above < 30 lines to perform a role-based security check.
o
What I really like about Spring Security is once it is set up the security is integrated into the project seamlessly.
o
It is as if the actual project code doesn't know the existence of the security... and that is good, because it allows me to easily detach or upgrade the security component in the future (ex: change database auth to LDAP/CAS auth).
p
Would you like to say something about when it is good to move from container based security to alternatives like shiro or others?
o
See more focussed question here: URL_http://stackoverflow.com/questions/7782720/when-to-move-from - container-managed-security-to-alternatives-like-apache-shiro.
o
I have tried both shiro and spring security, and I personally feel the shiro is quite easy to understand where as spring security feels complex.
n
I have yet to figureout how to setup permissions, that I can assign to roles/groups/users in spring security- (I think ACL may be the solution).
o
With shiro it was quite easy.I am not expert of spring security or shiro, its just my personal experience as user of both.
o
I had been using Spring Security (version 3.1) for a few months and was quite happy with it.
p
It is really powerful and has some very nice feature, especially after implementing everything by hand as I did before !
p
It was though, like I read somewhere, sort of something that you set up once near the beginning of the develoepment of the app, and then pray for it to keep working till the end, because if you have to go fix it you'll probably have forgotten most of the stuff you had to parameter.
p
But then a new project came along, with more complex security requirements.
n
In short, we had to implement some sort of custom SSO between a couple of related webapps.
o
I knew exactly what I wanted to achieve in terms of HTTP logic, cookies, session id's and stuff, and what should happen in what order, but I spent the better part of a day struggling with the Spring Security APIs, and still could not figure out exactly what class or interface I shoud implement or override, and how to plug them in the context.
n
The whole API felt really complex and a bit esoteric at times.
n
And while the doc is quite good for the general use cases and even some customization, it did not go deep enough to cover my needs.
p
After reading the answers here and on some other places on the web, I got the impression that Shiro would be easier to understand and customize to my needs.
p
So I gave it a try.
o
And I am glad I did, because after a day working on it I managed to learn enough about the APIs not only to set up a basic authentication and authorization system in my Spring webapp without trouble, but also to implement the custom SSO behaviour I was looking for.
p
I only had to extend 2 or 3 classes, and the whole thing took only about 25 lines of XML config in my spring context.
o
So as a conclusion, on the ease of use and learning curve aspects, Shiro is really quite likeable, and I think I will probably go with it in the future, unless I encounter some features lacking or some other problem (which I haven't so far).
n
TL;DR: Both are powerful, but Shiro is much easier to learn.
p
JAAS for human beings.
o
I am having a hard time understanding JAAS.
n
It all seems more complicated than it should be (especially the Sun tutorials).
o
I need a simple tutorial or example on how to implement security (authentication + authorization) in java application based on Struts + Spring + Hibernate with custom user repository.
n
Can be implemented using ACEGI.
o
Awesome question.
p
Great pithy title for a legitimate documentation failure.
p
Other users have provide some very useful links above so I am not going to bother with links.
n
I have done a similar research in JAAS for web application and has ran into a "mind roadblock" until I finally realize JAAS is a framework tackling security at a different "layer" then web applications in the Java World.
o
It is build to tackle security issues in Java SE not Java EE.
o
JAAS is a security framework build for securing things at a much lower level then web-application.
n
Some example of these things are code and resources available at the JVM level, hence all these ability to set policy files in the JVM level.
o
However, since Java EE is build on top of Java SE, a few modules from JAAS was reuses in Java EE security such as the LoginModules and Callbacks.
o
On the other hand, Acegi, or now aka Spring security, tackles a much higher "layer" in the securing web-application problem.
o
It is build on top of Java EE security hence Java SE hence JAAS.
o
Unless you are looking to secure resources in the Java SE level (classes, System resources), I don't see any real use of JAAS other than the using the common class and interfaces.
p
Just focus on using Acegi or plain old Java EE security which solves a lot of common web application security problems.
o
Java EE 6 Tutorial assumes understanding basic security concepts, so a little overview of JAAS won't hurt.
n
Here are some of the links I used to help understand JAAS: URL_http://www.owasp.org/index.php/JAAS_Tomcat_Login_Module [ URL_http://www.owasp.org/index.php/JAAS_Tomcat_Login_Module ] URL_http://www.javaworld.com/jw-09-2002/jw-0913-jaas.html [ URL_http://www.javaworld.com/jw-09-2002/jw-0913-jaas.html ] URL_http://www.jaasbook.com/ [ URL_http://www.jaasbook.com/ ] URL_http://roneiv.wordpress.com/2008/02/18/jaas-authentication-mechanism-is- it-possible-to-force-j_security_check-to-go-to-a-specific-page/ [ URL_http://roneiv.wordpress.com/2008/02/18/jaas-authentication-mechanism-is-it - possible-to-force-j_security_check-to-go-to-a-specific-page/] Also have a look at the Apache tomcat realms configuration how-to: URL_http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html [ URL_http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html ] .
o
thanks :) jaas book is really good.
p
javax.security is imho overcomplicated API.
o
As a result there are implementors of not only LoginModules, but the entire authentication and authorization api, that creates abstraction layer above, like Authentication & Authorization managers.
o
For starters, it is good to print URL_http://media.techtarget.com/tss/static/articles/content/Pramati- JAAS/interaction.gif [this] into your memory.
n
Secondly, imho the most simple, setup & go library for JAAS is Jboss URL_http://www.jboss.org/picketbox [PicketBox] .
p
It says how to do authentication and authorization via JBossAuthenticationManager and JBossAuthorizationManager ...
o
Easily configurable via XML or Annotations.
p
You can use it for managing both webapps and standalone applications.
p
If you need the authorization part for managing repository access, in terms of ACL for resources, this is what you are looking for sure.
o
Problem with the security is, that usually you need to customize it to your needs, so you may end up implementing : \- verifies userName + Password is used like this CODETERM1 CallbackHandler is passed to the underlying LoginModules so they may communicate and interact with users - prompting for a username and password via a graphical user interface, for example.
o
So inside of the Handler you get the username and password from user and it is passed to the LoginModule.
o
\- then you just call lc.login(); and authenticate the credentials.
o
LoginContext is populated with the authenticated Subject.
p