Package org.jboss.identity.idm.impl.model.hibernate

Examples of org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject


      if (credential == null)
      {
         throw new IllegalArgumentException();
      }

      HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);

      Session em = getHibernateSession(ctx);

      if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
      {

         HibernateIdentityObjectCredentialType hibernateCredentialType = getHibernateIdentityObjectCredentialType(ctx, credential.getType());

         if (hibernateCredentialType == null)
         {
            throw new IllegalStateException("Credential type not present in this store: " + credential.getType().getName());
         }

         HibernateIdentityObjectCredential hibernateCredential = hibernateObject.getCredential(credential.getType());

         if (hibernateCredential == null)
         {
            hibernateCredential = new HibernateIdentityObjectCredential();
            hibernateCredential.setType(hibernateCredentialType);
            hibernateObject.addCredential(hibernateCredential);
         }


         Object value = null;

         // Handle generic impl

         if (credential.getEncodedValue() != null)
         {
            value = credential.getEncodedValue();
         }
         else
         {
            //TODO: support for empty password should be configurable
            value = credential.getValue();
         }

         if (value instanceof String)
         {
            hibernateCredential.setTextValue(value.toString());
         }
         else if (value instanceof byte[])
         {
            hibernateCredential.setBinaryValue((byte[])value);
         }
         else
         {
            throw new IdentityException("Not supported credential value: " + value.getClass());
         }

         em.persist(hibernateCredential);

         hibernateObject.addCredential(hibernateCredential);

      }
      else
      {
         throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
View Full Code Here


   }

   private HibernateIdentityObject getHibernateIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
   {

      HibernateIdentityObject hibernateObject = null;

      Session em = getHibernateSession(ctx);


      try
View Full Code Here



      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
      {
View Full Code Here

      return io;
   }

   public void removeIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
   {
      HibernateIdentityObject hibernateObject = safeGet(ctx, identity);

      HibernateEntityManager hem = getHibernateEntityManager(ctx);

      try
      {
         // Remove all related relationships
         for (HibernateIdentityObjectRelationship relationship : hibernateObject.getFromRelationships())
         {
            relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
            relationship.getToIdentityObject().getToRelationships().remove(relationship);

            hem.remove(relationship);
         }

         for (HibernateIdentityObjectRelationship relationship : hibernateObject.getToRelationships())
         {
            relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
            relationship.getToIdentityObject().getToRelationships().remove(relationship);

            hem.remove(relationship);
View Full Code Here

      checkIOType(type);

      HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, type);

      HibernateIdentityObject hibernateObject = null;

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      try
      {
View Full Code Here

      if (id == null)
      {
         throw new IllegalArgumentException("id is null");
      }

      HibernateIdentityObject hibernateObject;

      try
      {
         hibernateObject = getHibernateEntityManager(ctx).find(HibernateIdentityObject.class, new Long(id));
      }
View Full Code Here

   @SuppressWarnings("unchecked")
   public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, IdentityObjectSearchControl[] controls) throws IdentityException
   {
      //TODO:test

      HibernateIdentityObject hibernateObject = safeGet(ctx, identity);

      List<IdentityObject> results;

      checkControls(controls);
View Full Code Here

      if (relationshipType == null)
      {
         throw new IllegalArgumentException("RelationshipType is null");
      }

      HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
      HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
      HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);

      if (!getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType))
      {
         throw new IdentityException("Relationship not supported. RelationshipType[ " + relationshipType.getName() + " ] " +
            "beetween: [ " + fromIO.getIdentityType().getName() + " ] and [ " + toIO.getIdentityType().getName() + " ]");
      }

      org.hibernate.Query query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
         .setParameter("fromIO", fromIO)
         .setParameter("toIO", toIO)
View Full Code Here

      if (relationshipType == null)
      {
         throw new IllegalArgumentException("RelationshipType is null");
      }

      HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
      HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
      HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);

      getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType);

      org.hibernate.Query query = null;

      if (name == null)
      {
         query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
            .setParameter("fromIO", fromIO)
            .setParameter("toIO", toIO)
            .setParameter("typeName", type.getName());
      }
      else
      {
         HibernateIdentityObjectRelationshipName relationshipName = (HibernateIdentityObjectRelationshipName)getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name)).uniqueResult();

         if (relationshipName == null)
         {
            throw new IdentityException("Relationship name not present in the store");
         }

         query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
            .setParameter("fromIO", fromIO)
            .setParameter("toIO", toIO)
            .setParameter("typeName", type.getName())
            .setParameter("name", name);
      }


      List results = query.list();

      if (results == null)
      {
         throw new IdentityException("Relationship already present");
      }

      HibernateIdentityObjectRelationship relationship = (HibernateIdentityObjectRelationship)results.iterator().next();     

      fromIO.getFromRelationships().remove(relationship);
      toIO.getToRelationships().remove(relationship);
      getHibernateEntityManager(ctx).remove(relationship);

   }
View Full Code Here

   }

   public void removeRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
   {
      HibernateIdentityObject hio1 = safeGet(ctx, identity1);
      HibernateIdentityObject hio2 = safeGet(ctx, identity2);

      org.hibernate.Query query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_IDENTITIES)
         .setParameter("IO1", hio1)
         .setParameter("IO2", hio2);
View Full Code Here

TOP

Related Classes of org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject

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.