Page 1 of 1

Getting Exception while implementing RowLevelSecurity

Posted: Tue Jun 09, 2015 6:43 am
by amit28
Hi, All I am Trying to Implement RowLevelSecurity, For Restrict Admin User According to Storage. I have Followed this URL
http://www.broadleafcommerce.com/docs/c ... l-security.
And I had Override these methods addFetchRestrictions() and addFetchRestrictionsRoot() .

So when I logged In in Admin Application i can access all the link except product link when I clicked on Product link then I am Getting ClassCastException like This:

"java.lang.ClassCastException: org.broadleafcommerce.openadmin.server.security.domain.AdminUserImpl cannot be cast to com.iwn.admin.user.MyAdminUser"

When I debug my application I get to know that I am getting Exception in following lines:

Store adminStore = ((MyAdminuser) currentUser).getStore();

Can anyone help me that how to resolve this issue, Thanks.

Re: Getting Exception while implementing RowLevelSecurity

Posted: Wed Jun 17, 2015 2:16 pm
by phillipuniverse
Answer is at http://stackoverflow.com/questions/3077 ... elsecurity which states:

If you have extended AdminuserImpl to your custom MyAdminuser make sure that you have followed all the instructions in http://www.broadleafcommerce.com/docs/c ... s-tutorial.

If you have done that but are still relying on the initial data imports, your data is likely wrong. Assuming that you have a table called MY_ADMIN_USER (that maps to the MyAdminuser Hibernate object), make sure that you have entries in that table for all of the entries in BLC_ADMIN_USER. Otherwise, Hibernate can only give you back instances of AdminUserImpl instead of your extended MyAdminuser.

One easy way to ensure this is with this SQL query:


INSERT INTO MY_ADMIN_USER (ADMIN_USER_ID) (SELECT blc.ADMIN_USER_ID FROM BLC_ADMIN_USER AS blc);