Пример #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);
    List<String> appNames = (List) rc.getOption(PARAM_APPL_NAMES);
    String[] param = {realm};
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_APPLICATIONS", param);

    Subject adminSubject = getAdminSubject();
    try {
      for (String a : appNames) {
        ApplicationManager.deleteApplication(adminSubject, "/", a);
      }
      IOutput writer = getOutputWriter();
      writer.printlnMessage(
          MessageFormat.format(
              getResourceString("delete-applications-succeeded"), (Object[]) param));
      writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_DELETE_APPLICATIONS", param);
    } catch (EntitlementException e) {
      String[] params = {realm, e.getMessage()};
      writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_DELETE_APPLICATIONS", params);
      throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
  }
Пример #2
0
  @BeforeClass
  @Override
  public void setup() throws Exception {
    super.setup();
    Application appl =
        ApplicationManager.newApplication(
            "/",
            APPL_NAME,
            ApplicationTypeManager.getAppplicationType(
                adminSubject, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));

    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", true);
    appl.setActions(actions);
    appl.setEntitlementCombiner(DenyOverride.class);

    ApplicationManager.saveApplication(adminSubject, "/", appl);
  }
Пример #3
0
  public void organizationConfigChanged(
      String serviceName,
      String version,
      String orgName,
      String groupName,
      String serviceComponent,
      int type) {
    if (type == ServiceListener.REMOVED) {
      ApplicationManager.clearCache(DNMapper.orgNameToRealmName(orgName));
      try {
        OpenSSOApplicationPrivilegeManager.removeAllPrivileges(orgName);
      } catch (EntitlementException ex) {
        PrivilegeManager.debug.error(
            "SubRealmObserver.organizationConfigChanged: "
                + "Unable to remove application  privileges",
            ex);
      }

      String deletedRealm = DNMapper.orgNameToRealmName(orgName);
      try {
        EntitlementService es = new EntitlementService(deletedRealm);
        Set<String> parentAndPeerRealms = es.getParentAndPeerRealmNames();

        if ((parentAndPeerRealms != null) && !parentAndPeerRealms.isEmpty()) {
          for (String r : parentAndPeerRealms) {
            removeReferrals(r, deletedRealm);
          }
        }

      } catch (EntitlementException ex) {
        PrivilegeManager.debug.error(
            "SubRealmObserver.organizationConfigChanged: " + "Unable to remove referral privileges",
            ex);
      }
    } else if (type == ServiceListener.MODIFIED) {
      ApplicationManager.clearCache(DNMapper.orgNameToRealmName(orgName));
    }
  }
Пример #4
0
 /**
  * Wrapper for the static method {@link ApplicationManager#updateApplication(Application,
  * Application, Subject, String)}.
  *
  * @param oldApplication The (existing) application, to update
  * @param newApplication The new version of the existing application. The name of the new and old
  *     much match.
  * @param subject The subject authorizing the update - will be validated for permission.
  * @param realm The realm in which to update the {@link Application}
  * @throws EntitlementException if there was a problem deleting the old resource
  */
 public void updateApplication(
     Application oldApplication, Application newApplication, Subject subject, String realm)
     throws EntitlementException {
   ApplicationManager.updateApplication(oldApplication, newApplication, subject, realm);
 }
Пример #5
0
 /**
  * Wrapper for the static method {@link
  * ApplicationManager#getApplicationNames(javax.security.auth.Subject, String)}.
  *
  * @param adminSubject An admin-level {@link Subject}.
  * @param realm The realm from which to gather the {@link Application} names.
  * @return a set of names of applications within the given realm
  * @throws EntitlementException if there were problems retrieving the names
  */
 public Set<String> getApplicationNames(Subject adminSubject, String realm)
     throws EntitlementException {
   return ApplicationManager.getApplicationNames(adminSubject, realm);
 }
Пример #6
0
 /**
  * Wrapper for the static method {@link
  * ApplicationManager#getApplication(javax.security.auth.Subject, String, String)}.
  *
  * @param adminSubject An admin-level {@link Subject}.
  * @param realm The realm in which the {@link Application} exists.
  * @param name The name of the {@link Application}
  * @return the Application if found without issue, null otherwise
  * @throws EntitlementException if there were problems retrieving the application
  */
 public Application getApplication(Subject adminSubject, String realm, String name)
     throws EntitlementException {
   return ApplicationManager.getApplication(adminSubject, realm, name);
 }
Пример #7
0
 /**
  * Wrapper for the static method {@link
  * ApplicationManager#deleteApplication(javax.security.auth.Subject, String, String)}.
  *
  * @param adminSubject An admin-level {@link Subject}.
  * @param realm The realm in which to save the {@link Application}
  * @param name The name of the {@link Application}
  * @throws EntitlementException If there was an issue deleting the application
  */
 public void deleteApplication(Subject adminSubject, String realm, String name)
     throws EntitlementException {
   ApplicationManager.deleteApplication(adminSubject, realm, name);
 }
Пример #8
0
 /**
  * Wrapper for the static method {@link ApplicationManager#saveApplication(Subject, String,
  * Application)}.
  *
  * @param adminSubject An admin-level {@link Subject}.
  * @param realm The realm in which to save the {@link Application}
  * @param application The {@link Application} to save
  * @throws EntitlementException If there was an issue saving the application
  */
 public void saveApplication(Subject adminSubject, String realm, Application application)
     throws EntitlementException {
   ApplicationManager.saveApplication(adminSubject, realm, application);
 }
Пример #9
0
 /**
  * Wrapper for the static method {@link ApplicationManager#search(Subject, String, Set)}.
  *
  * @param subject The subject authorizing the update - will be validated for permission.
  * @param realm The realm from which to gather the {@link Application} names.
  * @param searchFilters The constraints that must match Application attribute values.
  * @return the names of those Applications that match the filter.
  * @throws EntitlementException if there were problems retrieving the names
  * @since 12.0.0
  */
 public Set<String> search(Subject subject, String realm, Set<SearchFilter> searchFilters)
     throws EntitlementException {
   return ApplicationManager.search(subject, realm, searchFilters);
 }
Пример #10
0
 @AfterClass
 public void cleanup() throws EntitlementException {
   ApplicationManager.deleteApplication(adminSubject, "/", APPL_NAME);
 }