validate filed granting ticket on application start

This commit is contained in:
Peter Hormanns 2016-09-01 16:24:06 +02:00
parent fcf28c8381
commit feddbc5989

View File

@ -39,15 +39,11 @@ public class CASTicketProvider implements TicketProvider {
this.runAs = runAs;
this.backendURL = backendURL;
this.loginURL = loginURL;
if ("TestUmgebung".equals(loginURL)) {
grantingTicket = "ticket:" + user;
} else {
grantingTicket = readFiledGrantingTicket();
}
readFiledGrantingTicket();
}
@Override
public String getTicket() throws JSCliException, FileNotFoundException {
public String getTicket() throws JSCliException {
try {
final String encodedParams =
URLEncoder.encode("service", "UTF-8") + "=" + URLEncoder.encode(backendURL, "UTF-8");
@ -116,8 +112,7 @@ public class CASTicketProvider implements TicketProvider {
}
}
private String requestForServiceTicket(final String urlString, final String encodedParams)
throws MalformedURLException, IOException, ProtocolException
private String requestForServiceTicket(final String urlString, final String encodedParams) throws MalformedURLException, IOException, ProtocolException
{
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
final InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream());
@ -150,10 +145,12 @@ public class CASTicketProvider implements TicketProvider {
return connection;
}
private String readFiledGrantingTicket() throws JSCliException {
private void readFiledGrantingTicket() throws JSCliException {
final File file = getTicketFile();
final Properties properties = loadProperties(file);
return properties.getProperty(user);
final String filedTicket = properties.getProperty(user);
grantingTicket = filedTicket;
getTicket();
}
private File getTicketFile() {