Exemplo n.º 1
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);
    }
  }
Exemplo n.º 2
0
 /**
  * Returns a map of service names and the related object classes for the given <code>schemaType
  * </code>.
  *
  * @param schemaType name of the schema
  * @return Map of service names and objectclasses
  */
 public Map getServiceNamesAndOCs(String schemaType) {
   if (schemaType == null) {
     schemaType = ALL_SERVICES;
   } else if (schemaType.equalsIgnoreCase("realm")) {
     schemaType = "filteredrole";
   }
   Map answer = (Map) serviceNameAndOCs.get(schemaType);
   if (answer == null) {
     try {
       answer = new HashMap();
       Set sNames = getServiceNames();
       if (sNames != null && !sNames.isEmpty()) {
         Iterator it = sNames.iterator();
         while (it.hasNext()) {
           try {
             String service = (String) it.next();
             ServiceSchemaManagerImpl ssm;
             if (isCoexistenceMode()) {
               // For backward compatibility, get the
               // version from the service.
               // no hardcoding to '1.0', even if it
               // improves performance in OpenSSO.
               // Otherwise, it breaks for services like
               // iplanetAMProviderConfigService with
               // '1.1' as version.
               ssm =
                   ServiceSchemaManagerImpl.getInstance(
                       token, service, serviceDefaultVersion(token, service));
             } else {
               ssm =
                   ServiceSchemaManagerImpl.getInstance(
                       token, service, ServiceManager.getVersion(service));
             }
             if (ssm != null) {
               // Check if service has schemaType
               if (schemaType != null && ssm.getSchema(new SchemaType(schemaType)) == null) {
                 // If the schema type is "User"
                 // check for "Dynamic" also
                 if (schemaType.equalsIgnoreCase(SMSUtils.USER_SCHEMA)
                     && ssm.getSchema(SchemaType.DYNAMIC) == null) {
                   continue;
                 }
                 // If the schema type is "Role:
                 // check for "Dynamic" also
                 if (schemaType.toLowerCase().indexOf("role") != -1
                     && ssm.getSchema(SchemaType.DYNAMIC) == null) {
                   continue;
                 }
               }
               ServiceSchemaImpl ss = ssm.getSchema(SchemaType.GLOBAL);
               if (ss != null) {
                 Map attrs = ss.getAttributeDefaults();
                 if (attrs.containsKey(SERVICE_OC_ATTR_NAME)) {
                   answer.put(service, attrs.get(SERVICE_OC_ATTR_NAME));
                 }
               }
             }
           } catch (SMSException smse) {
             // continue with next service. Best effort to get
             // all service names.
             if (debug.messageEnabled()) {
               debug.message(
                   "ServiceManager.getServiceNamesandOCs" + " caught SMSException ", smse);
             }
           }
         }
       }
       serviceNameAndOCs.put(schemaType, answer);
     } catch (SMSException smse) {
       // ignore
       if (debug.messageEnabled()) {
         debug.message("ServiceManager.getServiceNamesandOCs" + " caught SMSException ", smse);
       }
     } catch (SSOException ssoe) {
       // ignore
       if (debug.messageEnabled()) {
         debug.message("ServiceManager.getServiceNamesandOCs" + " caught SSOException ", ssoe);
       }
     }
   }
   return (SMSUtils.copyAttributes(answer));
 }