Examples of LDAPIdentityObjectImpl


Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

      if (log.isLoggable(Level.FINER))
      {
         log.finer(toString() + ".removeIdentityObject: " + identity);
      }

      LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(invocationCtx, identity);

      String dn = ldapIdentity.getDn();

      if (dn == null)
      {
         throw new IdentityException("Cannot obtain DN of identity");
      }
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

      //TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?



      LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, identity);

      LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx, identity.getIdentityType());

      LdapContext ldapContext = getLDAPContext(ctx);

      List<IdentityObject> objects = new LinkedList<IdentityObject>();

      try
      {

         // If parent simply look for all its members
         if (parent)
         {
            if (typeConfig.getMembershipAttributeName() == null)
            {
               throw new IdentityException("Membership attribute name not configured. Given IdentityObjectType cannot have" +
                  "members: " + identity.getIdentityType().getName());
            }

            Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
            Attribute member = attrs.get(typeConfig.getMembershipAttributeName());

            if (member != null)
            {
               NamingEnumeration memberValues = member.getAll();
               while (memberValues.hasMoreElements())
               {
                  String memberRef = memberValues.nextElement().toString();

                  if (typeConfig.isMembershipAttributeDN())
                  {
                     //TODO: use direct LDAP query instaed of other find method and add attributesFilter

                     if (constraints != null && constraints.getFilter() != null)
                     {
                        String name = Tools.stripDnToName(memberRef);
                        String regex = Tools.wildcardToRegex(constraints.getFilter());

                        if (Pattern.matches(regex, name))
                        {
                           objects.add(findIdentityObject(ctx, memberRef));
                        }
                     }
                     else
                     {
                        objects.add(findIdentityObject(ctx, memberRef));
                     }
                  }
                  else
                  {
                     //TODO: if relationships are not refered with DNs and only names its not possible to map
                     //TODO: them to proper IdentityType and keep name uniqnes per type. Workaround needed
                     throw new NotYetImplementedException("LDAP limitation. If relationship targets are not refered with FQDNs " +
                        "and only names, it's not possible to map them to proper IdentityType and keep name uniqnes per type. " +
                        "Workaround needed");
                  }
                  //break;
               }
            }
         }

         // if not parent then all parent entries need to be found
         else
         {
            // Search in all other type contexts
            for (IdentityObjectType parentType : configuration.getConfiguredTypes())
            {
               checkIOType(parentType);

               LDAPIdentityObjectTypeConfiguration parentTypeConfiguration = getTypeConfiguration(ctx, parentType);

               List<String> allowedTypes = Arrays.asList(parentTypeConfiguration.getAllowedMembershipTypes());

               // Check if given identity type can be parent
               if (!allowedTypes.contains(identity.getIdentityType().getName()))
               {
                  continue;
               }

               String nameFilter = "*";

               //Filter by name
               if (constraints != null && constraints.getFilter() != null)
               {
                  nameFilter = constraints.getFilter();
               }

               Control[] requestControls = null;

               StringBuilder af = new StringBuilder();

               // Filter by attribute values
               if (constraints != null && constraints.isFiltered())
               {
                  af.append("(&");

                  for (Map.Entry<String, String[]> stringEntry : constraints.getValues().entrySet())
                  {
                     for (String value : stringEntry.getValue())
                     {
                        af.append("(")
                           .append(stringEntry.getKey())
                           .append("=")
                           .append(value)
                           .append(")");
                     }
                  }

                  af.append(")");
               }

               // Add filter to search only parents of the given entry
               af.append("(")
                  .append(parentTypeConfiguration.getMembershipAttributeName())
                  .append("=");
               if (parentTypeConfiguration.isMembershipAttributeDN())
               {
                  af.append(ldapFromIO.getDn());
               }
               else
               {
                  //TODO: this doesn't make much sense unless parent/child are same identity types and resides in the same LDAP context
                  af.append(ldapFromIO.getName());
               }
               af.append(")");


               String filter = parentTypeConfiguration.getEntrySearchFilter();
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

   {
      //TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?



      LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identity);

      LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx, identity.getIdentityType());

      LdapContext ldapContext = getLDAPContext(ctx);

      Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();

      try
      {

         // If parent simply look for all its members
         if (parent)
         {
            Attributes attrs = ldapContext.getAttributes(ldapIO.getDn());
            Attribute member = attrs.get(typeConfig.getMembershipAttributeName());

            if (member != null)
            {
               NamingEnumeration memberValues = member.getAll();
               while (memberValues.hasMoreElements())
               {
                  String memberRef = memberValues.nextElement().toString();

                  if (typeConfig.isMembershipAttributeDN())
                  {
                     //TODO: use direct LDAP query instaed of other find method and add attributesFilter


                     relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapIO, findIdentityObject(ctx, memberRef)));

                  }
                  else
                  {
                     //TODO: if relationships are not refered with DNs and only names its not possible to map
                     //TODO: them to proper IdentityType and keep name uniqnes per type. Workaround needed
                     throw new NotYetImplementedException("LDAP limitation. If relationship targets are not refered with FQDNs " +
                        "and only names, it's not possible to map them to proper IdentityType and keep name uniqnes per type. " +
                        "Workaround needed");
                  }
                  //break;
               }
            }
         }

         // if not parent then all parent entries need to be found
         else
         {
            // Search in all other type contexts
            for (IdentityObjectType parentType : configuration.getConfiguredTypes())
            {
               checkIOType(parentType);

               LDAPIdentityObjectTypeConfiguration parentTypeConfiguration = getTypeConfiguration(ctx, parentType);

               List<String> allowedTypes = Arrays.asList(parentTypeConfiguration.getAllowedMembershipTypes());

               // Check if given identity type can be parent
               if (!allowedTypes.contains(identity.getIdentityType().getName()))
               {
                  continue;
               }

               String nameFilter = "*";

               //Filter by name
               Control[] requestControls = null;

               StringBuilder af = new StringBuilder();


               // Add filter to search only parents of the given entry
               af.append("(")
                  .append(parentTypeConfiguration.getMembershipAttributeName())
                  .append("=");
               if (parentTypeConfiguration.isMembershipAttributeDN())
               {
                  af.append(ldapIO.getDn());
               }
               else
               {
                  //TODO: this doesn't make much sense unless parent/child are same identity types and resides in the same LDAP context
                  af.append(ldapIO.getName());
               }
               af.append(")");


               String filter = parentTypeConfiguration.getEntrySearchFilter();
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

         );
      }

      LDAPIdentityObjectRelationshipImpl relationship = null;

      LDAPIdentityObjectImpl ldapFromIO =  getSafeLDAPIO(ctx, fromIdentity);

      LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);

      LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());

      LdapContext ldapContext = getLDAPContext(ctx);

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

      try
      {
         // Construct new member attribute values
         Attributes attrs = new BasicAttributes(true);

         Attribute member = new BasicAttribute(fromTypeConfig.getMembershipAttributeName());

         if (fromTypeConfig.isMembershipAttributeDN())
         {
            member.add(ldapToIO.getDn());
         }
         else
         {
            member.add(toIdentity.getName());
         }
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

            + "; toIdentity: " + toIdentity
            + "; relationshipType: " + relationshipType
         );
      }

      LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
      LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);

      LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());

      // If relationship is not allowed simply return
      //TODO: use features description instead
      if (!Arrays.asList(fromTypeConfig.getAllowedMembershipTypes()).contains(ldapToIO.getIdentityType().getName()))
      {
         return;
      }

      LdapContext ldapContext = getLDAPContext(ctx);

      // Check posibilities

      //TODO: null RelationshipType passed from removeRelationships
      if (relationshipType != null &&
         !getSupportedFeatures().isRelationshipTypeSupported(fromIdentity.getIdentityType(), toIdentity.getIdentityType(), relationshipType))
      {
         throw new IdentityException("Relationship not supported");
      }

      try
      {
         //construct new member attribute values
         Attributes attrs = new BasicAttributes(true);

         Attribute member = new BasicAttribute(fromTypeConfig.getMembershipAttributeName());

         if (fromTypeConfig.isMembershipAttributeDN())
         {
            member.add(ldapToIO.getDn());
         }
         else
         {
            member.add(toIdentity.getName());
         }
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

         );
      }

      Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();

      LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
      LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);

      LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());

      // If relationship is not allowed return empty set
      //TODO: use features description instead

      if (!Arrays.asList(fromTypeConfig.getAllowedMembershipTypes()).contains(ldapToIO.getIdentityType().getName()))
      {
         return relationships;
      }

      LdapContext ldapContext = getLDAPContext(ctx);

      try
      {
         Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
         Attribute member = attrs.get(fromTypeConfig.getMembershipAttributeName());

         if (member != null)
         {
            NamingEnumeration memberValues = member.getAll();
            while (memberValues.hasMoreElements())
            {
               String memberRef = memberValues.nextElement().toString();

               if ((fromTypeConfig.isMembershipAttributeDN() && memberRef.equals(ldapToIO.getDn())) ||
                  (!fromTypeConfig.isMembershipAttributeDN() && memberRef.equals(ldapToIO.getName())))
               {
                  //TODO: impl lacks support for rel type
                  relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapFromIO, ldapToIO));
               }
            }
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

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

      LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identityObject);

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

         String passwordString = null;

         // Handle generic impl

         if (credential.getValue() != null)
         {
            //TODO: support for empty password should be configurable
            passwordString = credential.getValue().toString();
         }
         else
         {
            throw new IdentityException("Null password value");
         }

         LdapContext ldapContext = getLDAPContext(ctx);

         try
         {

            Hashtable env = ldapContext.getEnvironment();

            env.put(Context.SECURITY_PRINCIPAL, ldapIO.getDn());
            env.put(Context.SECURITY_CREDENTIALS, passwordString);

            InitialContext initialCtx = new InitialLdapContext(env, null);

            if (initialCtx != null)
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

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

      LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identityObject);

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

         String passwordString = null;

         // Handle generic impl

         if (credential.getValue() != null)
         {
            //TODO: support for empty password should be configurable
            passwordString = credential.getValue().toString();
         }
         else
         {
            throw new IdentityException("Null password value");
         }

         String attributeName = getTypeConfiguration(ctx, ldapIO.getIdentityType()).getPasswordAttributeName();

         if (attributeName == null)
         {
            throw new IdentityException("IdentityType doesn't have passwordAttributeName option set: "
               + ldapIO.getIdentityType().getName());
         }

         LdapContext ldapContext = getLDAPContext(ctx);

         try
         {
            //TODO: maybe perform a schema check if this attribute is allowed for such entry

            Attributes attrs = new BasicAttributes(true);
            Attribute attr = new BasicAttribute(attributeName);
            attr.add(passwordString);
            attrs.put(attr);

            ldapContext.modifyAttributes(ldapIO.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
         }
         catch (NamingException e)
         {
            throw new IdentityException("Cannot set identity password value.", e);
         }
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

         );
      }

      Map<String, IdentityObjectAttribute> attrsMap = new HashMap<String, IdentityObjectAttribute>();

      LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);


      LdapContext ldapContext = getLDAPContext(ctx);

      try
      {
         Set<String> mappedNames = getTypeConfiguration(ctx, identity.getIdentityType()).getMappedAttributesNames();

         // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id

         String dn = ldapIdentity.getDn();

         Attributes attrs = ldapContext.getAttributes(dn);

         for (Iterator iterator = mappedNames.iterator(); iterator.hasNext();)
         {
View Full Code Here

Examples of org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl

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

      LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);


      // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id

      String dn = ldapIdentity.getDn();

      LdapContext ldapContext = getLDAPContext(ctx);

      try
      {
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.