protected final Assertion parseResponseFromServer(final String response) throws TicketValidationException {
final String error = XmlUtils.getTextForElement(response, "authenticationFailure");
if (CommonUtils.isNotBlank(error)) {
throw new TicketValidationException(error);
}
final String principal = XmlUtils.getTextForElement(response, "user");
final String proxyGrantingTicketIou = XmlUtils.getTextForElement(response, "proxyGrantingTicket");
final String proxyGrantingTicket;
if (CommonUtils.isBlank(proxyGrantingTicketIou) || this.proxyGrantingTicketStorage == null) {
proxyGrantingTicket = null;
} else {
proxyGrantingTicket = this.proxyGrantingTicketStorage.retrieve(proxyGrantingTicketIou);
}
if (CommonUtils.isEmpty(principal)) {
throw new TicketValidationException("No principal was found in the response from the CAS server.");
}
分析后发现是response返回值出问题了,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>CAS – Central Authentication Service</title>
<meta name="_csrf" content=""/>
<meta name="_csrf_header" content=""/>
<link rel="stylesheet" href="/css/cas.css" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>
<body id="cas">
<div id="container">
<header>
<a id="logo" href="http://www.apereo.org" title="go to Apereo home page">Apereo</a>
<h1>Central Authentication Service (CAS)</h1>
</header>
<div id="content">
<div id="cookiesDisabled" class="errors" style="display:none;">
<h2>Browser cookies disabled</h2>
<p>Your browser does not accept cookies. Single Sign On WILL NOT WORK.</p>
</div>
<div id="serviceui" class="serviceinfo">
<table>
<tr>
<td><img src="images/webapp.png"></td>
<td id="servicedesc">
<h1>HTTPS and IMAPS</h1>
<p>This service definition authorized all application urls that support HTTPS and IMAPS protocols.</p>
</td>
</tr>
</table>
</div>
<p/>
<div class="box" id="login">
<form id="fm1" action="/login?ticket=ST-16-EGEyRb3BlMZqEWUUxJcL-cas01.example.org&service=http%3A%2F%2Fserver.liu.com%3A8081%2Ftest1%3Bjsessionid%3DB3C42F1109CDA8D004CE79858E53CBA1%3Bjsessionid%3DE55B13F1D64FF29DD96ED05CD7CDB73B" method="post">
<h2>Enter your Username and Password</h2>
<section class="row">
<label for="username"><span class="accesskey">U</span>sername:</label>
<input id="username" name="username" class="required" tabindex="1" accesskey="u" type="text" value="" size="25" autocomplete="off"/>
</section>
<section class="row">
<label for="password"><span class="accesskey">P</span>assword:</label>
<input id="password" name="password" class="required" tabindex="2" accesskey="p" type="password" value="" size="25" autocomplete="off"/>
<span id="capslock-on" style="display:none;"><p><img src="images/warning.png" valign="top"> CAPSLOCK key is turned on!</p></span>
</section>
<!--
<section class="row check">
<p>
<input id="warn" name="warn" value="true" tabindex="3" accesskey="w" type="checkbox" />
<label for="warn"><span class="accesskey">W</span>arn me before logging me into other sites.</label>
<br/>
<input id="publicWorkstation" name="publicWorkstation" value="false" tabindex="4" type="checkbox" />
<label for="publicWorkstation">I am at a public workstation.</label>
<br/>
<input type="checkbox" name="rememberMe" id="rememberMe" value="true" tabindex="5" />
<label for="rememberMe">Remember Me</label>
</p>
</section>
<section class="row btn-row">
<input type="hidden" name="execution" value="289fd1cd-0793-4f99-94f3-5041b51c4eeb_ZXlKaGJHY2lPaUpJVXpVeE1pSjkuTm1GUlduaDJiRFJHYWxFMVlXd3JaRmh1U2poa1owNHpSVmszWkc5SmMySXhTMmRXV1VjNFFYTkRPRWsxUzJnelpIbHlPRWd3YmprclduVldabVpYTTFvMFJFZ3ZaRWs0ZGxWcGQzWmpjVEF6VW1GTGVYaHBSVWwzV1hwTU5WaE5UVTh5TUc0clQxZHZaa2hyZFZONVJHNWFiR1ZwTTNSVUwwRktMMGw0U0VGMFlqSnFNVzlYVlU1cFZtaGtkakZzZVZBNU9XVjVUVVZ1VEhscFRFSkJhVmMwWWt0aWNESndTalJZWkZsblptazJOM1Z1VUhCVFFUWlZOVXBzWkdKS2NEZ3lTMHR0WkhGQ2JFMXNSMUpVTUM4NVNrVlZXSGxSTDFSRWJVZEVjM0ZSSzNCblNUTjBibVJIZDNWc2MxYzRjak5GWW5neFdtZDJjVlo1TW5WUmMxcHhTRlJKWVZGelJtRTJkRWxLY2pneGJ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I3dEZheDdUSDdSU0M4ejZPVHZ5TF9KT2huaDRxSzZ4T3h2ZW5EYkM2MGJCdmQzQ0ZQSFViNG5VMTZTT3NvZV9EU1JBUlZR" />
<input type="hidden" name="_eventId" value="submit" />
<input class="btn-submit" name="submit" accesskey="l" value="LOGIN" tabindex="6" type="submit" />
<input class="btn-reset" name="reset" accesskey="c" value="CLEAR" tabindex="7" type="reset" />
</section>
</form>
</div>
<div id="sidebar">
<div class="sidebar-content">
<p>For security reasons, please <a href="logout">log out</a> and exit your web browser when you are done accessing services that require authentication!</p>
<div id="list-languages">
<h3>Languages:</h3>
<ul>
<li class="first"><a href="login?ticket=ST-16-EGEyRb3BlMZqEWUUxJcL-cas01.example.org&service=http%3A%2F%2Fserver.liu.com%3A8081%2Ftest1%3Bjsessionid%3DB3C42F1109CDA8D004CE79858E53CBA1%3Bjsessionid%3DE55B13F1D64FF29DD96ED05CD7CDB73B&locale=en">English</a></li>
<li><a href="login?ticket=ST-16-EGEyRb3BlMZqEWUUxJcL-cas01.example.org&service=http%3A%2F%2Fserver.liu.com%3A8081%2Ftest1%3Bjsessionid%3DB3C42F1109CDA8D004CE79858E53CBA1%3Bjsessionid%3DE55B13F1D64FF29DD96ED05CD7CDB73B&locale=es">Spanish</a></li>
<li><a href="login?ticket=ST-16-EGEyRb3BlMZqEWUUxJcL-cas01.example.org&service=http%3A%2F%2Fserver.liu.com%3A8081%2Ftest1%3Bjsessionid%3DB3C42F1109CDA8D004CE79858E53CBA1%3Bjsessionid%3DE55B13F1D64FF29DD96ED05CD7CDB73B&locale=fr">French</a></li>
<li><a href="login?ticket=ST-16-EGEyRb3BlMZqEWUUxJcL-cas01.example.org&service=http%3A%2F%2Fserver.liu.com%3A8081%2Ftest1%3Bjsessionid%3DB3C42F1109CDA8D004C...