use of com.sun.security.jgss.AuthorizationDataEntry in project jdk8u_jdk by JetBrains.
the class Context method status.
/**
* Prints status of GSSContext and Subject
* @throws java.lang.Exception
*/
public void status() throws Exception {
System.out.println("STATUS OF " + name.toUpperCase());
try {
StringBuffer sb = new StringBuffer();
if (x.getAnonymityState()) {
sb.append("anon, ");
}
if (x.getConfState()) {
sb.append("conf, ");
}
if (x.getCredDelegState()) {
sb.append("deleg, ");
}
if (x.getIntegState()) {
sb.append("integ, ");
}
if (x.getMutualAuthState()) {
sb.append("mutual, ");
}
if (x.getReplayDetState()) {
sb.append("rep det, ");
}
if (x.getSequenceDetState()) {
sb.append("seq det, ");
}
if (x instanceof ExtendedGSSContext) {
if (((ExtendedGSSContext) x).getDelegPolicyState()) {
sb.append("deleg policy, ");
}
}
System.out.println("Context status of " + name + ": " + sb.toString());
System.out.println(x.getSrcName() + " -> " + x.getTargName());
} catch (Exception e) {
// Don't care
;
}
if (s != null) {
System.out.println("====== START SUBJECT CONTENT =====");
for (Principal p : s.getPrincipals()) {
System.out.println(" Principal: " + p);
}
for (Object o : s.getPublicCredentials()) {
System.out.println(" " + o.getClass());
System.out.println(" " + o);
}
System.out.println("====== Private Credentials Set ======");
for (Object o : s.getPrivateCredentials()) {
System.out.println(" " + o.getClass());
if (o instanceof KerberosTicket) {
KerberosTicket kt = (KerberosTicket) o;
System.out.println(" " + kt.getServer() + " for " + kt.getClient());
} else if (o instanceof KerberosKey) {
KerberosKey kk = (KerberosKey) o;
System.out.print(" " + kk.getKeyType() + " " + kk.getVersionNumber() + " " + kk.getAlgorithm() + " ");
for (byte b : kk.getEncoded()) {
System.out.printf("%02X", b & 0xff);
}
System.out.println();
} else if (o instanceof Map) {
Map map = (Map) o;
for (Object k : map.keySet()) {
System.out.println(" " + k + ": " + map.get(k));
}
} else {
System.out.println(" " + o);
}
}
System.out.println("====== END SUBJECT CONTENT =====");
}
if (x != null && x instanceof ExtendedGSSContext) {
if (x.isEstablished()) {
ExtendedGSSContext ex = (ExtendedGSSContext) x;
Key k = (Key) ex.inquireSecContext(InquireType.KRB5_GET_SESSION_KEY);
if (k == null) {
throw new Exception("Session key cannot be null");
}
System.out.println("Session key is: " + k);
boolean[] flags = (boolean[]) ex.inquireSecContext(InquireType.KRB5_GET_TKT_FLAGS);
if (flags == null) {
throw new Exception("Ticket flags cannot be null");
}
System.out.println("Ticket flags is: " + Arrays.toString(flags));
String authTime = (String) ex.inquireSecContext(InquireType.KRB5_GET_AUTHTIME);
if (authTime == null) {
throw new Exception("Auth time cannot be null");
}
System.out.println("AuthTime is: " + authTime);
if (!x.isInitiator()) {
AuthorizationDataEntry[] ad = (AuthorizationDataEntry[]) ex.inquireSecContext(InquireType.KRB5_GET_AUTHZ_DATA);
System.out.println("AuthzData is: " + Arrays.toString(ad));
}
}
}
}
Aggregations