Package org.nasutekds.server.protocols.asn1

Examples of org.nasutekds.server.protocols.asn1.ASN1ByteChannelReader$CombinedBufferInputStream


         throws ASN1Exception
  {
    ByteStringBuilder byteBuilder = new ByteStringBuilder();
    byteBuilder.append(encodedAttributes);

    ASN1Writer writer = ASN1.getWriter(byteBuilder);

    try
    {
      new LDAPAttribute(name, value).write(writer);
View Full Code Here


    private static String creds="some creds";

  @Test()
  public void testBindRequestEncodeDecode() throws Exception {
    ByteStringBuilder simpleBuilder = new ByteStringBuilder();
    ASN1Writer simpleWriter = ASN1.getWriter(simpleBuilder);
    ByteStringBuilder saslBuilder = new ByteStringBuilder();
    ASN1Writer saslWriter = ASN1.getWriter(saslBuilder);
    ByteString bindDn=ByteString.valueOf(dn);
    ByteString pw=ByteString.valueOf(pwd);
    BindRequestProtocolOp simple =
      new BindRequestProtocolOp(bindDn, 3, pw);
    BindRequestProtocolOp sasl =
View Full Code Here

   @Test (expectedExceptions = LDAPException.class)
    public void testBadBindRequestSequence() throws Exception
    {
    ByteStringBuilder builder = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(builder);
    writer.writeInteger(OP_TYPE_BIND_REQUEST, 0);

    ASN1Reader reader = ASN1.getReader(builder.toByteString());
    LDAPReader.readProtocolOp(reader);
    }
View Full Code Here

   @Test (expectedExceptions = LDAPException.class)
   public void testInvalidBindRequestTooManyElements() throws Exception
   {
     ByteStringBuilder builder = new ByteStringBuilder();
     ASN1Writer writer = ASN1.getWriter(builder);

     writer.writeStartSequence(OP_TYPE_BIND_REQUEST);
     writer.writeInteger(3);
     writer.writeOctetString(dn);
     writer.writeBoolean(true);
     writer.writeStartSequence(TYPE_AUTHENTICATION_SASL);
     writer.writeOctetString(SASL_MECHANISM_PLAIN);
     writer.writeOctetString(pwd);
     writer.writeEndSequence();
     writer.writeEndSequence();

     ASN1Reader reader = ASN1.getReader(builder.toByteString());
     LDAPReader.readProtocolOp(reader);
   }
View Full Code Here

   @Test (expectedExceptions = LDAPException.class)
   public void testInvalidBindRequestTooFewElements() throws Exception
   {
     ByteStringBuilder builder = new ByteStringBuilder();
     ASN1Writer writer = ASN1.getWriter(builder);

     writer.writeStartSequence(OP_TYPE_BIND_REQUEST);
     writer.writeOctetString(dn);
     writer.writeStartSequence(TYPE_AUTHENTICATION_SASL);
     writer.writeOctetString(SASL_MECHANISM_PLAIN);
     writer.writeOctetString(pwd);
     writer.writeEndSequence();
     writer.writeEndSequence();

    ASN1Reader reader = ASN1.getReader(builder.toByteString());
    LDAPReader.readProtocolOp(reader);
   }
View Full Code Here

   @Test (expectedExceptions = LDAPException.class)
   public void testInvalidBindRequestProtoVersion() throws Exception
   {
     ByteStringBuilder builder = new ByteStringBuilder();
     ASN1Writer writer = ASN1.getWriter(builder);

     writer.writeStartSequence(OP_TYPE_BIND_REQUEST);
     writer.writeOctetString("invalid element");
     writer.writeOctetString(dn);
     writer.writeStartSequence(TYPE_AUTHENTICATION_SASL);
     writer.writeOctetString(SASL_MECHANISM_PLAIN);
     writer.writeOctetString(pwd);
     writer.writeEndSequence();
     writer.writeEndSequence();

    ASN1Reader reader = ASN1.getReader(builder.toByteString());
    LDAPReader.readProtocolOp(reader);
   }
View Full Code Here

    }

    @Test (expectedExceptions = LDAPException.class)
    public void testBindResponseTooFew() throws Exception {
      ByteStringBuilder bsb = new ByteStringBuilder();
      ASN1Writer writer = ASN1.getWriter(bsb);
      writer.writeStartSequence(OP_TYPE_BIND_RESPONSE);
      writer.writeOctetString((String)null);
      writer.writeOctetString((String)null);
      writer.writeEndSequence();

      ASN1Reader reader = ASN1.getReader(bsb.toByteString());
      LDAPReader.readProtocolOp(reader);
    }
View Full Code Here

    @Test
    public void testBindResponseTooMany() throws Exception {
      DN responseDn = DN.decode(dn);

      ByteStringBuilder bsb = new ByteStringBuilder();
      ASN1Writer writer = ASN1.getWriter(bsb);
      writer.writeStartSequence(OP_TYPE_BIND_RESPONSE);
      writer.writeInteger(okCode.getIntValue());
      writer.writeOctetString(responseDn.toString());
      writer.writeOctetString(message.toString());
      writer.writeBoolean(true);
      writer.writeEndSequence();

      ASN1Reader reader = ASN1.getReader(bsb.toByteString());
      ProtocolOp protocolOp = LDAPReader.readProtocolOp(reader);

      assertTrue(protocolOp instanceof BindResponseProtocolOp);
View Full Code Here

    }

    @Test (expectedExceptions = LDAPException.class)
    public void testBindResponseBadResult() throws Exception {
      ByteStringBuilder bsb = new ByteStringBuilder();
      ASN1Writer writer = ASN1.getWriter(bsb);
      writer.writeStartSequence(OP_TYPE_BIND_RESPONSE);
      writer.writeOctetString("invalid element");
      writer.writeOctetString((String)null);
      writer.writeOctetString((String)null);
      writer.writeEndSequence();

      ASN1Reader reader = ASN1.getReader(bsb.toByteString());
      LDAPReader.readProtocolOp(reader);
    }
View Full Code Here

      DN responseDn = DN.decode(dn);
      ByteString serverSASLCredentials =
          ByteString.valueOf(saslCreds);

      ByteStringBuilder bsb = new ByteStringBuilder();
      ASN1Writer writer = ASN1.getWriter(bsb);
      writer.writeStartSequence(OP_TYPE_BIND_RESPONSE);
      writer.writeInteger(okCode.getIntValue());
      writer.writeOctetString(responseDn.toString());
      writer.writeOctetString(message.toString());
      writer.writeInteger(Long.MAX_VALUE);
      writer.writeOctetString(TYPE_SERVER_SASL_CREDENTIALS,
          serverSASLCredentials);
      writer.writeEndSequence();

      ASN1Reader reader = ASN1.getReader(bsb.toByteString());
      ProtocolOp protocolOp = LDAPReader.readProtocolOp(reader);

      assertTrue(protocolOp instanceof BindResponseProtocolOp);
View Full Code Here

TOP

Related Classes of org.nasutekds.server.protocols.asn1.ASN1ByteChannelReader$CombinedBufferInputStream

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.