Package org.jboss.identity.idm.exception

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


         Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
         for (IdentityObjectAttribute entry : leftAttrs)
         {
            if (!supportedAttrs.contains(entry.getName()))
            {
               throw new IdentityException("Cannot update not defined attribute. Use '"
                  + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
                  "Attribute name: " + entry.getName());
            }
         }
         defaultAttributeStore.updateAttributes(defaultCtx, identity, attributesToAdd);
View Full Code Here


         for (IdentityObjectAttribute entry : attributesToAdd)
         {
            // if we hit some unsupported attribute at this stage that we cannot store...
            if (!supportedAttrs.contains(entry.getName()))
            {
               throw new IdentityException("Cannot add not defined attribute. Use '"
                  + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
                  "Attribute name: " + entry.getName());
            }

         }
View Full Code Here

         Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
         for (String name : leftAttrs)
         {
            if (!supportedAttrs.contains(name))
            {
               throw new IdentityException("Cannot remove not defined attribute. Use '"
                  + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
                  "Attribute name: " + name);
            }
         }
         defaultAttributeStore.removeAttributes(defaultCtx, identity, leftAttrs.toArray(new String[leftAttrs.size()]));
View Full Code Here

         {
            String cacheConfig = configurationMD.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);

            if (cacheConfig == null)
            {
               throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing in the repository configuration");
            }

            ClassLoader classLoader = SecurityActions.getContextClassLoader();
            InputStream cacheConfigInputStream = classLoader.getResourceAsStream(cacheConfig);
            if (cacheConfigInputStream == null)
            {
               throw new IdentityException("JBoss Cache config file specified in option \"" + CACHE_CONFIG_FILE_OPTION +
                  "\" doesn't exist: " + cacheConfig);
            }

            defaultIdentityStore = new JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheConfigInputStream);


         }
      }

      for (IdentityStoreMappingMetaData identityStoreMappingMetaData : configurationMD.getIdentityStoreToIdentityObjectTypeMappings())
      {
         String storeId = identityStoreMappingMetaData.getIdentityStoreId();
         List<String> identityObjectTypeMappings = identityStoreMappingMetaData.getIdentityObjectTypeMappings();

         IdentityStore store = bootstrappedIdentityStores.get(storeId);

         String cacheOption = identityStoreMappingMetaData.getOptionSingleValue(CACHE_OPTION);

         if (cacheOption != null && cacheOption.equalsIgnoreCase("true"))
         {
            String cacheConfig = identityStoreMappingMetaData.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);

            if (cacheConfig == null)
            {
               throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing in the repository identity-store-mapping configuration");
            }

            ClassLoader classLoader = SecurityActions.getContextClassLoader();
            InputStream cacheConfigInputStream = classLoader.getResourceAsStream(cacheConfig);
            if (cacheConfigInputStream == null)
            {
               throw new IdentityException("JBoss Cache config file specified in option \"" + CACHE_CONFIG_FILE_OPTION +
                  "\" doesn't exist: " + cacheConfig);
            }


            store = new JBossCacheIdentityStoreWrapper(store, cacheConfigInputStream);
         }

         if (store == null)
         {
            throw new IdentityException("Mapped IdentityStore not available: " + storeId);
         }

         for (String mapping : identityObjectTypeMappings)
         {
            identityStoreMappings.put(mapping, store);
View Full Code Here

   public IdentitySession createIdentitySession(String realmName) throws IdentityException
   {

      if (!sessionContextMap.containsKey(realmName))
      {
         throw new IdentityException("Cannot find configured realm with a given name: " + realmName);
      }

      //IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
      IdentitySessionConfigurationContext sessionConfigCtx = sessionContextMap.get(realmName);
View Full Code Here

         {
            populateRelationshipTypes(hibernateSession, memberships.toArray(new String[memberships.size()]));
         }
         catch (Exception e)
         {
            throw new IdentityException("Failed to populate relationship types", e);
         }


      }

      if (populateIdentityObjectTypes != null && populateIdentityObjectTypes.equalsIgnoreCase("true"))
      {
         List<String> types = new LinkedList<String>();

         for (IdentityObjectTypeMetaData metaData : configurationMD.getSupportedIdentityTypes())
         {
            types.add(metaData.getName());
         }

         try
         {
            populateObjectTypes(hibernateSession, types.toArray(new String[types.size()]));
         }
         catch (Exception e)
         {
            throw new IdentityException("Failed to populate identity object types", e);
         }

      }

      if (supportedCredentialTypes != null && supportedCredentialTypes.size() > 0)
      {
         try
         {
            populateCredentialTypes(hibernateSession, supportedCredentialTypes.toArray(new String[supportedCredentialTypes.size()]));
         }
         catch (Exception e)
         {
            throw new IdentityException("Failed to populated credential types");
         }
      }

      String realmAware = configurationMD.getOptionSingleValue(IS_REALM_AWARE);
View Full Code Here

         {
            return (SessionFactory)new InitialContext().lookup(sfJNDIName);
         }
         catch (NamingException e)
         {
            throw new IdentityException("Cannot obtain hibernate SessionFactory from provided JNDI name: " + sfJNDIName, e);
         }
      }
      else if (sfRegistryName != null)
      {
         Object registryObject = configurationContext.getConfigurationRegistry().getObject(sfRegistryName);

         if (registryObject == null)
         {
            throw new IdentityException("Cannot obtain hibernate SessionFactory from provided registry name: " + sfRegistryName);
         }

         if (!(registryObject instanceof SessionFactory))
         {
            throw new IdentityException("Cannot obtain hibernate SessionFactory from provided registry name: " + sfRegistryName
            + "; Registered object is not an instance of SessionFactory: " + registryObject.getClass().getName());
         }

         return (SessionFactory)registryObject;


      }
      else if (hibernateConfiguration != null)
      {

         try
         {
            AnnotationConfiguration config = new AnnotationConfiguration().configure(hibernateConfiguration);

            //TODO: make it optional to add annotated classes here

            if (addMappedClasses != null && addMappedClasses.equals("false"))
            {
               return config.buildSessionFactory();
            }
            else
            {

               return config.addAnnotatedClass(HibernateIdentityObject.class)
                  .addAnnotatedClass(HibernateIdentityObjectAttribute.class)
                  .addAnnotatedClass(HibernateIdentityObjectBinaryAttribute.class)
                  .addAnnotatedClass(HibernateIdentityObjectBinaryAttributeValue.class)
                  .addAnnotatedClass(HibernateIdentityObjectTextAttribute.class)
                  .addAnnotatedClass(HibernateIdentityObjectCredential.class)
                  .addAnnotatedClass(HibernateIdentityObjectCredentialType.class)
                  .addAnnotatedClass(HibernateIdentityObjectRelationship.class)
                  .addAnnotatedClass(HibernateIdentityObjectRelationshipName.class)
                  .addAnnotatedClass(HibernateIdentityObjectRelationshipType.class)
                  .addAnnotatedClass(HibernateIdentityObjectType.class)
                  .addAnnotatedClass(HibernateRealm.class).buildSessionFactory();
            }
         }
         catch (Exception e)
         {
            throw new IdentityException("Cannot obtain hibernate SessionFactory using provided hibernate configuration: "+ hibernateConfiguration, e);
         }

      }
      throw new IdentityException("Cannot obtain hibernate SessionFactory. None of supported options specified: "
         + HIBERNATE_SESSION_FACTORY_JNDI_NAME + ", " + HIBERNATE_SESSION_FACTORY_REGISTRY_NAME + ", " + HIBERNATE_CONFIGURATION);


   }
View Full Code Here

      {
         return new HibernateIdentityStoreSessionImpl(sessionFactory);
      }
      catch (Exception e)
      {
         throw new IdentityException("Failed to obtain Hibernate SessionFactory",e);
      }
   }
View Full Code Here

         .setParameter("typeName", identityObjectType.getName())
        .list();

      if (results.size() != 0)
      {
         throw new IdentityException("IdentityObject already present in this IdentityStore:" +
            "name=" + name + "; type=" + identityObjectType.getName() + "; realm=" + realm);
      }

      HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityObjectType);

      HibernateIdentityObject io = new HibernateIdentityObject(name, hibernateType, realm);

      if (attributes != null)
      {
         for (Map.Entry<String, String[]> entry : attributes.entrySet())
         {
            io.addTextAttribute(entry.getKey(), entry.getValue());
         }
      }

      try
      {
         getHibernateSession(ctx).persist(io);
      }
      catch (Exception e)
      {
         throw new IdentityException("Cannot persist new IdentityObject" + io, e);
      }


      return io;
   }
View Full Code Here

         hibernateSession.delete(hibernateObject);
      }
      catch (Exception e)
      {
         throw new IdentityException("Cannot remove IdentityObject" + identity, e);
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.identity.idm.exception.IdentityException

Copyright © 2018 www.massapicom. 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.