use of password.pwm.svc.token.TokenService in project pwm by pwm-project.
the class TokenInfoCommand method doCommand.
public void doCommand() throws Exception {
final String tokenKey = (String) cliEnvironment.getOptions().get(TOKEN_KEY_OPTIONNAME);
final PwmApplication pwmApplication = cliEnvironment.getPwmApplication();
final TokenService tokenService = pwmApplication.getTokenService();
TokenPayload tokenPayload = null;
Exception lookupError = null;
try {
tokenPayload = tokenService.retrieveTokenData(SessionLabel.TOKEN_SESSION_LABEL, tokenKey);
} catch (Exception e) {
lookupError = e;
}
out(" token: " + tokenKey);
if (lookupError != null) {
out("result: error during token lookup: " + lookupError.toString());
} else if (tokenPayload == null) {
out("result: token not found");
} else {
out(" name: " + tokenPayload.getName());
out(" user: " + tokenPayload.getUserIdentity());
out("issued: " + JavaHelper.toIsoDate(tokenPayload.getIssueTime()));
out("expire: " + JavaHelper.toIsoDate(tokenPayload.getExpiration()));
for (final String key : tokenPayload.getData().keySet()) {
final String value = tokenPayload.getData().get(key);
out(" payload key: " + key);
out(" value: " + value);
}
}
pwmApplication.shutdown();
JavaHelper.pause(1000);
}
Aggregations