Package org.nasutekds.server.protocols.asn1

Examples of org.nasutekds.server.protocols.asn1.ASN1ByteSequenceReader


      if (! new File(path).exists())
      {
        return;
      }
      inputStream = new FileInputStream(path);
      ASN1Reader reader = ASN1.getReader(inputStream);


      // The first element in the file should be a sequence of object class
      // sets.  Each object class set will itself be a sequence of octet
      // strings, where the first one is the token and the remaining elements
      // are the names of the associated object classes.
      reader.readStartSequence();
      while(reader.hasNextElement())
      {
        reader.readStartSequence();
        ByteSequence token = reader.readOctetString();

        LinkedHashMap<ObjectClass,String> ocMap =
             new LinkedHashMap<ObjectClass,String>();
        while(reader.hasNextElement())
        {
          String ocName = reader.readOctetStringAsString();
          String lowerName = toLowerCase(ocName);
          ObjectClass oc = DirectoryServer.getObjectClass(lowerName, true);
          ocMap.put(oc, ocName);
        }
        reader.readEndSequence();

        ocEncodeMap.put(ocMap, token);
        ocDecodeMap.put(token, ocMap);
      }
      reader.readEndSequence();


      // The second element in the file should be an integer element that holds
      // the value to use to initialize the object class counter.
      ocCounter.set((int)reader.readInteger());


      // The third element in the file should be a sequence of attribute
      // description components.  Each attribute description component will
      // itself be a sequence of octet strings, where the first one is the
      // token, the second is the attribute name, and all remaining elements are
      // the attribute options.
      reader.readStartSequence();
      while(reader.hasNextElement())
      {
        reader.readStartSequence();
        ByteSequence token = reader.readOctetString();
        String attrName = reader.readOctetStringAsString();
        String lowerName = toLowerCase(attrName);
        AttributeType attrType =
            DirectoryServer.getAttributeType(lowerName, true);

        LinkedHashSet<String> options =
            new LinkedHashSet<String>();
        while(reader.hasNextElement())
        {
          options.add(reader.readOctetStringAsString());
        }
        reader.readEndSequence();

        atDecodeMap.put(token, attrType);
        aoDecodeMap.put(token, options);

        ConcurrentHashMap<Set<String>, ByteSequence> map = adEncodeMap
            .get(attrType);
        if (map == null)
        {
          map = new ConcurrentHashMap<Set<String>, ByteSequence>(1);
          map.put(options, token);
          adEncodeMap.put(attrType, map);
        }
        else
        {
          map.put(options, token);
        }
      }
      reader.readEndSequence();


      // The fourth element in the file should be an integer element that holds
      // the value to use to initialize the attribute description counter.
      adCounter.set((int)reader.readInteger());
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
View Full Code Here


       * {@inheritDoc}
       */
      public DelayRequestControl decode(boolean isCritical, ByteString value)
          throws DirectoryException
      {
        ASN1Reader reader = ASN1.getReader(value);

        try
        {
          long delay = reader.readInteger();

          return new DelayRequestControl(isCritical, delay);
        }
        catch (Exception e)
        {
View Full Code Here

    // Check that the user can bind.
    Socket s = null;
    try {
      s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort());
      s.setSoTimeout(3000);
      ASN1Reader r = ASN1.getReader(s.getInputStream());
      ASN1Writer w = ASN1.getWriter(s.getOutputStream());

      BindRequestProtocolOp bindRequest =
        new BindRequestProtocolOp(
                 ByteString.valueOf(dn),
View Full Code Here

       */
      public ShortCircuitRequestControl decode(boolean isCritical,
                                               ByteString value)
          throws DirectoryException
      {
        ASN1Reader reader = ASN1.getReader(value);

        try
        {
          reader.readStartSequence();
          int resultCode = (int)reader.readInteger();
          String section = reader.readOctetStringAsString();
          reader.readEndSequence();

          return new ShortCircuitRequestControl(isCritical,
              resultCode, section);
        }
        catch (Exception e)
View Full Code Here

   */
  public List<Modification> getMods() throws ASN1Exception, LDAPException
  {
    List<Modification> mods = new ArrayList<Modification>();

    ASN1Reader reader = ASN1.getReader(encodedMods);

    while (reader.hasNextElement())
      mods.add((LDAPModification.decode(reader)).toModification());

    return mods;
  }
View Full Code Here

   */
  protected List<Modification> decodeMods(byte[] in)
  throws ASN1Exception, LDAPException
  {
    List<Modification> mods = new ArrayList<Modification>();
    ASN1Reader reader = ASN1.getReader(in);
    while (reader.hasNextElement())
    {
      mods.add((LDAPModification.decode(reader)).toModification());
    }
    return mods;
  }
View Full Code Here

   */
  protected ArrayList<RawModification> decodeRawMods(byte[] in)
  throws LDAPException, ASN1Exception
  {
    ArrayList<RawModification> ldapmods = new ArrayList<RawModification>();
    ASN1Reader asn1Reader = ASN1.getReader(in);
    while(asn1Reader.hasNextElement())
    {
      ldapmods.add(LDAPModification.decode(asn1Reader));
    }
    return ldapmods;
  }
View Full Code Here

        this.destination = reader.getInt();
      }
    }


    ASN1Reader asn1Reader = ASN1.getReader(reader);
    try
    {
      asn1Reader.readStartSequence();
      // loop on the servers
      while(asn1Reader.hasNextElement())
      {
        ServerState newState = new ServerState();
        int serverId = 0;
        Long outime = (long)0;
        boolean isLDAPServer = false;

        asn1Reader.readStartSequence();
        // loop on the list of CN of the state
        while(asn1Reader.hasNextElement())
        {
          String s = asn1Reader.readOctetStringAsString();
          ChangeNumber cn = new ChangeNumber(s);
          if ((data.replServerDbState != null) && (serverId == 0))
          {
            // we are on the first CN that is a fake CN to store the serverId
            // and the older update time
            serverId = cn.getServerId();
            outime = cn.getTime();
            isLDAPServer = (cn.getSeqnum()>0);
          }
          else
          {
            // we are on a normal CN
            newState.update(cn);
          }
        }
        asn1Reader.readEndSequence();

        if (data.replServerDbState == null)
        {
          // the first state is the replication state
          data.replServerDbState = newState;
        }
        else
        {
          // the next states are the server states
          ServerData sd = new ServerData();
          sd.state = newState;
          sd.approxFirstMissingDate = outime;
          if (isLDAPServer)
            data.ldapStates.put(serverId, sd);
          else
            data.rsStates.put(serverId, sd);
        }
      }
      asn1Reader.readEndSequence();
    } catch(Exception e)
    {

    }
  }
View Full Code Here

    ArrayList<RawAttribute> rattr = new ArrayList<RawAttribute>();
    try
    {
      ByteSequenceReader reader =
        ByteString.wrap(in).asReader();
      ASN1Reader asn1Reader = ASN1.getReader(reader);
      // loop on attributes
      while(asn1Reader.hasNextElement())
      {
        rattr.add(LDAPAttribute.decode(asn1Reader));
      }
      return rattr;
    }
View Full Code Here

    ArrayList<Attribute> lattr = new ArrayList<Attribute>();
    try
    {
      ByteSequenceReader reader =
        ByteString.wrap(in).asReader();
      ASN1Reader asn1Reader = ASN1.getReader(reader);
      // loop on attributes
      while(asn1Reader.hasNextElement())
      {
        lattr.add(LDAPAttribute.decode(asn1Reader).toAttribute());
      }
      return lattr;
    }
View Full Code Here

TOP

Related Classes of org.nasutekds.server.protocols.asn1.ASN1ByteSequenceReader

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.