Examples of LDAPModification


Examples of com.day.ldap.LDAPModification

     * @return an array of <CODE>LDAPModification</CODE> objects that
     * represent the modifications specified in the content of the LDIF record.
     * @see com.day.ldap.LDAPModification
     */
    public LDAPModification[] getModifications() {
        LDAPModification mods[] = new LDAPModification[m_mods.size()];
        for (int i = 0; i < m_mods.size(); i++) {
            mods[i] = (LDAPModification)m_mods.elementAt(i);
        }
        return mods;
    }
View Full Code Here

Examples of com.novell.ldap.LDAPModification

            attribute = getUserCertAttribute();
            LDAPAttribute certAttr = new LDAPAttribute(getUserCertAttribute(), incert.getEncoded());
            if (oldEntry != null) {
              String oldDn = oldEntry.getDN();
              if (getAddMultipleCertificates()) {
                modSet.add(new LDAPModification(LDAPModification.ADD, certAttr));                       
                if (log.isDebugEnabled()) {
                  log.debug("Appended new certificate in user entry; " + username+": "+oldDn);
                }
              } else {
                modSet.add(new LDAPModification(LDAPModification.REPLACE, certAttr));                                           
                if (log.isDebugEnabled()) {
                  log.debug("Replaced certificate in user entry; " + username+": "+oldDn);
                }
              }
            } else {
              attributeSet.add(certAttr);
              if (log.isDebugEnabled()) {
                log.debug("Added new certificate to user entry; " + username+": "+dn);
              }
            }
          } catch (CertificateEncodingException e) {
            String msg = intres.getLocalizedMessage("publisher.errorldapencodestore", "certificate");
            log.error(msg, e);
            throw new PublisherException(msg);               
          }
        } else if ((type == SecConst.CERTTYPE_SUBCA) || (type == SecConst.CERTTYPE_ROOTCA)) {
          if (log.isDebugEnabled()) {
            log.debug("Publishing CA certificate to first available server of " + getHostnames());
          }
          if (oldEntry != null) {
            modSet = getModificationSet(oldEntry, certdn, null, false, false, password);
          } else {
            objectclass = getCAObjectClass(); // just used for logging
            attributeSet = getAttributeSet(incert, getCAObjectClass(), certdn, null, true, false, password, extendedinformation);
          }
          try {
            attribute = getCACertAttribute();
            LDAPAttribute certAttr = new LDAPAttribute(getCACertAttribute(), incert.getEncoded());
            if (oldEntry != null) {
              modSet.add(new LDAPModification(LDAPModification.REPLACE, certAttr));
            } else {
              attributeSet.add(certAttr);
              // Also create using the crlattribute, it may be required
              LDAPAttribute crlAttr = new LDAPAttribute(getCRLAttribute(), getFakeCRL());
              attributeSet.add(crlAttr);
View Full Code Here

Examples of com.novell.ldap.LDAPModification

    if(isDeltaCRL) {
      // It's a delta CRL.
      LDAPAttribute attr = new LDAPAttribute(getDeltaCRLAttribute(), incrl);
      if (oldEntry != null) {
        modSet.add(new LDAPModification(LDAPModification.REPLACE, attr));
      } else {
        attributeSet.add(attr);
      }
    } else {
      // It's a CRL
      LDAPAttribute crlAttr = new LDAPAttribute(getCRLAttribute(), incrl);
      LDAPAttribute arlAttr = new LDAPAttribute(getARLAttribute(), incrl);
      if (oldEntry != null) {
        modSet.add(new LDAPModification(LDAPModification.REPLACE, crlAttr));
        modSet.add(new LDAPModification(LDAPModification.REPLACE, arlAttr));
      } else {
        attributeSet.add(crlAttr);
        attributeSet.add(arlAttr);
      }
    }
View Full Code Here

Examples of com.novell.ldap.LDAPModification

          // Don't try to remove the cert if there does not exist any
          LDAPAttribute oldAttr = oldEntry.getAttribute(getUserCertAttribute());
          if (oldAttr != null) {
            modSet = getModificationSet(oldEntry, certdn, null, false, true, null);
            LDAPAttribute attr = new LDAPAttribute(getUserCertAttribute());
            modSet.add(new LDAPModification(LDAPModification.DELETE, attr));                   
          } else {
            String msg = intres.getLocalizedMessage("publisher.inforevokenocert");
            log.info(msg);
          }               
        }
View Full Code Here

Examples of com.novell.ldap.LDAPModification

          log.debug("removeme, dn="+dn);
        }
      }
      if ( ((attribute != null) && (oldattribute == null) && addNonExisting) || ( ((attribute != null) && (oldattribute != null )) && modifyExisting) ) {
        LDAPAttribute attr = new LDAPAttribute(attributes[i], attribute);
        modset.add(new LDAPModification(LDAPModification.REPLACE, attr));
      }
    }
    return modset;
  }
View Full Code Here

