Examples of IdentityConfigurationException


Examples of org.jboss.identity.idm.common.exception.IdentityConfigurationException

         jiElement = (JAXBElement<JbossIdentityType>)unMarshaller.unmarshal(configInputStream);
      }
      catch (JAXBException e)
      {
         throw new IdentityConfigurationException("Cannot unmarshal xml configuration: ", e);
      }

      JbossIdentityType identityConfig = jiElement.getValue();

      IdentityConfigurationMetaDataImpl configurationMD = new IdentityConfigurationMetaDataImpl();
View Full Code Here

Examples of org.jboss.identity.idm.common.exception.IdentityConfigurationException

      // IdentityStore

      if (configurationMD.getRepositories() == null || configurationMD.getIdentityStores().size() == 0)
      {
         throw new IdentityConfigurationException("No identity-store configured");
      }

      // Helper structure to keep track of all IdentityObjectType mappings in stores
      Map<String, Set<String>> storeObjectTypeNameMappings = new HashMap<String, Set<String>>();

      for (IdentityStoreConfigurationMetaData storeMD : configurationMD.getIdentityStores())
      {

         // id
         if (storeMD.getId() == null || storeMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store name required");
         }

         // Helper structure containing all configured identity object type names

         Set<String> storeObjectTypeNames = new HashSet<String>();
         if (storeMD.getSupportedIdentityTypes() != null)
         {
            for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
            {
               storeObjectTypeNames.add(typeMD.getName());
            }
         }

         storeObjectTypeNameMappings.put(storeMD.getId(), storeObjectTypeNames);

         // className
         if (storeMD.getClassName() == null || storeMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" class name required");
         }

         // supported relationship types are not required but we gather the names to check consistency in other parts

         Set<String> supportedRelTypes = new HashSet<String>();
         if (storeMD.getSupportedRelationshipTypes() != null)
         {
            supportedRelTypes = new HashSet<String>(storeMD.getSupportedRelationshipTypes());
         }

         // all configured identity object types
