Cas update
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
package com.plannaplan.security;
|
||||
|
||||
public class CasValidationExcepiton extends RuntimeException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CasValidationExcepiton(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ public class CasValidator {
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public String validate() throws Exception {
|
||||
public String validate() throws Exception, CasValidationExcepiton{
|
||||
HttpGet request = new HttpGet(CasValidator.CAS_URL + "/validate?service="
|
||||
+ URLEncoder.encode(this.service, "UTF-8") + "&ticket=" + URLEncoder.encode(this.ticket, "UTF-8"));
|
||||
try (CloseableHttpResponse response = httpClient.execute(request)) {
|
||||
@ -31,8 +31,11 @@ public class CasValidator {
|
||||
if (entity != null) {
|
||||
// return it as a String
|
||||
result = EntityUtils.toString(entity);
|
||||
|
||||
if(result.replace("\n", "").trim().equals("no")){
|
||||
throw new CasValidationExcepiton("Validation failed");
|
||||
}
|
||||
}
|
||||
|
||||
String res = result.substring(result.indexOf('\n') + 1);
|
||||
return res;
|
||||
|
||||
|
Reference in New Issue
Block a user