@AfterClass
 public void cleanup() throws Exception {
   if (orgAliasEnabled) {
     OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
     ocm.deleteSubOrganization(SUB_REALM1.substring(1), true);
   }
 }
Пример #2
0
  @AfterClass
  public void cleanup() throws Exception {
    if (!migrated) {
      return;
    }
    ReferralPrivilegeManager mgr = new ReferralPrivilegeManager(SUB_REALM2, adminSubject);
    mgr.delete(REFERRAL_NAME2);
    mgr = new ReferralPrivilegeManager("/", adminSubject);
    mgr.delete(REFERRAL_NAME1);

    ApplicationManager.deleteApplication(adminSubject, "/", APPL_NAME);
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM1.substring(1);
    ocm.deleteSubOrganization(subRealm, true);
    subRealm = SUB_REALM2.substring(1);
    ocm.deleteSubOrganization(subRealm, true);
    subRealm = SUB_REALM3.substring(1);
    ocm.deleteSubOrganization(subRealm, true);
  }
Пример #3
0
  @AfterClass
  public void cleanup() throws Exception {
    PolicyManager pm = new PolicyManager(adminToken, SUB_REALM1);
    pm.removePolicy(POLICY_NAME);
    pm = new PolicyManager(adminToken, "/");
    pm.removePolicy(REFERRAL_POLICY_NAME1);
    pm.removePolicy(REFERRAL_POLICY_NAME2);

    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM1.substring(1);
    ocm.deleteSubOrganization(subRealm, true);
  }
  @AfterTest
  public void cleanup() throws Exception {
    Set<AMIdentity> identities = new HashSet<AMIdentity>();
    identities.add(delegatedUser);
    identities.add(delegatedUser1);
    IdRepoUtils.deleteIdentities(SUB_REALM, identities);

    ApplicationManager.deleteApplication(
        SubjectUtils.createSuperAdminSubject(), SUB_REALM, APPLICATION_NAME);

    ReferralPrivilegeManager mgr =
        new ReferralPrivilegeManager("/", SubjectUtils.createSuperAdminSubject());
    mgr.remove(REFERRAL_NAME);

    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
    orgMgr.deleteSubOrganization(SUB_REALM, true);
  }
Пример #5
0
  /**
   * Services a Commandline Request.
   *
   * @param rc Request Context.
   * @throws CLIException if the request cannot serviced.
   */
  public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    boolean recursive = isOptionSet(IArgument.RECURSIVE);
    String strRecursive = (recursive) ? "recursive" : "non recursive";

    String[] params = {realm, strRecursive};
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_REALM", params);

    try {
      OrganizationConfigManager ocm = new OrganizationConfigManager(adminSSOToken, realm);
      ocm.deleteSubOrganization(null, recursive);
      getOutputWriter().printlnMessage(getResourceString("delete-realm-succeed"));
      writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_REALM", params);
    } catch (SMSException e) {
      String[] args = {realm, strRecursive, e.getMessage()};
      debugError("DeleteRealm.handleRequest", e);
      writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_REALM", args);
      throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
  }
Пример #6
0
  /** {@inheritDoc} */
  @Override
  public void deleteInstance(
      final ServerContext context,
      final String resourceId,
      final DeleteRequest request,
      final ResultHandler<Resource> handler) {

    RealmContext realmContext = context.asContext(RealmContext.class);
    String realmPath = realmContext.getResolvedRealm();

    boolean recursive = false;
    Resource resource;
    String holdResourceId = checkForTopLevelRealm(resourceId);

    try {
      hasPermission(context);

      if (holdResourceId != null && !holdResourceId.startsWith("/")) {
        holdResourceId = "/" + holdResourceId;
      }
      if (!realmPath.equalsIgnoreCase("/")) {
        holdResourceId = realmPath + holdResourceId;
      }
      OrganizationConfigManager ocm = new OrganizationConfigManager(getSSOToken(), holdResourceId);
      ocm.deleteSubOrganization(null, recursive);
      String principalName = PrincipalRestUtils.getPrincipalNameFromServerContext(context);
      debug.message(
          "RealmResource.deleteInstance :: DELETE of realm "
              + holdResourceId
              + " performed by "
              + principalName);
      // handle resource
      resource = new Resource(resourceId, "0", createJsonMessage("success", "true"));
      handler.handleResult(resource);
    } catch (SMSException smse) {
      try {
        configureErrorMessage(smse);
      } catch (NotFoundException nf) {
        debug.error("RealmResource.deleteInstance() : Cannot find " + resourceId + ":" + smse);
        handler.handleError(nf);
      } catch (ForbiddenException fe) {
        // User does not have authorization
        debug.error("RealmResource.deleteInstance() : Cannot DELETE " + resourceId + ":" + smse);
        handler.handleError(fe);
      } catch (PermanentException pe) {
        debug.error("RealmResource.deleteInstance() : Cannot DELETE " + resourceId + ":" + smse);
        // Cannot recover from this exception
        handler.handleError(pe);
      } catch (ConflictException ce) {
        debug.error("RealmResource.deleteInstance() : Cannot DELETE " + resourceId + ":" + smse);
        handler.handleError(ce);
      } catch (BadRequestException be) {
        debug.error("RealmResource.deleteInstance() : Cannot DELETE " + resourceId + ":" + smse);
        handler.handleError(be);
      } catch (Exception e) {
        handler.handleError(new BadRequestException(e.getMessage(), e));
      }
    } catch (SSOException sso) {
      debug.error("RealmResource.updateInstance() : Cannot DELETE " + resourceId + ":" + sso);
      handler.handleError(new PermanentException(401, "Access Denied", null));
    } catch (ForbiddenException fe) {
      debug.error("RealmResource.updateInstance() : Cannot DELETE " + resourceId + ":" + fe);
      handler.handleError(fe);
    } catch (Exception e) {
      handler.handleError(new BadRequestException(e.getMessage(), e));
    }
  }