Custom Acegi Authentication

I am attempting to upgrade from JS Pro 3.0 to JS Pro 3.5.1.

I have some custom code for acegi to do the authentication.

I override the jdbcDaoImpl bean and implement this bean in the mtDaoAuthenticationProvider.

This does not work.  Throws the following error on server start up:

java.lang.IllegalArgumentException: Cannot convert value of type [org.acegisecurity.userdetails.jdbc.JdbcDaoImpl] to required type [com.jaspersoft.jasperserver.multipleTenancy.MTUserDetailsService] for property 'MTUserDetailsService': no matching editors or conversion strategy found

 

I am guessing I am missing one piece in there somewhere.

Thanks in advance for your help.

Code:
<bean id="jdbcDaoImpl" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
        <property name="dataSource">
            <ref bean="dataSourceGBS"/>
        </property>
        <property name="usersByUsernameQuery">
            <value>Select username, '1' as tenantId,
                    password,
                    enabled
                   FROM   v_js_user
                   WHERE username = ?</value>
        </property>
        <property name="authoritiesByUsernameQuery">
            <value>SELECT user_name as username,
                      role_name as authority
                   FROM v_js_user_roles
                   WHERE user_name = ?</value>
        </property>
    </bean>
 
 
<bean id="mtDaoAuthenticationProvider" class="com.jaspersoft.jasperserver.multipleTenancy.MTDaoAuthenticationProvider">
        <!-- jdbcDaoImpl -->
        <!-- <property name="userDetailsService"><ref bean="inMemoryDaoImpl"/></property> -->
        <property name="userDetailsService"><ref bean="internalUserAuthorityService"/></property>
        <property name="MTUserDetailsService"><ref bean="jdbcDaoImpl"/></property>
        <property name="tenantService" ref="hibernateTenantService"/>
        <property name="passwordEncoder"><ref bean="passwordEncoder"/></property>
    </bean> 
</td></tr></tbody></table>
jfields's picture
97
Joined: Oct 22 2007 - 12:40am
Last seen: 15 years 11 months ago

18 Answers:

hey jfields,

We are also currently using JS 3.0, but would like to upgrade to 3.5 Community version. We have reports running on JS currently. Can you tell me if the upgrade process is simple, or would require me to delete everything in 3.0 and create new reports etc, in 3.5? Can I copy over a folder or something like that?

 

Thanks, Sridevi

skolluri's picture
421
Joined: Mar 23 2009 - 2:26pm
Last seen: 14 years 6 months ago

You need to delete your reports in 3.0 and recreate again in 3.5.

Please follow the instruction in 3.5 Install Guide regd upgrade from 3.0 to 3.5 .

(Upgrade process involves exporting your 3.0 data and then importing it in 3.5 . )

 

ramnik's picture
3221
Joined: Mar 16 2007 - 9:10am
Last seen: 16 years 6 months ago

Please ignore previous response:- Here is right response

 

You NEED NOT TO delete your old reports . Please follow the instruction in 3.5 Install Guide regd upgrade from 3.0 to 3.5 .

(Upgrade process involves exporting your 3.0 data and then importing it in 3.5 . )

ramnik's picture
3221
Joined: Mar 16 2007 - 9:10am
Last seen: 16 years 6 months ago

Sridevi,

I used the export script that came bundled with JS Pro 3.0 to back up my JS database.  Also did a mysqldump just in case.

Once the database was backed up, I followed the steps in the 3.5 install guild to use the 'buildomatic' scripts.  The scripts have you drop the 3.0 database, create a new database based on the 3.5 architecture, setup defualt users, and import my 3.0 data.

That part went smoothly.

I can log in as the default users (superuser, jasperadmin)  all seems fine.

 

My problem is when I modify acegi to authenitcate against an external db.

Other than that, the upgrade went very smoothly.

 

HTH,

Jeremy

jfields's picture
97
Joined: Oct 22 2007 - 12:40am
Last seen: 15 years 11 months ago

