| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/01/2007 10:30:50
|
nusa
Joined: 07/01/2007 00:00:00
Messages: 11
Offline
|
I wonder whether any of you could share to us a sample code how to integrate ICEfaces and Acegi.
Thanks for any help/suggestions.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/01/2007 13:03:35
|
nusa
Joined: 07/01/2007 00:00:00
Messages: 11
Offline
|
Although the icefaces/lib directory got acegi-security-1.0.1.jar file, but there is no example how to use it in the icefaces/samples directory.
philip_b, could you gives us some hints or a sample code ?
Thanks.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 15/01/2007 14:47:24
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2628
Offline
|
Hi,
Here's a basic ICEfaces-Acegi example. It's simply the base acegi example modified. Acegi and dependent jars are included.
Thanks,
Philip
| Filename |
icefaces-acegi-example.zip |
Download
|
| Description |
ICEfaces Acegi Example |
| Filesize |
1639 Kbytes
|
| Downloaded: |
1225 time(s) |
|
. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 16/01/2007 12:46:17
|
nusa
Joined: 07/01/2007 00:00:00
Messages: 11
Offline
|
Thanks Philip.
Will this be part of example for the incoming 1.5.2 ?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 16/01/2007 16:59:37
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2628
Offline
|
Hi,
No, it's just a modified example from the acegi download.
Cheers,
Philip
|
. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 11/02/2007 04:32:24
|
johnny
Joined: 12/01/2007 00:00:00
Messages: 32
Offline
|
Hi Phillip,
I'm just confused by the reference to loginProxy.jsp.
Could you clarify that a little please?
Cheers
J
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/02/2007 10:20:55
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2628
Offline
|
Sure, good question, that refers to something that was unfinished in that example. In general, it's a challenge to create JAAS login pages in JSF as the JSF element name-mangling gets in the way of needing to post 'j_username' and 'j_password' field ids. MyFaces Tomahawk has a 'forceId' attribute to get around this, but we don't. So, originally, this example just used a normal JSP page for the login page.
I then ran into this smart workaround by Duncan Mills (http://groundside.com/blog/DuncanMills.php?title=j2ee_security_a_jsf_based_login_form&more=1&c=1&tb=1&pb=1) which involves redirecting to a loginProxy.jsp which reposts the fields with their expected ids. This allows you to have a rich ICEfaces login page using JAAS. I've attached the finished example.
Thanks,
Philip
| Filename |
icefaces-acegi-example.zip |
Download
|
| Description |
ICEfaces Acegi Security Example with ICEfaces Login page |
| Filesize |
1657 Kbytes
|
| Downloaded: |
1089 time(s) |
|
. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 17/02/2007 15:13:04
|
johnny
Joined: 12/01/2007 00:00:00
Messages: 32
Offline
|
Thank you very much philip,
I have Acegie working at the moment although i do get that redirect page showing on the screen temporarily while authentication is taking place.
But all good for now ;-)
Once again, thank you.
J
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 18/04/2007 14:10:24
|
eashwaranp
Joined: 12/02/2007 00:00:00
Messages: 135
Offline
|
I've not used Spring before, so I was wondering if it is possible to get an example of ICEfaces + ACEGI without spring.
Regards,
Eashwaran.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 18/04/2007 14:42:27
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2628
Offline
|
Hi Eashwaran,
Acegi is a sub-project of Spring and depends on the basic Spring jars. But don't worry if you haven't used Spring before, no specific knowledge is required to use a basic configuration.
Philip
|
. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 18/04/2007 15:08:17
|
eashwaranp
Joined: 12/02/2007 00:00:00
Messages: 135
Offline
|
Thanks. What are those basic spring jars and where can I get them? I just need the ones for running your example.
Also, do we really need the org.springframework.web.context.ContextLoaderListener listener?
It would be nice if we just limit the example to only the jars that are needed. I see a lot more jars, like
C:\temp\acegi-example\web\WEB-INF\lib>ls *.jar
aopalliance.jar commons-lang.jar
aspectjrt.jar ehcache-1.2.3.jar
commons-attributes-api.jar jakarta-oro-2.0.8.jar
commons-codec.jar jstl-1.0.6.jar
commons-collections.jar standard-1.0.6.jar
I understand the need for jstl and standard, but are the others needed to get acegi security working?
Please forgive my ignorance of spring framework. I don't have too much time to invest learning spring now or to investigate how to get acegi working.
All I want is some mechanism in ICEfaces to allow me to do rolebased security checks. I see that you have used a text file user.properties in your example to layout the user, password and roles. Is it possible to use a Database instead? If so, can you please guide me on how I can achieve this with a database?
Regards,
Eashwaran.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 25/04/2007 12:24:13
|
brad.kroeger
Joined: 26/10/2004 00:00:00
Messages: 263
Offline
|
I would recommend reading the acegi documentation which is pretty good. I did this by implementing my own acegi UserDetailsService:
In your applicationContext.xml implement your own UserDetailsService:
Code:
<bean id="userDetailsService" class="com.icesoft.icefaces.acegi.OurUserDetailsService">
</bean>
Acegi has a recommeded SQL schema to make things easier when accessing a database. I used an existing user database to match similar fields with the acegi User object (iwhere I didn't have a match, I set the attribute to TRUE). I then used groups from this database to define my User's GrantedAuthorities by concatenating ROLE_ to the group name. This allows you to use the ICEfaces component attributes enabledOnUserRole/renderedOnUserRole:
Code:
public class OurUserDetailsService implements UserDetailsService {
private Connection authenticationConnection;
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
authenticationConnection = DBObject.getInstance().setupConnection("icefaces","icefaces","localhost","usertable");
try{
Statement authenticationStatement = authenticationConnection.createStatement();
ResultSet results = authenticationStatement.executeQuery("SELECT user_id, user_enabled, user_password, user_locked, FROM usertable WHERE username = \"" + username + "\";");
if(results.first()){
int id = results.getInt(1);
Boolean enabled = results.getBoolean(2);
String password = results.getString(3);
Boolean locked = results.getBoolean(4);
results = authenticationStatement.executeQuery("SELECT ug.group_id, g.group_name FROM usergroups ug, groups g WHERE ug.group_id = g.group_id AND ug.user_id = \"" + id + "\" ORDER BY g.group_id;");
ArrayList tempGrantedAuthorities = new ArrayList();
while (results.next()) {
GrantedAuthority temp = new GrantedAuthorityImpl("ROLE_" + results.getString("group_name"));
tempGrantedAuthorities.add(temp);
}
GrantedAuthority[] grantedAuthorities = new GrantedAuthority[tempGrantedAuthorities.size()];
tempGrantedAuthorities.toArray(grantedAuthorities);
authenticationStatement.close();
return new User(username,password,enabled,Boolean.TRUE,Boolean.TRUE,locked,grantedAuthorities);
}else{
throw new UsernameNotFoundException("Username Not Found");
}
}catch (SQLException sqe) {
sqe.printStackTrace();
}
return null;
}
}
|
Brad Kroeger
Developer
ICEsoft Technologies, Inc. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 10/05/2007 12:09:34
|
brad.kroeger
Joined: 26/10/2004 00:00:00
Messages: 263
Offline
|
I have added an example of a full ICEfaces/acegi implementation in this post:
http://www.icefaces.org/JForum/posts/list/1625.page
|
Brad Kroeger
Developer
ICEsoft Technologies, Inc. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 06/06/2007 16:35:33
|
eashwaranp
Joined: 12/02/2007 00:00:00
Messages: 135
Offline
|
Hello,
Thanks for the info. I just got both your examples running on my box; still have to research them though.
I thought I'll update you with the info on spring jars. The acegi-example (with the tree) only needs spring.jar from Spring, which was missing in the lib dir of the package.
The security.war example (with the JMS queues) that Brad posted in another link also has a lot of jars in the lib dir, but it seems to need only commons-lang.jar, jakarta-oro-2.0.8.jar, ehcache-1.2.4.jar, and spring.jar.
Please note that these are in addition to the jars that are shipped with Eclipse plugin for ICEfaces, and ofcourse acegi-security-1.0.1.jar and servlet-api.jar.
I got the examples working with above jars. In case I missed any jar or if I've stated anything in error, please feel free to correct me.
Regards,
Eashwaran.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 07/06/2007 14:01:55
|
jotache
Joined: 28/05/2007 00:00:00
Messages: 10
Offline
|
thanks very much. i 've been using spring + acegi and now icefaces.
|
|
|
 |
|
|