protected static boolean validateServiceSchema(Node serviceNode) throws SMSException { Node schemaRoot = XMLUtils.getChildNode(serviceNode, SMSUtils.SCHEMA); String[] schemaNames = { SMSUtils.GLOBAL_SCHEMA, SMSUtils.ORG_SCHEMA, SMSUtils.DYNAMIC_SCHEMA, SMSUtils.USER_SCHEMA, SMSUtils.POLICY_SCHEMA, SMSUtils.GROUP_SCHEMA, SMSUtils.DOMAIN_SCHEMA }; for (int i = 0; i < schemaNames.length; i++) { Node childNode = XMLUtils.getChildNode(schemaRoot, schemaNames[i]); if (childNode != null) { ServiceSchemaImpl ssi = new ServiceSchemaImpl(null, childNode); Map attrs = ssi.getAttributeDefaults(); ssi.validateAttributes(attrs, false); } } return (true); }
/** * 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)); }