Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-2009, 01:38 PM
Intermediate Member
 
Posts: 18
Default Authenticate with CAS & Mysql DB

Hi everyone

I have had a Zimbra server working great and authenticating via CAS. We are looking at testing a new server that authenticates by CAS but checks the CAS_FILTER_USER against a MySql database on another server where it retrieves the appropriate account name. The idea is, we want multiple users to access an account with their own CAS credentials.

I have added the following to the previously working preauth.jsp:

Code:
//Get CAS User from server and split username to only CWID
String casUser = (String) session.getAttribute(edu.yale.its.tp.cas.client.filter.CASFilter.CAS_FILTER_USER);
String[]cwid = casUser.split("@");
out.println(cwid[0]);


//START MYSQL CONNECTION AND QUERY
String DRIVER = "com.mysql.jdbc.Driver";
Class.forName(DRIVER).newInstance();

Connection con=null;
ResultSet rst=null;
Statement stmt=null;

String url="jdbc:mysql://test.other.server:3306/test?user=mickey&password=mouse";

con=DriverManager.getConnection(url);
stmt=con.createStatement();
rst=stmt.executeQuery("select cwid from members WHERE cwid='cwid[0]'");

while(rst.next()) {

String cwid2 = rst.getString(0);

}//end of while

rst.close();
stmt.close();
con.close();

String redirect = generateRedirect(request,cwid2+"@test.zimbra.server");
out.println(redirect);
response.sendRedirect(redirect);
The following appears in the /opt/zimbra/log/mailbox.log:

Code:
2009-10-13 14:47:24,936 WARN  [btpool0-9] [] log - /zimbra/preauth.jsp
org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP

PWC6197: An error occurred at line: 90 in the jsp file: /preauth.jsp
PWC6199: Generated servlet error:
cwid2 cannot be resolved
Any help in the right direction would be greatly appreciated.

~Tim
Reply With Quote
  #2 (permalink)  
Old 10-13-2009, 01:41 PM
Moderator
 
Posts: 7,911
Default

Code:
generateRedirect(request,cwid2+"@test.zimbra.server");
not a java person but will it not see cwid2+ as a var and not cwid ?
__________________
Reply With Quote
  #3 (permalink)  
Old 10-13-2009, 02:11 PM
Intermediate Member
 
Posts: 18
Default

The working preauth.jsp on the other server uses the following generateRedirect parameters so I don't believe it is the variable type:

Code:
generateRedirect(request,cwid[0]+"@test.zimbra.server");
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.