gluu
静的公開メンバ関数 | 静的非公開メンバ関数 | 全メンバ一覧
org.xdi.oxd.server.Cli クラス
org.xdi.oxd.server.Cli 連携図
Collaboration graph

静的公開メンバ関数

static void main (String[] args)
 

静的非公開メンバ関数

static void switchOffLogging ()
 
static void tryToConnectToRunningOxd (String oxdId)
 
static void print (String oxdId, Object rp)
 

詳解

著者
yuriyz

関数詳解

◆ main()

static void org.xdi.oxd.server.Cli.main ( String []  args)
inlinestatic
26  {
27 
28  Options options = new Options();
29 
30  Option input = new Option("oxd_id", "oxd_id", true, "oxd_id is unique identifier within oxd database (returned by register_site and setup_client commands)");
31  input.setRequired(true);
32  options.addOption(input);
33 
34  CommandLineParser parser = new DefaultParser();
35  HelpFormatter formatter = new HelpFormatter();
36  CommandLine cmd;
37  String oxdId = null;
39  try {
40  cmd = parser.parse(options, args);
41  oxdId = cmd.getOptionValue("oxd_id");
42 
43  Injector injector = ServerLauncher.getInjector();
44 
45  injector.getInstance(ConfigurationService.class).load();
46  injector.getInstance(PersistenceService.class).create();
47 
48  RpService rpService = injector.getInstance(RpService.class);
49  rpService.load();
50 
51  print(oxdId, rpService.getRp(oxdId));
52  } catch (ParseException e) {
53  System.out.println(e.getMessage());
54  formatter.printHelp("utility-name", options);
55  System.exit(1);
56  } catch (RuntimeException e) {
57  // oxd is running and keeps h2 database locked, so we connect to oxd-server and fetch RP via client connection
59  } catch (Throwable e) {
60  System.out.println("Failed to run oxd CLI (make sure oxd-server was run at least one time and database file is created). Error: " + e.getMessage());
61  e.printStackTrace();
62  System.exit(1);
63  }
64  }
static void tryToConnectToRunningOxd(String oxdId)
Definition: Cli.java:74
static void switchOffLogging()
Definition: Cli.java:66
static void print(String oxdId, Object rp)
Definition: Cli.java:95

◆ print()

static void org.xdi.oxd.server.Cli.print ( String  oxdId,
Object  rp 
)
inlinestaticprivate
95  {
96  if (rp != null) {
97  System.out.println("JSON for oxd_id " + oxdId);
98  System.out.println(rp);
99  } else {
100  System.out.println("No record found in database for oxd_id: " + oxdId);
101  }
102 
103  }

◆ switchOffLogging()

static void org.xdi.oxd.server.Cli.switchOffLogging ( )
inlinestaticprivate
66  {
67  List<Logger> loggers = Collections.<Logger>list(LogManager.getCurrentLoggers());
68  loggers.add(LogManager.getRootLogger());
69  for (Logger logger : loggers) {
70  logger.setLevel(Level.OFF);
71  }
72  }

◆ tryToConnectToRunningOxd()

static void org.xdi.oxd.server.Cli.tryToConnectToRunningOxd ( String  oxdId)
inlinestaticprivate
74  {
75  CommandClient client = null;
76  int port = 8099;
77  try {
78  port = ServerLauncher.getInjector().getInstance(ConfigurationService.class).get().getPort();
79  client = new CommandClient("localhost", port);
80 
81  final Command command = new Command(CommandType.GET_RP);
82  command.setParamsObject(new GetRpParams(oxdId));
83 
84  GetRpResponse resp = client.send(command).dataAsResponse(GetRpResponse.class);
85  print(oxdId, resp.getRp());
86  } catch (IOException e) {
87  System.out.println("Failed to get RP from oxd-server on port " + port + ", error: " + e.getMessage());
88  e.printStackTrace();
89  System.exit(1);
90  } finally {
91  CommandClient.closeQuietly(client);
92  }
93  }
static void print(String oxdId, Object rp)
Definition: Cli.java:95

このクラス詳解は次のファイルから抽出されました: