fix problem storing ticket in .hsadmin.tgt
This commit is contained in:
parent
5b55f7a74c
commit
83968cf292
@ -3,9 +3,8 @@ package de.hsadmin.jscli;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
@ -106,10 +105,6 @@ public class CASTicket {
|
|||||||
if (ticket != null && ticket.startsWith("ST-")) {
|
if (ticket != null && ticket.startsWith("ST-")) {
|
||||||
result = ticket;
|
result = ticket;
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
grantingTicket = getGrantingTicket();
|
|
||||||
writeFiledGrantingTicket(grantingTicket);
|
|
||||||
return getTicket();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
@ -121,8 +116,8 @@ public class CASTicket {
|
|||||||
String userHome = System.getProperty("user.home");
|
String userHome = System.getProperty("user.home");
|
||||||
String ticketFileName = userHome + "/.hsadmin.tgt";
|
String ticketFileName = userHome + "/.hsadmin.tgt";
|
||||||
File file = new File(ticketFileName);
|
File file = new File(ticketFileName);
|
||||||
|
Properties properties = new Properties();
|
||||||
if (file.isFile() && file.canRead()) {
|
if (file.isFile() && file.canRead()) {
|
||||||
Properties properties = new Properties();
|
|
||||||
try {
|
try {
|
||||||
properties.load(new FileReader(file));
|
properties.load(new FileReader(file));
|
||||||
filedTicket = properties.getProperty(user);
|
filedTicket = properties.getProperty(user);
|
||||||
@ -132,24 +127,15 @@ public class CASTicket {
|
|||||||
}
|
}
|
||||||
if (filedTicket == null) {
|
if (filedTicket == null) {
|
||||||
filedTicket = getGrantingTicket();
|
filedTicket = getGrantingTicket();
|
||||||
}
|
if (filedTicket != null) {
|
||||||
return filedTicket;
|
properties.setProperty(user, filedTicket);
|
||||||
}
|
try {
|
||||||
|
properties.store(new FileOutputStream(file), "");
|
||||||
private void writeFiledGrantingTicket(String ticket) throws JSCliException {
|
} catch (IOException e) {
|
||||||
String userHome = System.getProperty("user.home");
|
}
|
||||||
String ticketFileName = userHome + "/.hsadmin.tgt";
|
|
||||||
File file = new File(ticketFileName);
|
|
||||||
if (file.isFile() && file.canWrite()) {
|
|
||||||
Properties properties = new Properties();
|
|
||||||
try {
|
|
||||||
properties.load(new FileReader(file));
|
|
||||||
properties.put(user, ticket);
|
|
||||||
properties.store(new FileWriter(file), "hsscript");
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new JSCliException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return filedTicket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user