示例#1
0
  static void initialize(SSOToken token) throws SMSException, SSOException {
    // Validate SSOToken
    SMSEntry.validateToken(token);

    // Check if already initialized
    if (initialized) return;
    // Initilaize the parameters
    try {
      // Get the service names and cache it
      serviceNames = CachedSubEntries.getInstance(token, serviceDN);
      if (serviceNames.getSMSEntry().isNewEntry()) {
        if (debug.warningEnabled()) {
          debug.warning("SeviceManager:: Root service node " + "does not exists: " + serviceDN);
        }
        String[] msgs = new String[1];
        msgs[0] = serviceDN;
        throw (new SMSException(
            IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.SMS_services_node_does_not_exist, msgs));
      }
    } catch (SMSException e) {
      debug.error("ServiceManager::unable to get " + "services node: " + serviceDN, e);
      throw (e);
    }
    // Check if realm is enabled and set appropriate flags
    checkFlags(token);
    initialized = true;
  }
示例#2
0
 /**
  * Returns all the service names that have been registered.
  *
  * @return the set of names of services that have been registered
  * @throws SMSException if an error occurred while performing the operation
  * @supported.api
  */
 public Set getServiceNames() throws SMSException {
   try {
     if (serviceNames == null) {
       serviceNames = CachedSubEntries.getInstance(token, serviceDN);
     }
     return (serviceNames.getSubEntries(token));
   } catch (SSOException s) {
     debug.error("ServiceManager: Unable to get service names", s);
     throw (new SMSException(s, "sms-service-not-found"));
   }
 }
示例#3
0
 protected static Set getVersions(SSOToken token, String serviceName)
     throws SMSException, SSOException {
   CachedSubEntries sVersions = (CachedSubEntries) serviceVersions.get(serviceName);
   if (sVersions == null) {
     sVersions = CachedSubEntries.getInstance(token, getServiceNameDN(serviceName));
     if (sVersions == null
         || sVersions.getSMSEntry().isNewEntry()
         || sVersions.getSubEntries(token).isEmpty()) {
       String[] msgs = {serviceName};
       throw (new ServiceNotFoundException(
           IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.SMS_service_does_not_exist, msgs));
     }
     serviceVersions.put(serviceName, sVersions);
   }
   return (sVersions.getSubEntries(token));
 }
示例#4
0
  /**
   * Removes all the SMS cached entries. This method should be called to clear the cache for
   * example, if ACIs for the SMS entries are changed in the directory. Also, this clears the SMS
   * entries only in this JVM instance. If multiple instances (of JVM) are running this method must
   * be called within each instance.
   *
   * @supported.api
   */
  public synchronized void clearCache() {
    // Clear the local caches
    serviceNameAndOCs = new CaseInsensitiveHashMap();
    serviceVersions = new CaseInsensitiveHashMap();
    serviceNameDefaultVersion = new CaseInsensitiveHashMap();
    accessManagerServers = null;
    amsdkChecked = false;

    // Call respective Impl classes
    CachedSMSEntry.clearCache();
    CachedSubEntries.clearCache();
    ServiceSchemaManagerImpl.clearCache();
    PluginSchemaImpl.clearCache();
    ServiceInstanceImpl.clearCache();
    ServiceConfigImpl.clearCache();
    ServiceConfigManagerImpl.clearCache();
    OrganizationConfigManagerImpl.clearCache();
    OrgConfigViaAMSDK.clearCache();

    // Re-initialize the flags
    try {
      checkFlags(token);
      OrganizationConfigManager.initializeFlags();
      DNMapper.clearCache();
    } catch (Exception e) {
      debug.error("ServiceManager::clearCache unable to " + "re-initialize global flags", e);
    }
  }
示例#5
0
  /**
   * Returns organization names that match the given attribute name and values. Only exact matching
   * is supported, and if more than one value is provided the organization must have all these
   * values for the attribute. Basically an AND is performed for attribute values for searching.
   *
   * @param serviceName service name under which the attribute is to be sought.
   * @param attrName name of the attribute to search.
   * @param values set of attribute values to search.
   * @return organizations that match the attribute name and values.
   * @throws SMSException if an error occurred while performing the operation.
   * @throws SSOException if the user's single sign on token is invalid or expired.
   */
  public Set searchOrganizationNames(String serviceName, String attrName, Set values)
      throws SMSException, SSOException {

    try {
      if (subEntries == null) {
        subEntries =
            CachedSubEntries.getInstance(
                token, SMSEntry.SERVICES_RDN + SMSEntry.COMMA + SMSEntry.baseDN);
      }
      return (subEntries.searchOrgNames(token, serviceName.toLowerCase(), attrName, values));
    } catch (SSOException ssoe) {
      debug.error("OrganizationConfigManagerImpl: Unable to " + "get sub organization names", ssoe);
      throw (new SMSException(
          SMSEntry.bundle.getString("sms-INVALID_SSO_TOKEN"), "sms-INVALID_SSO_TOKEN"));
    }
  }
