コード例 #1
0
ファイル: ServiceManager.java プロジェクト: aldaris/opensso
  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
ファイル: ServiceManager.java プロジェクト: aldaris/opensso
 /**
  * Removes the service schema and configuration for the given service name.
  *
  * @param serviceName the name of the service
  * @param version the version of the service
  * @throws SMSException if an error occurred while performing the operation
  * @throws SSOException if the user's single sign on token is invalid or expired
  * @supported.api
  */
 public void removeService(String serviceName, String version) throws SMSException, SSOException {
   // Find all service entries that have the DN
   // Search for (&(ou=<serviceName>)(objectclass=top))
   // construct the rdn with the given version, look for the entry
   // in iDS and if entry exists(service with that version), delete.
   if (serviceName.equalsIgnoreCase(IdConstants.REPO_SERVICE)
       || serviceName.equalsIgnoreCase(ISAuthConstants.AUTH_SERVICE_NAME)) {
     Object args[] = {serviceName};
     throw (new SMSException(
         IUMSConstants.UMS_BUNDLE_NAME, "sms-SERVICE_CORE_CANNOT_DELETE", args));
   }
   SMSEntry.validateToken(token);
   String[] objs = {serviceName};
   Iterator results =
       SMSEntry.search(
               token,
               SMSEntry.baseDN,
               MessageFormat.format(SMSEntry.FILTER_PATTERN, (Object[]) objs),
               0,
               0,
               false,
               false)
           .iterator();
   while (results.hasNext()) {
     String dn = (String) results.next();
     String configdn = SMSEntry.PLACEHOLDER_RDN + SMSEntry.EQUALS + version + SMSEntry.COMMA + dn;
     CachedSMSEntry configsmse = CachedSMSEntry.getInstance(token, configdn);
     if (configsmse.isDirty()) {
       configsmse.refresh();
     }
     SMSEntry confige = configsmse.getClonedSMSEntry();
     if (!confige.isNewEntry()) {
       confige.delete(token);
       configsmse.refresh(confige);
     }
     // If there are no other service version nodes for that service,
     // delete that node(schema).
     CachedSMSEntry smse = CachedSMSEntry.getInstance(token, dn);
     if (smse.isDirty()) {
       smse.refresh();
     }
     SMSEntry e = smse.getSMSEntry();
     Iterator versions = e.subEntries(token, "*", 0, false, false).iterator();
     if (!versions.hasNext()) {
       e.delete(token);
       smse.refresh(e);
     }
   }
 }
コード例 #3
0
ファイル: ServiceManager.java プロジェクト: aldaris/opensso
  /**
   * Deletes only the schema for the given service name. This is provided only for backward
   * compatibility for DSAME 5.0 and will be deprecated in the future release. Alternative is to use
   * <code>ServiceSchemaManager.replaceSchema()</code>.
   *
   * @param serviceName Name of service to be deleted.
   * @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 void deleteService(String serviceName) throws SMSException, SSOException {
    if (serviceName.equalsIgnoreCase(IdConstants.REPO_SERVICE)
        || serviceName.equalsIgnoreCase(ISAuthConstants.AUTH_SERVICE_NAME)) {
      Object args[] = {serviceName};
      throw (new SMSException(
          IUMSConstants.UMS_BUNDLE_NAME, "sms-SERVICE_CORE_CANNOT_DELETE", args));
    }

    Iterator versions = getServiceVersions(serviceName).iterator();
    while (versions.hasNext()) {
      String version = (String) versions.next();
      CachedSMSEntry ce = CachedSMSEntry.getInstance(token, getServiceNameDN(serviceName, version));
      if (ce.isDirty()) {
        ce.refresh();
      }
      SMSEntry e = ce.getClonedSMSEntry();
      String[] values = {SMSSchema.getDummyXML(serviceName, version)};
      e.setAttribute(SMSEntry.ATTR_SCHEMA, values);
      e.save(token);
      ce.refresh(e);
    }
  }
コード例 #4
0
ファイル: ServiceManager.java プロジェクト: aldaris/opensso
  /**
   * 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;
  }