Skip to content
Snippets Groups Projects
Commit 8d70c71a authored by Wei Liu's avatar Wei Liu
Browse files

Print connection and authentication summary

parent 001067a8
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ import arc.mf.client.ServerRoute;
import arc.utils.AbortableOperationHandler;
import arc.xml.XmlDoc;
import arc.xml.XmlStringWriter;
import unimelb.utils.AnsiColors;
public class MFSession {
......@@ -158,6 +159,7 @@ public class MFSession {
cxn.reconnect(_sessionKey);
} else {
_sessionKey = cxn.connect(authenticationDetails);
printConnectionAndAuthenticationSummary(_rs.connectionDetails(), cxn.authenticationDetails());
_ad = authenticationDetails;
}
updateConfig(_rs.connectionDetails(), cxn.authenticationDetails(), _rs.proxy());
......@@ -169,6 +171,21 @@ public class MFSession {
}
return cxn;
}
private static void printConnectionAndAuthenticationSummary(ConnectionDetails cxnDetails, AuthenticationDetails authDetails) {
StringBuilder sb = new StringBuilder();
sb.append("Connected to ").append(AnsiColors.BLUE).append(cxnDetails.hostName() + ":" + cxnDetails.port()).append(AnsiColors.RESET);
if(authDetails!=null) {
if(authDetails.domain()!=null || authDetails.userName()!=null) {
sb.append(" as ").append(AnsiColors.YELLOW).append(authDetails.domain() + ":" + authDetails.userName()).append(AnsiColors.RESET);
}
if(authDetails.token()!=null) {
sb.append(" with a ").append(AnsiColors.CYAN).append("token").append(AnsiColors.RESET);
}
}
System.out.println(sb.toString());
System.out.println();
}
private void updateConfig(ConnectionDetails connectionDetails, AuthenticationDetails authenticationDetails,
ProxyDetails proxy) {
......@@ -539,6 +556,7 @@ public class MFSession {
ServerClient.Connection c = rs.open();
try {
String sessionKey = c.connect(config.authenticationDetails());
printConnectionAndAuthenticationSummary(rs.connectionDetails(), config.authenticationDetails());
return new MFSession(config, rs, sessionKey);
} finally {
c.close(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment