<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic WebScript from HttpClient in CAS third party application in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/webscript-from-httpclient-in-cas-third-party-application/m-p/276108#M229238</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I implement CAS SSO across both Alfresco (3.3E) and a third party sample application.(a simple servelt)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I need call a webscript (for example …alfresco/wcservice/office/getUsers) through HttpClient get.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is:CAS server return CAS login page&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;( i retrieve the page from method.getResponseBodyAsString())&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It should be noted that if i try to call the same webscript from browser (after SSO CAS login) i retrieve the correct result and the authentication is correctly managed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-from browser i call a simple servlet (A) filtered by CAS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-CAS login prompt appear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Log in with admin/admin&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-CAS authentication ok&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Call simple servlet (A) with request param (?goto=callAlf) .The servlet run the HttpClient above:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HttpClient client = new HttpClient();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;String ticketProxed = assertion1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.getPrincipal()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.getProxyTicketFor(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A href="https://localhost:8443/alfresco/wcservice/office/getUsers" rel="nofollow noopener noreferrer"&gt;https://localhost:8443/alfresco/wcservice/office/getUsers&lt;/A&gt;&lt;SPAN&gt;");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GetMethod method = new GetMethod(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A href="https://localhost:8443/alfresco/wcservice/office/getUsers" rel="nofollow noopener noreferrer"&gt;https://localhost:8443/alfresco/wcservice/office/getUsers&lt;/A&gt;&lt;SPAN&gt;");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;method.getParams().setParameter("ticket", ticket);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// method.setDoAuthentication(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int statusCode = client.executeMethod(method);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (statusCode != HttpStatus.SC_OK) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.err.println("Method failed: " + method.getStatusLine());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;String res = method.getResponseBodyAsString();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.out.println("ESITO:" + res);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;JSONArray jsonOut = new JSONArray(res);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.out.println(jsonOut);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return jsonOut.toString();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-I retrive Login CAS page in res.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I attach the Alfresco web.xml configuration file for CAS filter&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for support!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matteo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Authentication Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-class&amp;gt;org.jasig.cas.client.authentication.AuthenticationFilter&amp;lt;/filter-class&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;casServerLoginUrl&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;&lt;/SPAN&gt;&lt;A href="https://localhost:9443/cas-server-webapp-3.4.2/login" rel="nofollow noopener noreferrer"&gt;https://localhost:9443/cas-server-webapp-3.4.2/login&lt;/A&gt;&lt;SPAN&gt;&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;serverName&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;&lt;/SPAN&gt;&lt;A href="https://localhost:8443" rel="nofollow noopener noreferrer"&gt;https://localhost:8443&lt;/A&gt;&lt;SPAN&gt;&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;renew&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;false&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;gateway&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;false&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Validation Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-class&amp;gt;org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter&amp;lt;/filter-class&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;casServerUrlPrefix&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;&lt;/SPAN&gt;&lt;A href="https://localhost:9443/cas-server-webapp-3.4.2/" rel="nofollow noopener noreferrer"&gt;https://localhost:9443/cas-server-webapp-3.4.2/&lt;/A&gt;&lt;SPAN&gt;&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;serverName&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;&lt;/SPAN&gt;&lt;A href="https://localhost:8443" rel="nofollow noopener noreferrer"&gt;https://localhost:8443&lt;/A&gt;&lt;SPAN&gt;&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;proxyCallbackUrl&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;&lt;/SPAN&gt;&lt;A href="https://localhost:8443/alfresco/MTCallback" rel="nofollow noopener noreferrer"&gt;https://localhost:8443/alfresco/MTCallback&lt;/A&gt;&lt;SPAN&gt;&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;proxyReceptorUrl&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;/MTCallback&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-name&amp;gt;acceptAnyProxy&amp;lt;/param-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/init-param&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS HttpServletRequest Wrapper Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-class&amp;gt;org.jasig.cas.client.util.HttpServletRequestWrapperFilter&amp;lt;/filter-class&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Assertion Thread Local Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-class&amp;gt;org.jasig.cas.client.util.AssertionThreadLocalFilter&amp;lt;/filter-class&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Authentication Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/faces/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/wcservice/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Validation Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/faces/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/wcservice/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS HttpServletRequest Wrapper Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/faces/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/wcservice/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Assertion Thread Local Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/faces/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/wcservice/*&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;CAS Validation Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;url-pattern&amp;gt;/MTCallback&amp;lt;/url-pattern&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-name&amp;gt;Authentication Filter&amp;lt;/filter-name&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;description&amp;gt;dp2k filter&amp;lt;/description&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;filter-class&amp;gt;it.dp2000.alfresco.cas.CASAuthenticationFilter&amp;lt;/filter-class&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/filter&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;!– END –&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Mar 2011 14:15:20 GMT</pubDate>
    <dc:creator>plinio</dc:creator>
    <dc:date>2011-03-23T14:15:20Z</dc:date>
    <item>
      <title>WebScript from HttpClient in CAS third party application</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/webscript-from-httpclient-in-cas-third-party-application/m-p/276108#M229238</link>
      <description>Hi all,I implement CAS SSO across both Alfresco (3.3E) and a third party sample application.(a simple servelt)I need call a webscript (for example …alfresco/wcservice/office/getUsers) through HttpClient get.The problem is:CAS server return CAS login page( i retrieve the page from method.getResponseB</description>
      <pubDate>Wed, 23 Mar 2011 14:15:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/webscript-from-httpclient-in-cas-third-party-application/m-p/276108#M229238</guid>
      <dc:creator>plinio</dc:creator>
      <dc:date>2011-03-23T14:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: WebScript from HttpClient in CAS third party application</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/webscript-from-httpclient-in-cas-third-party-application/m-p/276109#M229239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I suggest to install the CAS REST API to allow HTTP call directly to the CAS server without parsing the HTML page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise you need to parse the HTML page of the login form to get all the hidden parameters included in this form to allow you to create a granting ticket.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Mar 2011 14:00:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/webscript-from-httpclient-in-cas-third-party-application/m-p/276109#M229239</guid>
      <dc:creator>openpj</dc:creator>
      <dc:date>2011-03-26T14:00:23Z</dc:date>
    </item>
  </channel>
</rss>