Examples of com.novell.ldap.LDAPModification

          }
        }
        LDAPAttribute oldsn = oldEntry.getAttribute("sn");
        if (((sn != null) && (oldsn == null) && addNonExisting) || ( (sn != null) && (oldsn != null ) && modifyExisting)) {
          LDAPAttribute attr = new LDAPAttribute("sn", sn);
          modSet.add(new LDAPModification(LDAPModification.REPLACE, attr));
        }
        // gn means givenname in LDAP, and is required for inetOrgPerson
        String gn = CertTools.getPartFromDN(dn, "GIVENNAME");
        LDAPAttribute oldgn = oldEntry.getAttribute("GIVENNAME");
        if ( (gn == null) && (cn != null) ) {
          // Only construct this if we are the standard object class
          if (getUserObjectClass().endsWith("inetOrgPerson")) {
            // Take givenname to be the first part of the cn
            int index = cn.indexOf(' ');
            if (index <=0) {
              // If there is no natural gn/sn, ignore gn if we are using sn
              if (sn == null) {
                gn = cn;
              }
            } else {
              gn = new String(cn.substring(0, index));
            }
          }
          if ( ( ((gn != null) && (oldgn == null)) && addNonExisting) || ( ((gn != null) && (oldgn != null )) && modifyExisting) ) {
            LDAPAttribute attr = new LDAPAttribute("givenName", gn);
            modSet.add(new LDAPModification(LDAPModification.REPLACE, attr));
          }
        }
        String title = CertTools.getPartFromDN(dn, "T");
        LDAPAttribute oldTitle = oldEntry.getAttribute("Title");
        if ( ( (title != null) && (oldTitle == null) && addNonExisting) || ( (title != null) && (oldTitle != null ) && modifyExisting) ) {
          LDAPAttribute attr = new LDAPAttribute("givenName", title);
          modSet.add(new LDAPModification(LDAPModification.REPLACE, attr));
        }
        LDAPAttribute oldEmail = oldEntry.getAttribute("mail");
        if ( ( (email != null) && (oldEmail == null) && addNonExisting) || ( (email != null) && (oldEmail != null ) && modifyExisting) ) {
          LDAPAttribute mailAttr = new LDAPAttribute("mail", email);
          modSet.add(new LDAPModification(LDAPModification.REPLACE, mailAttr));                     
        }

        // All generic personal attributes
        modSet.addAll(getModificationSetFromDN(dn, oldEntry, MATCHINGPERSONALATTRIBUTES));
        // If we have selected to use the SN (serialNUmber DN field, we will also add it as an attribute
        // This is not present in the normal objectClass (inetOrgPerson)
        Collection<Integer> usefields = getUseFieldInLdapDN();
        if (usefields.contains(Integer.valueOf(DNFieldExtractor.SN))) {
          String serno = CertTools.getPartFromDN(dn, "SN");
          LDAPAttribute oldserno = oldEntry.getAttribute("SN");
          if (((serno != null) && (oldserno == null) && addNonExisting) || ( (serno != null) && (oldserno != null ) && modifyExisting)) {
            LDAPAttribute attr = new LDAPAttribute("serialNumber", serno);
            modSet.add(new LDAPModification(LDAPModification.REPLACE, attr));
          }               
        }
       
        // If this is an objectClass which is a SecurityObject, such as simpleSecurityObject, we will add the password as well, if not null
        if ( (getSetUserPassword() && (password != null)) && (addNonExisting || modifyExisting) ) {
          if (log.isDebugEnabled()) {
            log.debug("Modifying userPassword attribute");
          }
          LDAPAttribute attr = new LDAPAttribute("userPassword", password);
          modSet.add(new LDAPModification(LDAPModification.REPLACE, attr));
        }
      }
    }
    if (log.isTraceEnabled()) {
      log.trace("<getModificationSet()");
View Full Code Here

Examples of com.novell.ldap.LDAPModification

            connection.connect(LDAPServerAddress, 389);
            connection.bind(LDAPConnection.LDAP_V3, "cn=admin,dc=sei,dc=pku",
                    "seiseforge");
            connection.modify("uid=" + user.getUserName()
                    + ",ou=People,o=SEForge,dc=sei,dc=pku",
                    new LDAPModification(LdapContext.REPLACE_ATTRIBUTE,
                            new LDAPAttribute("userPassword", user
                                    .getPassword())));
            System.out.println("成功修改一条记录!");
            connection.disconnect();
        } catch (LDAPException e) {
View Full Code Here

Examples of netscape.ldap.LDAPModification

          // bind to the server               
            connection.bind(_authid, _authpw );
         
          //change attribut         
            connection.modify( base,
              new LDAPModification(LDAPModification.REPLACE,
                  new LDAPAttribute( attrKey, value)));
          return true;
        } catch( LDAPException e1) {
          throw new Exception ("..can not change the Key. " + attrKey + "=" + value + " " + e1.toString());                  
        }
View Full Code Here

Examples of netscape.ldap.LDAPModification

    {
        LDAPConnection con = getWiredConnection( ldapServer );

        // first a valid attribute
        LDAPAttribute attr = new LDAPAttribute( "description", "The description" );
        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );
        // then an invalid one without any value
        attr = new LDAPAttribute( "displayName" );
        LDAPModification mod2 = new LDAPModification( LDAPModification.ADD, attr );

        try
        {
            con.modify( "cn=Kate Bush,ou=system", new LDAPModification[] { mod, mod2 } );
            fail( "error expected due to empty attribute value" );
View Full Code Here

Examples of netscape.ldap.LDAPModification

    {
        LDAPConnection con = getNsdkWiredConnection( getLdapServer() );

        // first a valid attribute
        LDAPAttribute attr = new LDAPAttribute( "description", "The description" );
        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );
        // then an invalid one without any value
        attr = new LDAPAttribute( "displayName" );
        LDAPModification mod2 = new LDAPModification( LDAPModification.ADD, attr );

        try
        {
            con.modify( "cn=Kate Bush,ou=system", new LDAPModification[]
                { mod, mod2 } );
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.