Error validating ticket

Scott Battaglia scott.battaglia at gmail.com
Sat Aug 16 15:34:07 EDT 2008


I just tried it and I got a 201 with the Location header set (though there
is an incorrect url being sent back)

-Scott

-Scott Battaglia
PGP Public Key Id: 0x383733AA
LinkedIn: http://www.linkedin.com/in/scottbattaglia


On Sat, Aug 16, 2008 at 3:08 PM, Jason Roscoe <jroscoe at riteaid.com> wrote:

>  Can anyone see anythingwrong with this?  I am kind of under a deadline to
> get this implemented.  Thanks for any and all help with this!!
>
>
>
>
> Yes, I have added this to the web.xml:
>
>
>
> <servlet>
>
>             <servlet-name>restlet</servlet-name>
>
>             <servlet-class>
> com.noelios.restlet.ext.spring.RestletFrameworkServlet</servlet-class>
>
>             <load-on-startup>1</load-on-startup>
>
>       </servlet>
>
>
>
>       <servlet-mapping>
>
>             <servlet-name>restlet</servlet-name>
>
>             <url-pattern>/v1/*</url-pattern>
>
>       </servlet-mapping>
>
>
>
> And I have changed my authenticationUrl to be:
> http://localhost:9089/cas/v1/tickets.  I still get a response code of 302.
>
>
>
> We can't use the standard CAS login page as we are not in a position to
> completely change our current login page, and don't want to use any sort of
> iframes or anything.
>
>
>
> I've also updated my code to this since I should be checking for a 201, not
> a 200.
>
>
>
> setAuthenticationUrl("http://localhost:9089/cas/v1/tickets");
>
>             PostMethod postMethod = *new* PostMethod(authenticationUrl);
>
>             GetMethod getMethod = *new* GetMethod();
>
>
>
>             NameValuePair[] data = {
>
>                         *new* NameValuePair("username", username),
>
>                         *new* NameValuePair("password", password)
>
>             };
>
>
>
>             postMethod.setRequestBody(data);
>
>
>
>             *try* {
>
>                   statusCode = client.executeMethod(postMethod);
>
>
>
>                   *logger*.debug("status code: " + statusCode);
>
>
>
>                   *if* (statusCode != HttpStatus.*SC_CREATED*) {
>
>                         *logger*.error("Post Method failed: " +
> postMethod.getStatusLine());
>
>                   }
>
>
>
> //          Read the response body.
>
>             *byte*[] responseBody = postMethod.getResponseBody();
>
>
>
>             // Deal with the response.
>
>             // Use caution: ensure correct character encoding and is not
> binary data
>
>             System.*out*.println(*new* String(responseBody));
>
>
>
>             } *catch* (HttpException e) {
>
>                   *logger*.error("Fatal protocol violation: " +
> e.getMessage());
>
>                   e.printStackTrace();
>
>             } *catch* (IOException e) {
>
>                   *logger*.error("Fatal transport error: " +
> e.getMessage());
>
>                   e.printStackTrace();
>
>             } *finally* {
>
>                   // Release the connection.
>
>                   *postMethod*.releaseConnection();
>
>             }
>
>
>
> Thanks
>
>
>  ------------------------------
>
> *From:* cas-bounces at tp.its.yale.edu [mailto:cas-bounces at tp.its.yale.edu] *On
> Behalf Of *Scott Battaglia
> *Sent:* Friday, August 15, 2008 3:13 PM
> *To:* Yale CAS mailing list
> *Subject:* Re: Error validating ticket
>
>
>
> Have you configured it according to the documentation?
>
>
> http://www.ja-sig.org/wiki/display/CASUM/RESTful+API
>
> Also any reason why you can't use the standard CAS login page?
>
> -Scott
>
> -Scott Battaglia
> PGP Public Key Id: 0x383733AA
> LinkedIn: http://www.linkedin.com/in/scottbattaglia
>
>  On Fri, Aug 15, 2008 at 2:28 PM, Jason Roscoe <jroscoe at riteaid.com>
> wrote:
>
> OK, I downloaded CAS 3.3 and am trying to use the Restful API.  Below is
> the code I have to generate a Ticket Granting Ticket, but the response code
> from the post is a 302, location header is http://localhost:9089/cas/login.,
> so it returns me the login page code
>
>
>
> setAuthenticationUrl("http://localhost:9089/cas/tickets");
>
>             PostMethod postMethod = *new* PostMethod(authenticationUrl);
>
>             GetMethod getMethod = *new* GetMethod();
>
>
>
>             NameValuePair[] data = {
>
>                         *new* NameValuePair("username", username),
>
>                         *new* NameValuePair("password", password)
>
>             };
>
>
>
>             postMethod.setRequestBody(data);
>
> postMethod.setRequestBody(data);
>
>
>
>             *try* {
>
>                   statusCode = client.executeMethod(postMethod);
>
>
>
>                   *logger*.debug("status code: " + statusCode);
>
>
>
>                   *if* (statusCode != HttpStatus.*SC_OK*) {
>
>                         *if* (statusCode == HttpStatus.*
> SC_MOVED_PERMANENTLY*
>
>                        || statusCode == HttpStatus.*SC_MOVED_TEMPORARILY*
>
>                        || statusCode == HttpStatus.*SC_SEE_OTHER*
>
>                        || statusCode == HttpStatus.*SC_TEMPORARY_REDIRECT*
> ) {
>
>                      String redirectLocation;
>
>                      Header locationHeader = postMethod
>
>                            .getResponseHeader("location");
>
>
>                      *if* (locationHeader != *null*) {
>
>                          redirectLocation = locationHeader.getValue();
>
>                          *logger*.debug("locationHeader = "
> +locationHeader.getValue());
>
>                          getMethod = *new* GetMethod(redirectLocation);
>
>                          statusCode = client.executeMethod(getMethod);
>
>                          *logger*.debug("Status code = "+statusCode);
>
>                          *if* (statusCode != HttpStatus.*SC_OK*) {
>
>                            *logger*.error("Method failed: " +
> getMethod.getStatusLine());
>
>                          }
>
> //                       Read the response body.
>
>                          *byte*[] responseBody =
> getMethod.getResponseBody();
>
>
>
>                          // Deal with the response.
>
>                          // Use caution: ensure correct character encoding
> and is not binary data
>
>                          System.*out*.println(*new* String(responseBody));
>
>                      } *else* {
>
>                          // The response is invalid and did not provide
> the new
>
>                          // location for
>
>                          // the resource. Report an error or possibly
> handle the
>
>                          // response
>
>                          // like a 404 Not Found error.
>
>                      }
>
>                  }
>
>                   }
>
>
>
> //                Read the response body.
>
>             *byte*[] responseBody = getMethod.getResponseBody();
>
>
>
>             // Deal with the response.
>
>             // Use caution: ensure correct character encoding and is not
> binary data
>
>             System.*out*.println(*new* String(responseBody));
>
>
>
>
>
>
>
>             } *catch* (HttpException e) {
>
>                   *logger*.error("Fatal protocol violation: " +
> e.getMessage());
>
>                   e.printStackTrace();
>
>             } *catch* (IOException e) {
>
>                   *logger*.error("Fatal transport error: " +
> e.getMessage());
>
>                   e.printStackTrace();
>
>             }
> ...
>
> [Message clipped]
> _______________________________________________
> Yale CAS mailing list
> cas at tp.its.yale.edu
> http://tp.its.yale.edu/mailman/listinfo/cas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tp.its.yale.edu/pipermail/cas/attachments/20080816/50d0eee5/attachment.html 


More information about the cas mailing list