CAS authentication in js android app

0

Hi

I just downloaded the js-android-app from github. The sample app requires user to provide authentication info like organization name, user name, password etc. 
But, I have a requirement in which I do not have user credentials, I have to set sessionId as cookie for the each jasper requests made in android app. Is there any way to accomplish this? Does it need too many code changes in sample app? Any help would be appreciated..

Thanks

vabhishek's picture
Joined: Jul 24 2014 - 2:40am
Last seen: 4 years 9 months ago

2 Answers:

0

I figured it out. I extended JsRestClient class to store the cookies in HttpURLConnection

public class CustomRestClient extends JsRestClient {
 public void setServerProfile(JsServerProfile serverProfile, final String sessionID) {                                                                                                  super.setServerProfile(serverProfile);
 ClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory() {                                                                                                                 @Override                                                                                                                                                                              protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {                                                                                     super.prepareConnection(connection, httpMethod);                                                                                                                                       String myCookie = "jsessionid=" + sessionID;                                                                                                                                           connection.setRequestProperty("Cookie", myCookie);                                                                                                                                     connection.setRequestProperty("Connection", "close");                                                                                                                    
      }                                                                                                                                                                                   };                                                                                                                                                                                   getRestTemplate().setRequestFactory(factory); }
}

vabhishek's picture
Joined: Jul 24 2014 - 2:40am
Last seen: 4 years 9 months ago
1

What version are you using?  It is not easy, but it should be possible in 5.1 or higher.  The place to start is the authentication cookbook, which tells you how to integrate with CAS for users who are logging in directly.  I would start there an then see if you can extend it to REST.

http://community.jaspersoft.com/documentation/jasperreports-authenticati...

elizam's picture
4158
Joined: Mar 5 2012 - 9:19am
Last seen: 1 week 5 days ago

Hey thanks for the response. But the server side implementation of the CAS authentication is already done. In fact, it is working perfectly fine in web browser. The only problem I have now is, I need to set session id as cookie for each requests made in the android app. I couldn't find anything in the document you suggested to help me solve that problem.

vabhishek - 5 years 1 month ago
Feedback
randomness