-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Opensymphony's OSUser: anyone used it yet?
PostPosted: Sat Sep 27, 2003 6:50 pm 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
I'm intrested in using OSUser for as the authentication framework, since it has build-in support for Hibernate. However: there's no documentation whatsoever and I have no clue on how to start. Anyone who has some experience with it?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2003 8:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I have. I actually wrote the weblogic 6.1 provider for OSUser. I haven't checked back in for a while, but there was a major lack of focus for that particular component. There is (was) a major refactoring starting, but never seemed to make any progress. I've since chosen to stay away from using it.

What exactly are you trying to do?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2003 2:18 am 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
I want an authentication system for my website. This system should be able to do the following:

construct and edit users
construct and edit roles
construct and edit usergroups
construct and edit permissions

So it basically should be a flexible authentication system, where you can create every possible combination with permissions and there's no limit of roles.

I can start from scratch ofcourse, but I'd rather make use of some proven solution.

I've looked around for a while and OSUser seemed to have exactly what I want, minus good documentation that is :(


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2003 7:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
OSUser attempts to configure itsef as follows:
1) Look for osuser.xml in the classpath
2) Look for META-INF/osuser.xml in the classpath
3) Look for the System property osuser.config.file and load the resource from there
4) Look for the System property osuser.config.url and load the resource from there
5) Load the default configuration from META-INF/osuser-default.xml

The XML config needs to look something like:
Code:
<opensymphony-user>
   <provider class="com.opensymphony.user.provider.memory.MemoryCredentialsProvider" />
   <provider class="com.opensymphony.user.provider.memory.MemoryProfileProvider" />
   <provider class="com.opensymphony.user.provider.memory.MemoryAccessProvider" />
</opensymphony-user>


The just call UserManager.getInstance();


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2003 10:10 am 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
Thanks! But what about examples how to check whether a certain user has permission to perform a certain action? That kind of things is that is lacking from the documentation, the actual implementation of the business logic.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2003 12:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
OSUser does not fulfill that role. OSUser simply handles Users, Groups, and associations between Users and Groups. Applications using OSUser are responsible for interpreting what that association means in terms of access privileges.

If your looking for a way to define that "interpretation" of a User/Group association in relation to a given resource, then you need an entitlement enigine, not a user manager. Opensymphony does have such a component, also, called OSAccess, but I've never used that one.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 6:35 am 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
Thanks, I'm looking into both of them now...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 7:31 am 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
hm, getting the following error:

Code:
java.lang.RuntimeException: net/sf/hibernate/HibernateException
        com.opensymphony.user.util.ConfigLoader.load(ConfigLoader.java:74)
        com.opensymphony.user.UserManager.(UserManager.java:103)
        com.opensymphony.user.UserManager.(UserManager.java:58)
        org.mathesis.test.OSUserTest.doGet(OSUserTest.java:31)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:853)


Guess I have to look into the log-messages of hibernate, however I cannot find it.

Have put a log4j.properties in the WEB-INF/classes dir:

Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ##

log4j.rootLogger=warn, stdout

log4j.logger.net.sf.hibernate=info

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace

### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=info

### log prepared statement cache activity ###
log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=info


But cannot find any log-messages and can't find hibernate.log neither...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 11:20 am 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
I've put it now in WEB-INF/lib

but still no logging :(


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 04, 2003 1:33 pm 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
Ok, found a possibly related error in catalina.out:

Code:
com.opensymphony.user.util.ConfigLoader load
SEVERE: Exception
java.lang.NoClassDefFoundError: net/sf/hibernate/HibernateException
   at com.opensymphony.user.provider.hibernate.HibernateBaseProvider.init(HibernateBaseProvider.java:80)
   at com.opensymphony.user.util.ConfigLoader.addProvider(ConfigLoader.java:123)
   at com.opensymphony.user.util.ConfigLoader.access$100(ConfigLoader.java:37)
   at com.opensymphony.user.util.ConfigLoader$ConfigHandler.endElement(ConfigLoader.java:154)
   at
...


this is the error that the servlet throws up:

Code:
java.lang.RuntimeException: net/sf/hibernate/HibernateException
        com.opensymphony.user.util.ConfigLoader.load(ConfigLoader.java:74)
        com.opensymphony.user.UserManager.(UserManager.java:103)
        com.opensymphony.user.UserManager.(UserManager.java:58)
        org.mathesis.test.OSUserTest.doGet(OSUserTest.java:35)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:853)


I've got hibernate.jar in my WEB-INF/lib directory...

