Search in sources :

Example 1 with TokenService

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);
}
Also used : PwmApplication(password.pwm.PwmApplication) TokenPayload(password.pwm.svc.token.TokenPayload) TokenService(password.pwm.svc.token.TokenService)

Aggregations

PwmApplication (password.pwm.PwmApplication)1 TokenPayload (password.pwm.svc.token.TokenPayload)1 TokenService (password.pwm.svc.token.TokenService)1