Thanks ramnik and jfields for your replies!

I did follow your tips. i downloaded the 3.5 version. and followed the instructions in the Install Guide.

But when I come to the part of import-export, I am stuck again! The js-import.sh and js-export.sh dont seem to work. I checked the configuration according to the guide. its all good. I cant run the commands - js-import.sh --help or js-import.sh --help. or any other js-import ot js-export commands. It gives me a message -

"-bash: js-import: command not found"  (ans the same for export too).

I made sure I am in the correct directory - where the js-import.sh exists - "<jasperserver-3.0-bin-unzipped directory>/scripts"

 

I seemed to have followed all the directions correctly, but still have no luch executing these commands. It looks like the import-export utility is not configured correctly.

 

I am kinda stuck here! Do you (or anyone else out there) have any tips on how to resolve this, pleeasse?!!

 

Thanks,

Sridevi

 

 

skolluri's picture
421
Joined: Mar 23 2009 - 2:26pm
Last seen: 14 years 6 months ago

Here are the tips you can use:-

1. if you are directory {js-install-dir}/scripts

try running

./js-import.sh

and ./js--export.sh

2. Or go to directory-> {install-dir}/buildomatic/

run command

./js-ant import and

./js-ant export

 

 

 

ramnik's picture
3221
Joined: Mar 16 2007 - 9:10am
Last seen: 16 years 6 months ago

Yes, that did it!!

Thanks so much for your prompt answer, Ramnik!

 

I dont know how I missed that, having had the same problem on executing shell scripts before on Linux!

But thanks for your answer! You are a lifesaver ;-)

 

Sridevi

skolluri's picture
421
Joined: Mar 23 2009 - 2:26pm
Last seen: 14 years 6 months ago

Hi,

 

I have another problem in the upgrade from 3.0 --> 3.5.

Everything went well for the steps 7.1, 7.2,7.3,7.4,7.5 of the Install Guide. I just started the section 7.6 - the actual Upgrade to 3.5, and am getting errors in the ant scripts.

I am running JasperServer on a Resin app server. Not using JBoss or Tomcat or Glassfish or any of the servers in the setup.xml file.

When I run the first command - js-ant drop-js-db, I get this error -

Buildfile: build.xml

BUILD FAILED
/opt/downloads/jasperserver-3.5.0-bin/buildomatic/build.xml:9: The following error occurred while executing this line:
/opt/downloads/jasperserver-3.5.0-bin/buildomatic/setup.xml:289: Error: Unable to determine type of app server in directory /opt/resin!

Total time: 1 second

 

I checked the setup.xml file, line 289. In the if statement, it is checking if the appserver is Tomcat 5, Tomcat 6, JBoss 4,5 , Glassfish V2 UR2 and thats it. So, if appserverType is not set (which it wouldnt be if it is not one of the above servers), it is throwing the error.

 

How can I set it to be Resin app server? If I were to create another if statement for Resin, what is the file I should check for? It is servlet-api-jar for Tomcat,  sun-appserv-ant.jar for Glassfish etc.

 

Can someone please help me?

(I should probably start another thread for this, but I see Ramnik and Jfields are following this, so I was hoping to atleast get replies from them ;-)

 

Thanks,

Sridevi

skolluri's picture
421
Joined: Mar 23 2009 - 2:26pm
Last seen: 14 years 6 months ago
Sridevi, I had received the same error with Tomcat. My problem was I did not have the correct path to tomcat in the default_master.properties file that you create for the buildomatic. My first thought is double check \'appServerDir\' and verify you have it correct. Otherwise I am not sure about Resin. jfields
jfields's picture
97
Joined: Oct 22 2007 - 12:40am
Last seen: 15 years 11 months ago

hey jfields, thanks for your reply.

 

I added another if element in setup.xml testing for the appserver - "resin". I dont know if it is right, or if the values i gave for the diffferent properties are right, but I was able to execute the drop, create, init , import database scripts successfully.

