Hi,
I recently set up the Fulcrum security using the dynamic model using
hibernate for Antelope (a sample app for turbine found at
http://zebra.tigris.org ).
I am not sure exactly what you are trying to achieve and I am sorry if I
have got the wrong end of the stick, but when you are adding the security
elements you should use the managers. These encapsulate all the hibernate
code for getting them into the database.
However if you are writing a manager you cannot use the securitySet.add()
method directly because it throws a "unimplemented exception" as you stated.
You have to use the methods on the subclass. To get round this I did
something along these lines:
SecuritySet ss;
...
if (shouldAdd) {
if (ss instanceof GroupSet)
((GroupSet) ss).add((Group) e1);
if (ss instanceof RoleSet)
((RoleSet) ss).add((Role) e1);
if (ss instanceof PermissionSet)
((PermissionSet) ss).add((Permission) e1);
}
If you have a look at Antelope though if will give you a lot more info on
how I set it all up.
Cheers
Mike
-----Original Message-----
From: Lester Ward [mailto:[EMAIL PROTECTED]
Sent: 24 June 2004 18:31
To: Turbine User Mailing List (E-mail)
Subject: Fulcrum SecuritySet error
I'm using Fulcrum's security component to use Hibernate with Turbine 2.3.
Using the dynamic security model, I'm running into an issue. I'm subclassing
the security objects from Fulcrum such as
org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup. I have code
that looks like this:
Set roles = a_Group.getRolesAsSet();
Role role = (Role)m_RolesByName.get(k_RoleUser);
roles.add(role);
I get this exception:
java.lang.RuntimeException: not implemented
at
org.apache.fulcrum.security.util.SecuritySet.add(SecuritySet.java:257)
at net.sf.hibernate.collection.Set.add(Set.java:156)
at com.tagaudit.humpback.Humpback.attachRoles(Humpback.java:424)
at com.tagaudit.humpback.Humpback.translateUser(Humpback.java:366)
at com.tagaudit.humpback.Humpback.walkUsers(Humpback.java:316)
at com.tagaudit.humpback.Humpback.run(Humpback.java:111)
at com.tagaudit.humpback.Humpback.main(Humpback.java:87)
This appears to be caused be an odd combination of things:
1) The SecuritySet.add(Object) method throws an unimplemented exception,
apparently because it's subclasses have typed add() method that the author
wants to be called instead of the generic add(Object) method.
2) In the code, my roles object is a net.sf.hibernate.collection.Set object.
This object is evidently a proxy wrapped around another Set, in this case an
org.apache.fulcrum.security.util.RoleSet.
3) The RoleSet object has an add(Role) method and is a subclass of
SecuritySet.
4) Hibernate's Set.add method looks like this:
public boolean add(Object value)
{
write();
return set.add(value);
}
5) Since the Hibernate add takes an object, when it calls set.add(), it ends
up invoking the add(Object) call of the RoleSet object. Since this object
doesn't have one of those, it invokes the add(Object) method of its
superclass, which throws the unimplemented exception (see item 1 above).
Now, as near as I can tell, this means I'm pretty much hosed. I have to
alter either Fulcrum's set objects, Hibernate's set objects or both to fix
this problem.
Anyone have any advice for solving this?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Scanned for viruses by MessageLabs
Scanned for viruses by MessageLabs. The integrity and security of this message cannot
be guaranteed. This email is intended for the named recipient only, and may contain
confidential information and proprietary material. Any unauthorised use or disclosure
is prohibited.