Uploaded image for project: 'Seam Security'
  1. Seam Security
  2. SEAMSECURITY-70

Calling RoleManager.removeRole(Roletype rt,User u, Group g) throws an NPE

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.1.0.Beta1
    • Labels:
      None

      Description

      Hi,

      I tried to use the function removeRole(Roletype rt,User u, Group g) of the class RoleManagerImpl which throws me an NullPointerException.

      I have fixed the bug, which was in the class JPAIdentityStore in the method removeRelationship :

      public void removeRelationship(IdentityStoreInvocationContext ctx,
                                         IdentityObject fromIdentity, IdentityObject toIdentity,
                                         IdentityObjectRelationshipType relationshipType,
                                         String relationshipName) throws IdentityException {
              Property<?> fromProperty = modelProperties.get(PROPERTY_RELATIONSHIP_FROM);
              Property<?> toProperty = modelProperties.get(PROPERTY_RELATIONSHIP_TO);
              Property<?> relationshipTypeProp = modelProperties.get(PROPERTY_RELATIONSHIP_TYPE);
       
              EntityManager em = getEntityManager(ctx);
       
              CriteriaBuilder builder = em.getCriteriaBuilder();
              CriteriaQuery<?> criteria = builder.createQuery(identityClass);
              Root<?> root = criteria.from(identityClass);
       
              List<Predicate> predicates = new ArrayList<Predicate>();
              predicates.add(builder.equal(root.get(fromProperty.getName()),
                      lookupIdentity(fromIdentity, em)));
              predicates.add(builder.equal(root.get(toProperty.getName()),
                      lookupIdentity(toIdentity, em)));
              predicates.add(builder.equal(root.get(relationshipTypeProp.getName()),
                      lookupRelationshipType(relationshipType, em)));
       
              criteria.where(predicates.toArray(new Predicate[predicates.size()]));
       
              Object relationship = em.createQuery(criteria).getSingleResult();
              em.remove(relationship);
          }
      

      The bug is due to those following lines :
      CriteriaQuery<?> criteria = builder.createQuery(identityClass);
      Root<?> root = criteria.from(identityClass);
      It should be instead :
      CriteriaQuery<?> criteria = builder.createQuery(relationshipClass);
      Root<?> root = criteria.from(relationshipClass);

        Gliffy Diagrams

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              lightguard Jason Porter
              Reporter:
              poulpe Charles Louppe
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development