Now, I am trying to execute the js-ant import-upgrade-ce script, and am getting this error -

 13:53:36,937 ERROR ImporterImpl:109 - java.util.zip.ZipException: error in opening zip file
     [java] 13:53:36,957 ERROR BaseExportImportCommand:45 - com.jaspersoft.jasperserver.api.JSExceptionWrapper: error in opening zip file
     [java] com.jaspersoft.jasperserver.api.JSExceptionWrapper: java.util.zip.ZipException: error in opening zip file
     [java]     at java.util.zip.ZipFile.open(Native Method)
     [java]     at java.util.zip.ZipFile.<init>(ZipFile.java:114)
     [java]     at com.jaspersoft.jasperserver.export.io.ZipFileInput.open(ZipFileInput.java:51)
     [java]     at com.jaspersoft.jasperserver.export.ImporterImpl.performImport(ImporterImpl.java:92)
     [java]     at com.jaspersoft.jasperserver.export.ImportCommandImpl.process(ImportCommandImpl.java:57)
     [java]     at com.jaspersoft.jasperserver.export.BaseExportImportCommand.process(BaseExportImportCommand.java:87)
     [java]     at com.jaspersoft.jasperserver.export.ImportCommand.main(ImportCommand.java:43)
     [java] Java Result: 255

It is not able to open the database import zip file.

 

Anyone has any idea why?

Is anyone from the JasperServer support team around? Can you please help me figure this out?

 

Thanks,
Sridevi
 

skolluri's picture
421
Joined: Mar 23 2009 - 2:26pm
Last seen: 14 years 6 months ago

hey jfields, thanks for your reply.

 

I added another if element in setup.xml testing for the appserver - "resin". I dont know if it is right, or if the values i gave for the diffferent properties are right, but I was able to execute the drop, create, init , import database scripts successfully.

Now, I am trying to execute the js-ant import-upgrade-ce script, and am getting this error -

 13:53:36,937 ERROR ImporterImpl:109 - java.util.zip.ZipException: error in opening zip file
     [java] 13:53:36,957 ERROR BaseExportImportCommand:45 - com.jaspersoft.jasperserver.api.JSExceptionWrapper: error in opening zip file
     [java] com.jaspersoft.jasperserver.api.JSExceptionWrapper: java.util.zip.ZipException: error in opening zip file
     [java]     at java.util.zip.ZipFile.open(Native Method)
     [java]     at java.util.zip.ZipFile.<init>(ZipFile.java:114)
     [java]     at com.jaspersoft.jasperserver.export.io.ZipFileInput.open(ZipFileInput.java:51)
     [java]     at com.jaspersoft.jasperserver.export.ImporterImpl.performImport(ImporterImpl.java:92)
     [java]     at com.jaspersoft.jasperserver.export.ImportCommandImpl.process(ImportCommandImpl.java:57)
     [java]     at com.jaspersoft.jasperserver.export.BaseExportImportCommand.process(BaseExportImportCommand.java:87)
     [java]     at com.jaspersoft.jasperserver.export.ImportCommand.main(ImportCommand.java:43)
     [java] Java Result: 255

It is not able to open the database import zip file.

 

Anyone has any idea why?

Is anyone from the JasperServer support team around? Can you please help me figure this out?

 

Thanks,
Sridevi
 

skolluri's picture
421
Joined: Mar 23 2009 - 2:26pm
Last seen: 14 years 6 months ago
Jeremy,
Can you please attach the current XML you use to authnticate from the external DB?
I have the samr problam without any upgrading...
Thanks,
Meir
meir's picture
34
Joined: Oct 18 2009 - 6:52am
Last seen: 13 years 11 months ago
Code:
Make sure you have the daoAuthenticationProvider uncommented.
 
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
        <property name="providers">
            <list>
                <!-- not on by default <ref local="ldapAuthenticationProvider"/>  -->
                <ref local="daoAuthenticationProvider"/>
                <ref local="anonymousAuthenticationProvider"/>
                <!--ref local="jaasAuthenticationProvider"/-->
            </list>
        </property>
    </bean>
 
