|
@@ -500,6 +500,22 @@ public final class SmRestClientBuilder {
|
|
return token;
|
|
return token;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String getNewToken() {
|
|
|
|
+ byte[] tokenN = initiateSecurityContext(getSubj(), getServerRealm());
|
|
|
|
+
|
|
|
|
+ for(int times = 0; null == tokenN && times < 3; ++times) {
|
|
|
|
+ SmRestClientBuilder.LOG.error("InitiateSecurityContext again.");
|
|
|
|
+ tokenN = initiateSecurityContext(getSubj(), getServerRealm());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null == tokenN) {
|
|
|
|
+ throw new IllegalArgumentException("Get security token failed.");
|
|
|
|
+ } else {
|
|
|
|
+ //this.createSTTime = System.currentTimeMillis();
|
|
|
|
+ return new String(Base64.getEncoder().encode(tokenN), StandardCharsets.UTF_8);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private static GSSContext getGssContext(String servicePrincipalName) throws GSSException {
|
|
private static GSSContext getGssContext(String servicePrincipalName) throws GSSException {
|
|
GSSManager manager = GSSManager.getInstance();
|
|
GSSManager manager = GSSManager.getInstance();
|
|
GSSName serverName = manager.createName(servicePrincipalName, new Oid("1.2.840.113554.1.2.2.1"));
|
|
GSSName serverName = manager.createName(servicePrincipalName, new Oid("1.2.840.113554.1.2.2.1"));
|