Exemplo n.º 1
0
  /**
   * Returns the organization DN.
   *
   * <p>If the organization name matches the root suffix or has the root suffix in it then the DN
   * will be returned as string. Otherwise the DN will be constructed from the organization Name DN
   * and the root suffix DN.
   *
   * @param userOrg Organization Name
   * @return Organization DN of the organization
   */
  public String getOrgDN(String userOrg) {
    DN userOrgDN = new DN(userOrg);
    DN rootSuffixDN = new DN(rootSuffix);
    String orgDN = null;

    if (debug.messageEnabled()) {
      debug.message("userOrg is : " + userOrg);
      debug.message("rootSuffix is : " + rootSuffix);
      debug.message("rootSuffixDN is : " + rootSuffixDN);
      debug.message("userOrgDN is : " + userOrgDN);
    }

    if ((userOrgDN.equals(rootSuffixDN)) || (userOrgDN.isDescendantOf(rootSuffixDN))) {
      orgDN = userOrgDN.toString();
    } else {
      orgDN =
          (new StringBuffer(50))
              .append(userOrgDN.toString())
              .append(",")
              .append(rootSuffixDN)
              .toString();
    }

    if (debug.messageEnabled()) {
      debug.message("Returning OrgDN is : " + orgDN);
    }
    return orgDN.toString();
  }
Exemplo n.º 2
0
  private void initAuthSessions() throws SSOException, SessionException {
    if (authSession == null) {
      authSession = getSS().getAuthenticationSession(defaultOrg, null);
      if (authSession == null) {
        debug.error("AuthD failed to get auth session");
        throw new SessionException(BUNDLE_NAME, "gettingSessionFailed", null);
      }

      String clientID = authSession.getClientID();
      authSession.setProperty("Principal", clientID);
      authSession.setProperty("Organization", defaultOrg);
      authSession.setProperty("Host", authSession.getID().getSessionServer());
      DN dn = new DN(clientID);
      if (dn.isDN()) {
        String[] tokens = dn.explodeDN(true);
        String id = "id=" + tokens[0] + ",ou=user," + ServiceManager.getBaseDN();
        authSession.setProperty(Constants.UNIVERSAL_IDENTIFIER, id);
      }
      SSOTokenManager ssoManager = SSOTokenManager.getInstance();
      ssoAuthSession = ssoManager.createSSOToken(authSession.getID().toString());
    }
  }
Exemplo n.º 3
0
  /**
   * Gets the Organization DN for the specified entryDN. If the entry itself is an org, then same DN
   * is returned.
   *
   * <p><b>NOTE:</b> This method will involve serveral directory searches, hence be cautious of
   * Performance hit.
   *
   * <p>This method does not call its base classes method unlike the rest of the overriden methods
   * to obtain the organization DN, as it requires special processing requirements.
   *
   * @param token a valid SSOToken
   * @param entryDN the entry whose parent Organization is to be obtained
   * @return the DN String of the parent Organization
   * @throws AMException if an error occured while obtaining the parent Organization
   */
  public String getOrganizationDN(SSOToken token, String entryDN) throws AMException {
    DN dnObject = new DN(entryDN);
    if (entryDN.length() == 0 || !dnObject.isDN()) {
      getDebug().error("CachedRemoteServicesImpl.getOrganizationDN() " + "Invalid DN: " + entryDN);
      throw new AMException(token, "157");
    }

    String organizationDN = "";
    Set childDNSet = new HashSet();
    boolean errorCondition = false;
    boolean found = false;
    while (!errorCondition && !found) {
      boolean lookupDirectory = true;
      String childDN = dnObject.toRFCString().toLowerCase();
      if (getDebug().messageEnabled()) {
        getDebug()
            .message(
                "CachedRemoteServicesImpl."
                    + "getOrganizationDN() - looping Organization DN for"
                    + " entry: "
                    + childDN);
      }

      CacheBlock cb = (CacheBlock) sdkCache.get(childDN);
      if (cb != null) {
        organizationDN = cb.getOrganizationDN();
        if (organizationDN != null) {
          if (getDebug().messageEnabled()) {
            getDebug()
                .message(
                    "CachedRemoteServicesImpl."
                        + "getOrganizationDN(): found OrganizationDN: "
                        + organizationDN
                        + " for: "
                        + childDN);
          }
          found = true;
          setOrganizationDNs(organizationDN, childDNSet);
          continue;
        } else if (cb.getObjectType() == AMObject.ORGANIZATION
            || cb.getObjectType() == AMObject.ORGANIZATIONAL_UNIT) {
          // Object type is organization
          organizationDN = childDN;
          found = true;
          childDNSet.add(childDN);
          setOrganizationDNs(organizationDN, childDNSet);
          continue;
        } else if (cb.getObjectType() != AMObject.UNDETERMINED_OBJECT_TYPE) {
          // Don't lookup directory if the object type is unknown
          lookupDirectory = false;
        }
      }
      childDNSet.add(childDN);
      if (lookupDirectory) {
        organizationDN = super.verifyAndGetOrgDN(token, entryDN, childDN);
      }
      if (organizationDN != null && organizationDN.length() > 0) {
        found = true;
        setOrganizationDNs(organizationDN, childDNSet);
      } else if (dnObject.countRDNs() == 1) { // Reached topmost level
        errorCondition = true;
        getDebug()
            .error(
                "CachedRemoteServicesImpl."
                    + "getOrganizationDN(): Reached root suffix. Unable to"
                    + " get parent Org");
      } else { // Climb tree on level up
        dnObject = dnObject.getParent();
      }
    }
    return organizationDN;
  }