Make sure the jdbcDaoImpl is uncommented.
Also becareful of the password encoder.  Uncomment if you need it.  I had to override to use the encoding that the external db used.
<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
        <!-- jdbcDaoImpl --> 
        <!-- <property name="userDetailsService"><ref bean="inMemoryDaoImpl"/></property> -->
        <!-- <property name="userDetailsService"><ref bean="userAuthorityService"/></property> -->
        <!-- <property name="passwordEncoder"><ref local="passwordEncoder"/></property>  -->
        <property name="userDetailsService"><ref bean="jdbcDaoImpl"/></property>    
        <property name="passwordEncoder"><ref  local="passwordEncoder"/></property>
    </bean>
 
This is the override to use the encoding that I use in the external db.
<bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.Md5PasswordEncoder"/>
 
Override the jdbcDaoImpl giving the 2 querys that acegi will use to authenticate.
I created views on the external db.  That made it easier to call from here.  The columns returned from these queries is important.  Acegi expects the 3 columns from the first and the 2 columns from the second.
The dataSource is just another bean i have set up in another file that has a jndi resource for the datasource informantion.
<bean id="jdbcDaoImpl" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
        <property name="dataSource">
        	<ref bean="dataSourceGBS"/>
        </property>
        <property name="usersByUsernameQuery">
        	<value>Select username,
        			password,
        			enabled
        		   FROM   v_js_user
        		   WHERE username = ?</value>
        </property>
        <property name="authoritiesByUsernameQuery">
        	<value>SELECT user_name as username, 
        			  role_name as authority
        		   FROM v_js_user_roles 
        		   WHERE user_name = ?</value>
        </property>
 
    </bean>
 
 
Hope this helps.
Note: This method will no longer work with JS v3.5.  I had to switch to use jaas authentication.
</td></tr></tbody></table>
jfields's picture
97
Joined: Oct 22 2007 - 12:40am
Last seen: 15 years 11 months ago

 So JdbcDaoImpl will not work neither with JS CE 3.7.0 ?

We must implement Jaas classes ?

jogrey's picture
670
Joined: Jun 28 2007 - 7:17pm
Last seen: 16 years 3 months ago
Could we use the jdbcDaoImpl with JS CE 3.7.0 ?
jogrey's picture
670
Joined: Jun 28 2007 - 7:17pm
Last seen: 16 years 3 months ago
With JS Pro, we were not able to use the jdbcDaoImpl because of the addition of multi-tenancy. I am not sure if it is the same with CE.


jfields's picture
97
Joined: Oct 22 2007 - 12:40am
Last seen: 15 years 11 months ago

Ok, it should be the same in the CE JdbcDaoImpl seems to have an issue with my version too.

 

So, how do you succeed to peform this operation ?

 

Thank you :)

jogrey's picture
670
Joined: Jun 28 2007 - 7:17pm
Last seen: 16 years 3 months ago
Hi Jeremy

I'm currently trying to upgrade from JS 3-3.5.
I am battling with the same appServerDir problem as the previous user above.
I have Apache-TomCat installed as part of my original JS installation.

I have set appServerDir =C:\\Program Files\\Jasper\\jasperserver-2.0\\apache-tomcat
and get the following error.

C:\\Program Files\\Jasper\\jasperserver-3.5.0-bin\\buildomatic>js-ant drop-js-db
Buildfile: build.xml

BUILD FAILED
C:\\Program Files\\Jasper\\jasperserver-3.5.0-bin\\buildomatic\\build.xml:9: The foll
owing error occurred while executing this line:
C:\\Program Files\\Jasper\\jasperserver-3.5.0-bin\\buildomatic\\setup.xml:230: Error:
App server root directory ${appServerDir} not found!

Total time: 1 second

Any help would be greatly appreciated.
Regards
Sarah


sarahllong's picture
Joined: Mar 10 2010 - 6:16am
Last seen: 8 years 2 weeks ago
Feedback
randomness