This is the servlet code:

Code:
/*
* Created on 29-sep-2003
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.mathesis.test;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Iterator;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opensymphony.user.DuplicateEntityException;
import com.opensymphony.user.ImmutableException;
import com.opensymphony.user.User;
import com.opensymphony.user.UserManager;
import com.opensymphony.user.provider.CredentialsProvider;

/**
* @author iljahehenkamp
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class OSUserTest extends HttpServlet
{
   public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
   {
      UserManager um = new UserManager();
      PrintWriter out = response.getWriter();
      
      Collection credentialProviders = null;
      
      try
      {
         credentialProviders = um.getCredentialsProviders();
         
         for (Iterator iterator = credentialProviders.iterator(); iterator.hasNext();)
         {
            CredentialsProvider provider = (CredentialsProvider) iterator.next();
         }
      }
      catch (NullPointerException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace(out);
      }
      
      try
      {
         User u = um.createUser("jan wandelaar");
      }
      catch (DuplicateEntityException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace(out);
      }
      catch (ImmutableException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace(out);
      }
      catch (NullPointerException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace(out);
      }
      catch (RuntimeException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace(out);
      }
      catch (Exception e)
      {   
         e.printStackTrace(out);
      }
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 05, 2003 3:54 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Ilja, reading your latest posting. I can't help but think that you have a blind spot somwhere regarding classloaders. I suggest you check your installation, read some classloader documentation, or even do both. :)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 05, 2003 5:38 pm 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
christian wrote:
Ilja, reading your latest posting. I can't help but think that you have a blind spot somwhere regarding classloaders. I suggest you check your installation, read some classloader documentation, or even do both. :)


You were right christian, I had some conflicts in my different paths. I have seemed to solve these, however now I get the following error directly from hibernate:

Code:
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
   at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:31)
   at net.sf.hibernate.impl.SessionFactoryImpl.openConnection(SessionFactoryImpl.java:402)
   at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:2751)
   at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:50)
   at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:395)
   at net.sf.hibernate.loader.Loader.doFind(Loader.java:118)
   at net.sf.hibernate.loader.Loader.find(Loader.java:507)
   at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:856)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1329)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1308)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1304)
   at com.opensymphony.user.provider.hibernate.impl.HibernateUserDAOImpl.findUserByUsername(HibernateUserDAOImpl.java:67)
   at com.opensymphony.user.provider.hibernate.HibernateCredentialsProvider.handles(HibernateCredentialsProvider.java:83)
   at com.opensymphony.user.UserManager.getProvider(UserManager.java:306)
   at com.opensymphony.user.UserManager.createEntity(UserManager.java:350)
   at com.opensymphony.user.UserManager.createUser(UserManager.java:238)
   at org.mathesis.test.OSUserTest.doGet(OSUserTest.java:57)

[...]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 05, 2003 5:41 pm 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
This is my hibernate.cfg.xml:

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

    <!-- a SessionFactory instance listed as /jndi/name -->
    <session-factory>
   
        <!-- properties -->
        <property name="connection.datasource">java:comp/env/jdbc/Mathesis</property>
        <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
        <property name="show_sql">false</property>
        <property name="use_outer_join">true</property>

        <!-- mapping files -->
        <mapping resource="org/mathesis/user/User.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


I've configured a JNDI resource which did work with another test.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 05, 2003 6:13 pm 
Beginner
Beginner

Joined: Sat Sep 20, 2003 4:23 am
Posts: 48
before you take the effort to reply, I'm slowly getting there. Just give me some time ;)


Top
 Profile  
 
 Post subject: Re: Opensymphony's OSUser: anyone used it yet?
PostPosted: Fri Oct 10, 2003 11:49 am 
Newbie

Joined: Mon Sep 01, 2003 9:48 pm
Posts: 17
Ilja wrote:
I'm intrested in using OSUser for as the authentication framework, since it has build-in support for Hibernate. However: there's no documentation whatsoever and I have no clue on how to start. Anyone who has some experience with it?


The thing that I have found most useful about OSUser is that it provides a very nice way of switching out your authentication providers midstream by abstracting the interfaces. Of less utility but equal importance is the ability to connect it to a large number of containers. It's less common to switch app servers, but switching from auth caches in a SQL database to an LDAP server shouldn't cause you to have to do a lot of work. OSUser handles that.

Additionally, if you want to use OSGroup, it requires OSUser. OSGroup may be the bigger reason to use OSUser than you think.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.