Hello
I'm a beginner with shiro and I I've tried to follow the documentation
related to guice + shiro but I've the following error
java.lang.NoClassDefFoundError: com/google/inject/multibindings/Multibinder
at org.apache.shiro.guice.ShiroModule.bindRealm
I'm using
guice 3
shiro 1.2 snapshot
jersey 1.8
in tomcat 7
I'm trying to expose MyDataResource with Jersey REST framework. It has
stopped working since I'v tried to add shiro.
I'm certainly missing something but I don't know what.
here is my code :
****************************************
public class MyGuiceServletContextListener extends
GuiceServletContextListener {
private ServletContext servletContext;
@Override
protected Injector getInjector() {
Injector injector = Guice.createInjector(new
MyShiroWebModule(servletContext), new ShiroAopModule(), new
JerseyServletModule() {
@Override
protected void configureServlets() {
bind(MyDataResource.class);
serve("/*").with(GuiceContainer.class);
}
});
return injector;
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent)
{
servletContext = servletContextEvent.getServletContext();
super.contextInitialized(servletContextEvent);
}
}
*****************************
class MyShiroWebModule extends ShiroWebModule {
MyShiroWebModule(ServletContext servletContext) {
super(servletContext);
}
protected void configureShiroWeb() {
bindRealm().to(MyShiroRealm.class).in(Singleton.class);
addFilterChain("/**", ANON);
addFilterChain("/data/add/**", AUTHC_BASIC, config(PERMS, "yes"));
}
}
****************************************
public class MyShiroRealm extends AuthorizingRealm {
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken
token) throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken)
token;
String username = upToken.getUsername();
if (username == null) {
throw new AccountException("Null usernames are
not allowed by this
realm.");
}
String password = "password";
return new SimpleAuthenticationInfo(username, password,
this.getName());
}
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection
principals) {
if (principals == null) {
throw new AuthorizationException("PrincipalCollection
method argument
cannot be null.");
}
String username = (String)
principals.fromRealm(getName()).iterator().next();
Set<String> roleNames = ImmutableSet.of();
if (username != null) {
roleNames = ImmutableSet.of("admin", "user");
}
return new SimpleAuthorizationInfo(roleNames);
}
}
***************************************************
Thanks in advance for your help.
By the way, Is there somewhere on internet a complete example of
ShiroWebModule usage ?
--
View this message in context:
http://shiro-user.582556.n2.nabble.com/Guice-shiro-jersey-tp6673315p6673315.html
Sent from the Shiro User mailing list archive at Nabble.com.