//         if (storeMD.getSupportedIdentityTypes() == null || storeMD.getSupportedIdentityTypes().size() == 0)
//         {
//            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" doesn't have any supported " +
//               "identity-object-types configured");
//         }

         // check each configured types
         for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
         {
            // Name
            if (typeMD.getName() == null || typeMD.getName().length() == 0)
            {
               throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" identity-object-type name" +
                  "is not specified");
            }

            // Attributes

            if (typeMD.getAttributes() != null)
            {
               for (IdentityObjectAttributeMetaData attrMD : typeMD.getAttributes())
               {
                  // Name
                  if (attrMD.getName() == null || attrMD.getName().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute name not specified in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (attrMD.getType() == null || attrMD.getType().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute type not specified for attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!attributeTypes.contains(attrMD.getType()))
                  {
                     throw new IdentityConfigurationException("Unsupported attribute type in attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

               }
            }

            // Relationships

            if (typeMD.getRelationships() != null)
            {
               for (RelationshipMetaData relMD : typeMD.getRelationships())
               {
                  if (relMD.getIdentityObjectTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!storeObjectTypeNames.contains(relMD.getIdentityObjectTypeRef()))
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref contains " +
                        "not configured name \"" + relMD.getIdentityObjectTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (relMD.getRelationshipTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("relationship-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!supportedRelTypes.contains(relMD.getRelationshipTypeRef()))
                  {
                     throw new IdentityConfigurationException("relationship-type-ref name is not supported" +
                        "by identity-store. Relationship name \"" + relMD.getRelationshipTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }
               }
            }
         }
      }

      // Helper structures

      Set<String> configuredRepoNames = new HashSet<String>();

      Map<String, Set<String>> repoObjectTypeNamesMappings = new HashMap<String, Set<String>>();

      // IdentityStoreRepository

      if (configurationMD.getRepositories() == null || configurationMD.getRepositories().size() == 0)
      {
         throw new IdentityConfigurationException("No IdentityRepository configured");
      }

      for (IdentityRepositoryConfigurationMetaData repoMD : configurationMD.getRepositories())
      {
         Set<String> repoObjectNames = new HashSet<String>();

         // id
         if (repoMD.getId() == null || repoMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("repository name is required");
         }

         configuredRepoNames.add(repoMD.getId());

         // className
         if (repoMD.getClassName() == null || repoMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("repository \"" + repoMD.getId() + "\" class name required");
         }

         // defaultAttributeStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-attribute-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultAttributeStoreId()))
         {
            throw new IdentityConfigurationException("default-attribute-store \"" + repoMD.getDefaultAttributeStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

         // defaultIdentityStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-identity-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultIdentityStoreId()))
         {
            throw new IdentityConfigurationException("default-identity-store \"" + repoMD.getDefaultIdentityStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

        

//         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings() == null ||
//            repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
//         {
//            throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
//         }

         // If there are no repo mappings then add all mappings from the default store
         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
         {
            Set<String> names = storeObjectTypeNameMappings.get(repoMD.getDefaultIdentityStoreId());
            repoObjectTypeNamesMappings.put(repoMD.getId(), names);
         }

         for (IdentityStoreMappingMetaData mappingsMD : repoMD.getIdentityStoreToIdentityObjectTypeMappings())
         {
            if (mappingsMD.getIdentityStoreId() == null ||
               mappingsMD.getIdentityStoreId().length() == 0)
            {
               throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
            }

            if (!storeObjectTypeNameMappings.containsKey(mappingsMD.getIdentityStoreId()))
            {
               throw new IdentityConfigurationException("Store with id from identity-store-id \"" + mappingsMD.getIdentityStoreId() +
                  "in identity-store-mapping in repository \"" + repoMD.getId() + "\" is not present in configuration");
            }

            if (mappingsMD.getIdentityObjectTypeMappings() == null ||
               mappingsMD.getIdentityObjectTypeMappings().size() == 0)
            {
               throw new IdentityConfigurationException("identity-store-mapping with \"" + mappingsMD.getIdentityStoreId() +
                  "in repository \"" + repoMD.getId() + "\" doesn't have any identity-object-types listed");
            }

            for (String identityTypeName : mappingsMD.getIdentityObjectTypeMappings())
            {
               Set<String> validNames = storeObjectTypeNameMappings.get(mappingsMD.getIdentityStoreId());

               if (!validNames.contains(identityTypeName))
               {
                  throw new IdentityConfigurationException("identity-object-type \"" + identityTypeName + "\" specified in " +
                     "identity-store-mapping in repository \"" + repoMD.getId() + "\" is not configured in specified " +
                     "identity-store");
               }

               repoObjectNames.add(identityTypeName);
            }
         }

         repoObjectTypeNamesMappings.put(repoMD.getId(), repoObjectNames);
      }


      // Realms

      if (configurationMD.getRealms() == null || configurationMD.getRealms().size() == 0)
      {
         throw new IdentityConfigurationException("No realm configured");
      }

      for (RealmConfigurationMetaData realmMD : configurationMD.getRealms())
      {
         if (realmMD.getId() == null || realmMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("realm id is missing");
         }

         if (realmMD.getIdentityRepositoryIdRef() == null || realmMD.getIdentityRepositoryIdRef().length() == 0)
         {
            throw new IdentityConfigurationException("repository-id-ref in realm \"" + realmMD.getId() + "\" is missing");
         }

         if (!configuredRepoNames.contains(realmMD.getIdentityRepositoryIdRef()))
         {
            throw new IdentityConfigurationException("repository-id-ref \"" + realmMD.getIdentityRepositoryIdRef() +
               "\" in realm \"" + realmMD.getId() + "\" doesn't reference configured repository");
         }

         if (realmMD.getIdentityMapping() == null || realmMD.getIdentityMapping().length() == 0)
         {
            throw new IdentityConfigurationException("identity-mapping in realm \"" + realmMD.getId() + "\" is missing");
         }

         // Group type mappings are not required
         if (realmMD.getGroupTypeMappings() != null )
         {
            Set<String> validNames = repoObjectTypeNamesMappings.get(realmMD.getIdentityRepositoryIdRef());

            for (String typeName : realmMD.getGroupTypeMappings().values())
            {
               if (!validNames.contains(typeName))
               {
                  throw new IdentityConfigurationException("identity-object-type-name in realm \"" + realmMD.getId() + "\" " +
                     "doesn't reference identity-object-type configured in repository \"" + realmMD.getIdentityRepositoryIdRef() +
                  "\"");

               }
            }
View Full Code Here

Examples of org.jboss.identity.idm.common.exception.IdentityConfigurationException

   {
      Map<String, IdentitySessionConfigurationContext> realmMap = null;

      if (configMD == null)
      {
         throw new IdentityConfigurationException("Failed to build IdentitySessionFactory. Configuration not initialized");
      }

      try
      {
         realmMap = createRealmMap(configMD);
      }
      catch (Exception e)
      {
         throw new IdentityConfigurationException("Failed to build IdentitySessionFactory", e);
      }

      return new IdentitySessionFactoryImpl(realmMap);
   }
View Full Code Here

Examples of org.jboss.identity.idm.exception.IdentityConfigurationException

         jiElement = (JAXBElement<JbossIdentityType>)unMarshaller.unmarshal(configInputStream);
      }
      catch (JAXBException e)
      {
         throw new IdentityConfigurationException("Cannot unmarshal xml configuration: ", e);
      }

      JbossIdentityType identityConfig = jiElement.getValue();

      IdentityConfigurationMetaDataImpl configurationMD = new IdentityConfigurationMetaDataImpl();
View Full Code Here

Examples of org.jboss.identity.idm.exception.IdentityConfigurationException

      // IdentityStore

      if (configurationMD.getRepositories() == null || configurationMD.getIdentityStores().size() == 0)
      {
         throw new IdentityConfigurationException("No identity-store configured");
      }

      // Helper structure to keep track of all IdentityObjectType mappings in stores
      Map<String, Set<String>> storeObjectTypeNameMappings = new HashMap<String, Set<String>>();

      for (IdentityStoreConfigurationMetaData storeMD : configurationMD.getIdentityStores())
      {

         // id
         if (storeMD.getId() == null || storeMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store name required");
         }

         // Helper structure containing all configured identity object type names

         Set<String> storeObjectTypeNames = new HashSet<String>();
         if (storeMD.getSupportedIdentityTypes() != null)
         {
            for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
            {
               storeObjectTypeNames.add(typeMD.getName());
            }
         }

         storeObjectTypeNameMappings.put(storeMD.getId(), storeObjectTypeNames);

         // className
         if (storeMD.getClassName() == null || storeMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" class name required");
         }

         // supported relationship types are not required but we gather the names to check consistency in other parts

         Set<String> supportedRelTypes = new HashSet<String>();
         if (storeMD.getSupportedRelationshipTypes() != null)
         {
            supportedRelTypes = new HashSet<String>(storeMD.getSupportedRelationshipTypes());
         }

         // all configured identity object types
         if (storeMD.getSupportedIdentityTypes() == null || storeMD.getSupportedIdentityTypes().size() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" doesn't have any supported " +
               "identity-object-types configured");
         }

         // check each configured types
         for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
         {
            // Name
            if (typeMD.getName() == null || typeMD.getName().length() == 0)
            {
               throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" identity-object-type name" +
                  "is not specified");
            }

            // Attributes

            if (typeMD.getAttributes() != null)
            {
               for (IdentityObjectAttributeMetaData attrMD : typeMD.getAttributes())
               {
                  // Name
                  if (attrMD.getName() == null || attrMD.getName().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute name not specified in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (attrMD.getType() == null || attrMD.getType().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute type not specified for attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!attributeTypes.contains(attrMD.getType()))
                  {
                     throw new IdentityConfigurationException("Unsupported attribute type in attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

               }
            }

            // Relationships

            if (typeMD.getRelationships() != null)
            {
               for (RelationshipMetaData relMD : typeMD.getRelationships())
               {
                  if (relMD.getIdentityObjectTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!storeObjectTypeNames.contains(relMD.getIdentityObjectTypeRef()))
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref contains " +
                        "not configured name \"" + relMD.getIdentityObjectTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (relMD.getRelationshipTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("relationship-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!supportedRelTypes.contains(relMD.getRelationshipTypeRef()))
                  {
                     throw new IdentityConfigurationException("relationship-type-ref name is not supported" +
                        "by identity-store. Relationship name \"" + relMD.getRelationshipTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }
               }
            }
         }
      }

      // Helper structures

      Set<String> configuredRepoNames = new HashSet<String>();

      Map<String, Set<String>> repoObjectTypeNamesMappings = new HashMap<String, Set<String>>();

      // IdentityStoreRepository

      if (configurationMD.getRepositories() == null || configurationMD.getRepositories().size() == 0)
      {
         throw new IdentityConfigurationException("No IdentityRepository configured");
      }

      for (IdentityRepositoryConfigurationMetaData repoMD : configurationMD.getRepositories())
      {
         Set<String> repoObjectNames = new HashSet<String>();

         // id
         if (repoMD.getId() == null || repoMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("repository name is required");
         }

         configuredRepoNames.add(repoMD.getId());

         // className
         if (repoMD.getClassName() == null || repoMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("repository \"" + repoMD.getId() + "\" class name required");
         }

         // defaultAttributeStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-attribute-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultAttributeStoreId()))
         {
            throw new IdentityConfigurationException("default-attribute-store \"" + repoMD.getDefaultAttributeStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

         // defaultIdentityStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-identity-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultIdentityStoreId()))
         {
            throw new IdentityConfigurationException("default-identity-store \"" + repoMD.getDefaultIdentityStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

        

//         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings() == null ||
//            repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
//         {
//            throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
//         }

         // If there are no repo mappings then add all mappings from the default store
         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
         {
            Set<String> names = storeObjectTypeNameMappings.get(repoMD.getDefaultIdentityStoreId());
            repoObjectTypeNamesMappings.put(repoMD.getId(), names);
         }

         for (IdentityStoreMappingMetaData mappingsMD : repoMD.getIdentityStoreToIdentityObjectTypeMappings())
         {
            if (mappingsMD.getIdentityStoreId() == null ||
               mappingsMD.getIdentityStoreId().length() == 0)
            {
               throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
            }

            if (!storeObjectTypeNameMappings.containsKey(mappingsMD.getIdentityStoreId()))
            {
               throw new IdentityConfigurationException("Store with id from identity-store-id \"" + mappingsMD.getIdentityStoreId() +
                  "in identity-store-mapping in repository \"" + repoMD.getId() + "\" is not present in configuration");
            }

            if (mappingsMD.getIdentityObjectTypeMappings() == null ||
               mappingsMD.getIdentityObjectTypeMappings().size() == 0)
            {
               throw new IdentityConfigurationException("identity-store-mapping with \"" + mappingsMD.getIdentityStoreId() +
                  "in repository \"" + repoMD.getId() + "\" doesn't have any identity-object-types listed");
            }

            for (String identityTypeName : mappingsMD.getIdentityObjectTypeMappings())
            {
               Set<String> validNames = storeObjectTypeNameMappings.get(mappingsMD.getIdentityStoreId());

               if (!validNames.contains(identityTypeName))
               {
                  throw new IdentityConfigurationException("identity-object-type \"" + identityTypeName + "\" specified in " +
                     "identity-store-mapping in repository \"" + repoMD.getId() + "\" is not configured in specified " +
                     "identity-store");
               }

               repoObjectNames.add(identityTypeName);
            }
         }

         repoObjectTypeNamesMappings.put(repoMD.getId(), repoObjectNames);
      }


      // Realms

      if (configurationMD.getRealms() == null || configurationMD.getRealms().size() == 0)
      {
         throw new IdentityConfigurationException("No realm configured");
      }

      for (RealmConfigurationMetaData realmMD : configurationMD.getRealms())
      {
         if (realmMD.getId() == null || realmMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("realm id is missing");
         }

         if (realmMD.getIdentityRepositoryIdRef() == null || realmMD.getIdentityRepositoryIdRef().length() == 0)
         {
            throw new IdentityConfigurationException("repository-id-ref in realm \"" + realmMD.getId() + "\" is missing");
         }

         if (!configuredRepoNames.contains(realmMD.getIdentityRepositoryIdRef()))
         {
            throw new IdentityConfigurationException("repository-id-ref \"" + realmMD.getIdentityRepositoryIdRef() +
               "\" in realm \"" + realmMD.getId() + "\" doesn't reference configured repository");
         }

         if (realmMD.getIdentityMapping() == null || realmMD.getIdentityMapping().length() == 0)
         {
            throw new IdentityConfigurationException("identity-mapping in realm \"" + realmMD.getId() + "\" is missing");
         }

         // Group type mappings are not required
         if (realmMD.getGroupTypeMappings() != null )
         {
            Set<String> validNames = repoObjectTypeNamesMappings.get(realmMD.getIdentityRepositoryIdRef());

            for (String typeName : realmMD.getGroupTypeMappings().values())
            {
               if (!validNames.contains(typeName))
               {
                  throw new IdentityConfigurationException("identity-object-type-name in realm \"" + realmMD.getId() + "\" " +
                     "doesn't reference identity-object-type configured in repository \"" + realmMD.getIdentityRepositoryIdRef() +
                  "\"");

               }
            }
View Full Code Here

Examples of org.jboss.identity.idm.exception.IdentityConfigurationException

         jiElement = (JAXBElement<JbossIdentityType>)unMarshaller.unmarshal(configInputStream);
      }
      catch (JAXBException e)
      {
         throw new IdentityConfigurationException("Cannot unmarshal xml configuration: ", e);
      }

      JbossIdentityType identityConfig = jiElement.getValue();

      IdentityConfigurationMetaDataImpl configurationMD = new IdentityConfigurationMetaDataImpl();
View Full Code Here

Examples of org.jboss.identity.idm.exception.IdentityConfigurationException

      // IdentityStore

      if (configurationMD.getRepositories() == null || configurationMD.getIdentityStores().size() == 0)
      {
         throw new IdentityConfigurationException("No identity-store configured");
      }

      // Helper structure to keep track of all IdentityObjectType mappings in stores
      Map<String, Set<String>> storeObjectTypeNameMappings = new HashMap<String, Set<String>>();

      for (IdentityStoreConfigurationMetaData storeMD : configurationMD.getIdentityStores())
      {

         // id
         if (storeMD.getId() == null || storeMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store name required");
         }

         // Helper structure containing all configured identity object type names

         Set<String> storeObjectTypeNames = new HashSet<String>();
         if (storeMD.getSupportedIdentityTypes() != null)
         {
            for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
            {
               storeObjectTypeNames.add(typeMD.getName());
            }
         }

         storeObjectTypeNameMappings.put(storeMD.getId(), storeObjectTypeNames);

         // className
         if (storeMD.getClassName() == null || storeMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" class name required");
         }

         // supported relationship types are not required but we gather the names to check consistency in other parts

         Set<String> supportedRelTypes = new HashSet<String>();
         if (storeMD.getSupportedRelationshipTypes() != null)
         {
            supportedRelTypes = new HashSet<String>(storeMD.getSupportedRelationshipTypes());
         }

         // all configured identity object types
         if (storeMD.getSupportedIdentityTypes() == null || storeMD.getSupportedIdentityTypes().size() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" doesn't have any supported " +
               "identity-object-types configured");
         }

         // check each configured types
         for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
         {
            // Name
            if (typeMD.getName() == null || typeMD.getName().length() == 0)
            {
               throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" identity-object-type name" +
                  "is not specified");
            }

            // Attributes

            if (typeMD.getAttributes() != null)
            {
               for (IdentityObjectAttributeMetaData attrMD : typeMD.getAttributes())
               {
                  // Name
                  if (attrMD.getName() == null || attrMD.getName().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute name not specified in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (attrMD.getType() == null || attrMD.getType().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute type not specified for attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!attributeTypes.contains(attrMD.getType()))
                  {
                     throw new IdentityConfigurationException("Unsupported attribute type in attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

               }
            }

            // Relationships

            if (typeMD.getRelationships() != null)
            {
               for (RelationshipMetaData relMD : typeMD.getRelationships())
               {
                  if (relMD.getIdentityObjectTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!storeObjectTypeNames.contains(relMD.getIdentityObjectTypeRef()))
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref contains " +
                        "not configured name \"" + relMD.getIdentityObjectTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (relMD.getRelationshipTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("relationship-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!supportedRelTypes.contains(relMD.getRelationshipTypeRef()))
                  {
                     throw new IdentityConfigurationException("relationship-type-ref name is not supported" +
                        "by identity-store. Relationship name \"" + relMD.getRelationshipTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }
               }
            }
         }
      }

      // Helper structures

      Set<String> configuredRepoNames = new HashSet<String>();

      Map<String, Set<String>> repoObjectTypeNamesMappings = new HashMap<String, Set<String>>();

      // IdentityStoreRepository

      if (configurationMD.getRepositories() == null || configurationMD.getRepositories().size() == 0)
      {
         throw new IdentityConfigurationException("No IdentityRepository configured");
      }

      for (IdentityRepositoryConfigurationMetaData repoMD : configurationMD.getRepositories())
      {
         Set<String> repoObjectNames = new HashSet<String>();

         // id
         if (repoMD.getId() == null || repoMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("repository name is required");
         }

         configuredRepoNames.add(repoMD.getId());

         // className
         if (repoMD.getClassName() == null || repoMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("repository \"" + repoMD.getId() + "\" class name required");
         }

         // defaultAttributeStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-attribute-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultAttributeStoreId()))
         {
            throw new IdentityConfigurationException("default-attribute-store \"" + repoMD.getDefaultAttributeStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

         // defaultIdentityStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-identity-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultIdentityStoreId()))
         {
            throw new IdentityConfigurationException("default-identity-store \"" + repoMD.getDefaultIdentityStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

        

//         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings() == null ||
//            repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
//         {
//            throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
//         }

         // If there are no repo mappings then add all mappings from the default store
         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
         {
            Set<String> names = storeObjectTypeNameMappings.get(repoMD.getDefaultIdentityStoreId());
            repoObjectTypeNamesMappings.put(repoMD.getId(), names);
         }

         for (IdentityStoreMappingMetaData mappingsMD : repoMD.getIdentityStoreToIdentityObjectTypeMappings())
         {
            if (mappingsMD.getIdentityStoreId() == null ||
               mappingsMD.getIdentityStoreId().length() == 0)
            {
               throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
            }

            if (!storeObjectTypeNameMappings.containsKey(mappingsMD.getIdentityStoreId()))
            {
               throw new IdentityConfigurationException("Store with id from identity-store-id \"" + mappingsMD.getIdentityStoreId() +
                  "in identity-store-mapping in repository \"" + repoMD.getId() + "\" is not present in configuration");
            }

            if (mappingsMD.getIdentityObjectTypeMappings() == null ||
               mappingsMD.getIdentityObjectTypeMappings().size() == 0)
            {
               throw new IdentityConfigurationException("identity-store-mapping with \"" + mappingsMD.getIdentityStoreId() +
                  "in repository \"" + repoMD.getId() + "\" doesn't have any identity-object-types listed");
            }

            for (String identityTypeName : mappingsMD.getIdentityObjectTypeMappings())
            {
               Set<String> validNames = storeObjectTypeNameMappings.get(mappingsMD.getIdentityStoreId());

               if (!validNames.contains(identityTypeName))
               {
                  throw new IdentityConfigurationException("identity-object-type \"" + identityTypeName + "\" specified in " +
                     "identity-store-mapping in repository \"" + repoMD.getId() + "\" is not configured in specified " +
                     "identity-store");
               }

               repoObjectNames.add(identityTypeName);
            }
         }

         repoObjectTypeNamesMappings.put(repoMD.getId(), repoObjectNames);
      }


      // Realms

      if (configurationMD.getRealms() == null || configurationMD.getRealms().size() == 0)
      {
         throw new IdentityConfigurationException("No realm configured");
      }

      for (RealmConfigurationMetaData realmMD : configurationMD.getRealms())
      {
         if (realmMD.getId() == null || realmMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("realm id is missing");
         }

         if (realmMD.getIdentityRepositoryIdRef() == null || realmMD.getIdentityRepositoryIdRef().length() == 0)
         {
            throw new IdentityConfigurationException("repository-id-ref in realm \"" + realmMD.getId() + "\" is missing");
         }

         if (!configuredRepoNames.contains(realmMD.getIdentityRepositoryIdRef()))
         {
            throw new IdentityConfigurationException("repository-id-ref \"" + realmMD.getIdentityRepositoryIdRef() +
               "\" in realm \"" + realmMD.getId() + "\" doesn't reference configured repository");
         }

         if (realmMD.getIdentityMapping() == null || realmMD.getIdentityMapping().length() == 0)
         {
            throw new IdentityConfigurationException("identity-mapping in realm \"" + realmMD.getId() + "\" is missing");
         }

         // Group type mappings are not required
         if (realmMD.getGroupTypeMappings() != null )
         {
            Set<String> validNames = repoObjectTypeNamesMappings.get(realmMD.getIdentityRepositoryIdRef());

            for (String typeName : realmMD.getGroupTypeMappings().values())
            {
               if (!validNames.contains(typeName))
               {
                  throw new IdentityConfigurationException("identity-object-type-name in realm \"" + realmMD.getId() + "\" " +
                     "doesn't reference identity-object-type configured in repository \"" + realmMD.getIdentityRepositoryIdRef() +
                  "\"");

               }
            }
View Full Code Here

Examples of org.jboss.identity.idm.exception.IdentityConfigurationException

   {
      Map<String, IdentitySessionConfigurationContext> realmMap = null;

      if (configMD == null)
      {
         throw new IdentityConfigurationException("Failed to build IdentitySessionFactory. Configuration not initialized");
      }

      try
      {
         realmMap = createRealmMap(configMD);
      }
      catch (Exception e)
      {
         throw new IdentityConfigurationException("Failed to build IdentitySessionFactory", e);
      }

      return new IdentitySessionFactoryImpl(realmMap);
   }
View Full Code Here

Examples of org.jboss.identity.idm.spi.exception.IdentityConfigurationException

         jiElement = (JAXBElement<JbossIdentityType>)unMarshaller.unmarshal(xmlConfig);
      }
      catch (JAXBException e)
      {
         throw new IdentityConfigurationException("Cannot unmarshal xml configuration: ", e);
      }

      JbossIdentityType identityConfig = jiElement.getValue();

      IdentityConfigurationMetaDataImpl configurationMD = new IdentityConfigurationMetaDataImpl();
View Full Code Here

Examples of org.jboss.identity.idm.spi.exception.IdentityConfigurationException

      // IdentityStore

      if (configurationMD.getRepositories() == null || configurationMD.getIdentityStores().size() == 0)
      {
         throw new IdentityConfigurationException("No identity-store configured");
      }

      // Helper structure to keep track of all IdentityObjectType mappings in stores
      Map<String, Set<String>> storeObjectTypeNameMappings = new HashMap<String, Set<String>>();

      for (IdentityStoreConfigurationMetaData storeMD : configurationMD.getIdentityStores())
      {

         // id
         if (storeMD.getId() == null || storeMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store name required");
         }

         // Helper structure containing all configured identity object type names

         Set<String> storeObjectTypeNames = new HashSet<String>();
         if (storeMD.getSupportedIdentityTypes() != null)
         {
            for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
            {
               storeObjectTypeNames.add(typeMD.getName());
            }
         }

         storeObjectTypeNameMappings.put(storeMD.getId(), storeObjectTypeNames);

         // className
         if (storeMD.getClassName() == null || storeMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" class name required");
         }

         // supported relationship types are not required but we gather the names to check consistency in other parts

         Set<String> supportedRelTypes = new HashSet<String>();
         if (storeMD.getSupportedRelationshipTypes() != null)
         {
            supportedRelTypes = new HashSet<String>(storeMD.getSupportedRelationshipTypes());
         }

         // all configured identity object types
         if (storeMD.getSupportedIdentityTypes() == null || storeMD.getSupportedIdentityTypes().size() == 0)
         {
            throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" doesn't have any supported " +
               "identity-object-types configured");
         }

         // check each configured types
         for (IdentityObjectTypeMetaData typeMD : storeMD.getSupportedIdentityTypes())
         {
            // Name
            if (typeMD.getName() == null || typeMD.getName().length() == 0)
            {
               throw new IdentityConfigurationException("identity-store \"" + storeMD.getId() + "\" identity-object-type name" +
                  "is not specified");
            }

            // Attributes

            if (typeMD.getAttributes() != null)
            {
               for (IdentityObjectAttributeMetaData attrMD : typeMD.getAttributes())
               {
                  // Name
                  if (attrMD.getName() == null || attrMD.getName().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute name not specified in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (attrMD.getType() == null || attrMD.getType().length() == 0)
                  {
                     throw new IdentityConfigurationException("Attribute type not specified for attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!attributeTypes.contains(attrMD.getType()))
                  {
                     throw new IdentityConfigurationException("Unsupported attribute type in attribute \"" + attrMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

               }
            }

            // Relationships

            if (typeMD.getRelationships() != null)
            {
               for (RelationshipMetaData relMD : typeMD.getRelationships())
               {
                  if (relMD.getIdentityObjectTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!storeObjectTypeNames.contains(relMD.getIdentityObjectTypeRef()))
                  {
                     throw new IdentityConfigurationException("identity-object-type-ref contains " +
                        "not configured name \"" + relMD.getIdentityObjectTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (relMD.getRelationshipTypeRef() == null)
                  {
                     throw new IdentityConfigurationException("relationship-type-ref not specified" +
                        "in identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }

                  if (!supportedRelTypes.contains(relMD.getRelationshipTypeRef()))
                  {
                     throw new IdentityConfigurationException("relationship-type-ref name is not supported" +
                        "by identity-store. Relationship name \"" + relMD.getRelationshipTypeRef() + "\" in " +
                        "identity-object-type \"" + typeMD.getName()
                        + "\" in identity-store \"" + storeMD.getId() + "\"");
                  }
               }
            }
         }
      }

      // Helper structures

      Set<String> configuredRepoNames = new HashSet<String>();

      Map<String, Set<String>> repoObjectTypeNamesMappings = new HashMap<String, Set<String>>();

      // IdentityStoreRepository

      if (configurationMD.getRepositories() == null || configurationMD.getRepositories().size() == 0)
      {
         throw new IdentityConfigurationException("No IdentityRepository configured");
      }

      for (IdentityRepositoryConfigurationMetaData repoMD : configurationMD.getRepositories())
      {
         Set<String> repoObjectNames = new HashSet<String>();

         // id
         if (repoMD.getId() == null || repoMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("repository name is required");
         }

         configuredRepoNames.add(repoMD.getId());

         // className
         if (repoMD.getClassName() == null || repoMD.getClassName().length() == 0)
         {
            throw new IdentityConfigurationException("repository \"" + repoMD.getId() + "\" class name required");
         }

         // defaultAttributeStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-attribute-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultAttributeStoreId()))
         {
            throw new IdentityConfigurationException("default-attribute-store \"" + repoMD.getDefaultAttributeStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

         // defaultIdentityStore
         if (repoMD.getDefaultAttributeStoreId() == null || repoMD.getDefaultAttributeStoreId().length() == 0)
         {
            throw new IdentityConfigurationException("default-identity-store in repository \"" + repoMD.getId() + "\" is required");
         }

         if (!storeObjectTypeNameMappings.containsKey(repoMD.getDefaultIdentityStoreId()))
         {
            throw new IdentityConfigurationException("default-identity-store \"" + repoMD.getDefaultIdentityStoreId() +
               "in repository \"" + repoMD.getId() + "\" is not present in configuration");
         }

        

//         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings() == null ||
//            repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
//         {
//            throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
//         }

         // If there are no repo mappings then add all mappings from the default store
         if (repoMD.getIdentityStoreToIdentityObjectTypeMappings().size() == 0)
         {
            Set<String> names = storeObjectTypeNameMappings.get(repoMD.getDefaultIdentityStoreId());
            repoObjectTypeNamesMappings.put(repoMD.getId(), names);
         }

         for (IdentityStoreMappingMetaData mappingsMD : repoMD.getIdentityStoreToIdentityObjectTypeMappings())
         {
            if (mappingsMD.getIdentityStoreId() == null ||
               mappingsMD.getIdentityStoreId().length() == 0)
            {
               throw new IdentityConfigurationException("No identity-store-mappings defined in repository \"" + repoMD.getId() + "\"");
            }

            if (!storeObjectTypeNameMappings.containsKey(mappingsMD.getIdentityStoreId()))
            {
               throw new IdentityConfigurationException("Store with id from identity-store-id \"" + mappingsMD.getIdentityStoreId() +
                  "in identity-store-mapping in repository \"" + repoMD.getId() + "\" is not present in configuration");
            }

            if (mappingsMD.getIdentityObjectTypeMappings() == null ||
               mappingsMD.getIdentityObjectTypeMappings().size() == 0)
            {
               throw new IdentityConfigurationException("identity-store-mapping with \"" + mappingsMD.getIdentityStoreId() +
                  "in repository \"" + repoMD.getId() + "\" doesn't have any identity-object-types listed");
            }

            for (String identityTypeName : mappingsMD.getIdentityObjectTypeMappings())
            {
               Set<String> validNames = storeObjectTypeNameMappings.get(mappingsMD.getIdentityStoreId());

               if (!validNames.contains(identityTypeName))
               {
                  throw new IdentityConfigurationException("identity-object-type \"" + identityTypeName + "\" specified in " +
                     "identity-store-mapping in repository \"" + repoMD.getId() + "\" is not configured in specified " +
                     "identity-store");
               }

               repoObjectNames.add(identityTypeName);
            }
         }

         repoObjectTypeNamesMappings.put(repoMD.getId(), repoObjectNames);
      }


      // Realms

      if (configurationMD.getRealms() == null || configurationMD.getRealms().size() == 0)
      {
         throw new IdentityConfigurationException("No realm configured");
      }

      for (RealmConfigurationMetaData realmMD : configurationMD.getRealms())
      {
         if (realmMD.getId() == null || realmMD.getId().length() == 0)
         {
            throw new IdentityConfigurationException("realm id is missing");
         }

         if (realmMD.getIdentityRepositoryIdRef() == null || realmMD.getIdentityRepositoryIdRef().length() == 0)
         {
            throw new IdentityConfigurationException("repository-id-ref in realm \"" + realmMD.getId() + "\" is missing");
         }

         if (!configuredRepoNames.contains(realmMD.getIdentityRepositoryIdRef()))
         {
            throw new IdentityConfigurationException("repository-id-ref \"" + realmMD.getIdentityRepositoryIdRef() +
               "\" in realm \"" + realmMD.getId() + "\" doesn't reference configured repository");
         }

         if (realmMD.getIdentityMapping() == null || realmMD.getIdentityMapping().length() == 0)
         {
            throw new IdentityConfigurationException("identity-mapping in realm \"" + realmMD.getId() + "\" is missing");
         }

         // Group type mappings are not required
         if (realmMD.getGroupTypeMappings() != null )
         {
            Set<String> validNames = repoObjectTypeNamesMappings.get(realmMD.getIdentityRepositoryIdRef());

            for (String typeName : realmMD.getGroupTypeMappings().values())
            {
               if (!validNames.contains(typeName))
               {
                  throw new IdentityConfigurationException("identity-object-type-name in realm \"" + realmMD.getId() + "\" " +
                     "doesn't reference identity-object-type configured in repository \"" + realmMD.getIdentityRepositoryIdRef() +
                  "\"");

               }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.