Пример #1
0
  /**
   * Services a Commandline Request.
   *
   * @param rc Request Context.
   * @throw CLIException if the request cannot serviced.
   */
  @Override
  public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    String name = getStringOptionValue(PARAM_NAME);
    String[] params = {realm, name};

    Subject userSubject = SubjectUtils.createSubject(getAdminSSOToken());
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance(realm, userSubject);
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_APPLICATION_PRIVILEGE", params);

    try {
      ApplicationPrivilege appPrivilege = apm.getPrivilege(name);
      outputInfo("show-application-privilege-output-name", name);
      String description = appPrivilege.getDescription();
      if (description == null) {
        description = "";
      }
      outputInfo("show-application-privilege-output-description", description);
      outputInfo("show-application-privilege-output-actions", getDisplayAction(appPrivilege));
      outputInfo("show-application-privilege-output-subjects", getSubjects(appPrivilege));
      outputInfo(
          "show-application-privilege-output-resources", getApplicationToResources(appPrivilege));
      writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SHOW_APPLICATION_PRIVILEGE", params);
    } catch (EntitlementException ex) {
      String[] paramExs = {realm, name, ex.getMessage()};
      writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_SHOW_APPLICATION_PRIVILEGE", paramExs);
      throw new CLIException(ex, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
  }