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