@Override public boolean use(InputLine inputLine) throws Exception { CommonCommands commands = null; if (inputLine.hasArg(CLIENTS)) { commands = getNewClientStoreCommands(); } if (inputLine.hasArg(CLIENT_APPROVALS)) { commands = getNewClientApprovalStoreCommands(); } if (inputLine.hasArg(COPY)) { commands = getNewCopyCommands(); } if (commands != null) { CLIDriver cli = new CLIDriver(commands); cli.start(); return true; } if (super.use(inputLine)) { return true; } return false; }
@Override public boolean use(InputLine inputLine) throws Exception { CommonCommands commands = null; if (inputLine.hasArg(ADMINS)) { commands = getAdminClientCommands(); } if (inputLine.hasArg(KEYS)) { commands = new SigningCommands(getOA2SE()); } if (inputLine.hasArg(PERMISSIONS)) { commands = getPermissionCommands(); } if (commands != null) { CLIDriver cli = new CLIDriver(commands); cli.start(); return true; } if (super.use(inputLine)) { return true; } return false; } }
public void create_hash(InputLine inputLine) { if (showHelp(inputLine)) { showCreateHashHelp(); return; } String secret = null; if (inputLine.hasArg("-file")) { try { FileReader fis = new FileReader(inputLine.getArg(1 + inputLine.indexOf("-file"))); StringBuffer sb = new StringBuffer(); int i; while ((i = fis.read()) != -1) { sb.append((char) i); } fis.close(); secret = sb.toString(); } catch (Throwable t) { say("Error: could not read file: " + t.getMessage()); return; } } else { secret = inputLine.getLastArg(); } say("creating hash of " + secret); say(DigestUtils.sha1Hex(secret)); }
@Override public boolean use(InputLine inputLine) throws Exception { String indent = " "; if (inputLine.hasArg("test")) { OA2TestCommands usc = new OA2TestCommands(getMyLogger(), (ClientEnvironment) getEnvironment()); CLIDriver cli = new CLIDriver(usc); cli.start(); return true; } return false; } }
if (inputLine.hasArg(LIST_KEYS_FLAG)) { if (getStore().getXMLConverter() instanceof MapConverter) { say("keys"); if (inputLine.hasArg(KEY_FLAG)) { String key = inputLine.getNextArgFor(KEY_FLAG); if (!keys.allKeys().contains(key)) { values = getStore().search(key, inputLine.getLastArg(), inputLine.hasArg(REGEX_FLAG)); }catch(Throwable t){ say("Sorry, that didn't work:" + t.getMessage()); say("no matches"); if (inputLine.hasArg(SIZE_FLAG)) { say("Got " + values.size() + " results"); return; if (inputLine.hasArg(LONG_LIST_FLAG)) { longFormat(identifiable); } else {
return; if(inputLine.hasArg("-file")) {
public void getat(InputLine inputLine) throws Exception { /* if(!canGetAT){ say("Sorry, but you have not gotten a grant yet here, so you cannot get an access token."); }*/ if (grant == null || showHelp(inputLine)) { getATHelp(); return; } currentATResponse = getOA2S().getAccessToken(getDummyAsset(), grant); Object x = currentATResponse.getParameters().get(RAW_ID_TOKEN); if (x == null) { x = ""; } else { rawIdToken = x.toString(); } claims = (JSONObject) currentATResponse.getParameters().get(ID_TOKEN); if (inputLine.hasArg(CLAIMS_FLAG)) { if (claims.isEmpty()) { say("(no claims found)"); } else { say(claims.toString(2)); } } printTokens(); }
public void validate_token(InputLine inputLine) throws Exception { if (showHelp(inputLine)) { printValidateTokenHelp(); return; } String token = null; if (1 == inputLine.size()) { say("Sorry, no argument"); return; } if (inputLine.hasArg("-file")) { token = getArgValue(inputLine, "-file"); } else { token = inputLine.getArg(1); } String[] x = decat(token); JSONObject h = JSONObject.fromObject(new String(Base64.decodeBase64(x[0]))); JSONObject p = JSONObject.fromObject(new String(Base64.decodeBase64(x[1]))); say("header=" + h); say("payload=" + p); if (JWTUtil.verify(h, p, x[2], keys.get(defaultKeyID))) { say("token valid!"); } else { say("could not validate token"); } } }
OutputStream os = System.out; boolean hasFile = false; if (inputLine.hasArg("-file")) { try { os = new FileOutputStream(inputLine.getNextArgFor("-file"));
if (inputLine.hasArg("-keys")) { String fileName = getArgValue(inputLine, "-keys"); File f = new File(fileName); if (inputLine.hasArg("-id")) { localDefaultID = getArgValue(inputLine, "-id"); } else { if (inputLine.hasArg("-file")) { claims = JSONObject.fromObject(readFile(getArgValue(inputLine, "-file"))); } else {
public void getrt(InputLine inputLine) throws Exception { if (showHelp(inputLine)) { getRTHelp(); return; } RTResponse rtResponse = getOA2S().refresh(dummyAsset.getIdentifier().toString()); dummyAsset = (OA2Asset) getCe().getAssetStore().get(dummyAsset.getIdentifier().toString()); // Have to update the AT reponse here every time or no token state is preserved. currentATResponse = new ATResponse2(dummyAsset.getAccessToken(), dummyAsset.getRefreshToken()); currentATResponse.setParameters(rtResponse.getParameters()); JSONObject json = JSONObject.fromObject(currentATResponse.getParameters()); claims = json; if (inputLine.hasArg(CLAIMS_FLAG)) { if (json.isEmpty()) { say("(no claims found)"); } else { say(json.toString(2)); } } printTokens(); }