示例#6
0
  /**
   * Registers one or more services, defined by the XML input stream that follows the SMS DTD.
   *
   * @param xmlServiceSchema the input stream of service metadata in XML conforming to SMS DTD.
   * @param decryptObj Object to decrypt the password in the XML.
   * @return set of registered service names.
   * @throws SMSException if an error occurred while performing the operation
   * @throws SSOException if the user's single sign on token is invalid or expired.
   */
  public Set registerServices(InputStream xmlServiceSchema, AMEncryption decryptObj)
      throws SMSException, SSOException {
    // Validate SSO Token
    SMSEntry.validateToken(token);
    Set sNames = new HashSet();
    List serviceNodes = new ArrayList();
    // Get the XML document and get the list of service nodes
    Document doc = SMSSchema.getXMLDocument(xmlServiceSchema);

    if (!validSMSDtdDocType(doc)) {
      throw new SMSException(
          IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.SMS_xml_invalid_doc_type, null);
    }

    // Before validating service schema, we need to check
    // for AttributeSchema having the syntax of "password"
    // and if present, encrypt the DefaultValues if any
    checkAndEncryptPasswordSyntax(doc, true, decryptObj);

    // Create service schema
    NodeList nodes = doc.getElementsByTagName(SMSUtils.SERVICE);
    for (int i = 0; (nodes != null) && (i < nodes.getLength()); i++) {
      Node serviceNode = nodes.item(i);
      String name = XMLUtils.getNodeAttributeValue(serviceNode, SMSUtils.NAME);
      String version = XMLUtils.getNodeAttributeValue(serviceNode, SMSUtils.VERSION);

      // Obtain the SMSSchema for Schema and PluginSchema
      SMSSchema smsSchema = new SMSSchema(name, version, doc);

      // Check if the schema element exists
      if (XMLUtils.getChildNode(serviceNode, SMSUtils.SCHEMA) != null) {
        validateServiceSchema(serviceNode);
        ServiceSchemaManager.createService(token, smsSchema);

        // Update the service name and version cached SMSEntry
        if (serviceNames == null) {
          serviceNames = CachedSubEntries.getInstance(token, serviceDN);
        }
        serviceNames.add(name);
        CachedSubEntries sVersions = (CachedSubEntries) serviceVersions.get(name);
        if (sVersions == null) {
          // Not present, hence create it and add it
          sVersions = CachedSubEntries.getInstance(token, getServiceNameDN(name));
          serviceVersions.put(name, sVersions);
        }
        sVersions.add(version);
        sNames.add(name);
      }

      // Check if PluginSchema nodes exists
      for (Iterator pluginNodes =
              XMLUtils.getChildNodes(serviceNode, SMSUtils.PLUGIN_SCHEMA).iterator();
          pluginNodes.hasNext(); ) {
        Node pluginNode = (Node) pluginNodes.next();
        PluginSchema.createPluginSchema(token, pluginNode, smsSchema);
      }

      if (XMLUtils.getChildNode(serviceNode, SMSUtils.CONFIGURATION) != null) {
        serviceNodes.add(serviceNode);
      }
    }

    if (serviceNodes.size() > 0) {
      clearCache();
    }
    /*
     * Need to do this after all the schema has been loaded
     */
    for (Iterator i = serviceNodes.iterator(); i.hasNext(); ) {
      Node svcNode = (Node) i.next();
      String name = XMLUtils.getNodeAttributeValue(svcNode, SMSUtils.NAME);
      String version = XMLUtils.getNodeAttributeValue(svcNode, SMSUtils.VERSION);
      Node configNode = XMLUtils.getChildNode(svcNode, SMSUtils.CONFIGURATION);
      /*
       * Store the configuration, will throw exception if
       * the service configuration already exists
       */
      CreateServiceConfig.createService(this, name, version, configNode, true, decryptObj);
    }
    return sNames;
  }