Examples of ASN1Writer


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

    assertEquals(pec.isCritical(),isCritical);
    assertEquals(pec.getOID(),OID_PASSWORD_POLICY_CONTROL);

    // Check the encode/decode
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    pec = new PasswordPolicyRequestControl(isCritical);
    pec.write(writer);
    LDAPControl control = LDAPReader
        .readControl(ASN1.getReader(bsb));
    pec = PasswordPolicyRequestControl.DECODER.decode(control.isCritical(), control.getValue());
View Full Code Here

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


    // check encode/decode
    PasswordPolicyResponseControl control ;
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    for (PasswordPolicyErrorType errorType : PasswordPolicyErrorType.values())
    {
      for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType
          .values())
      {
View Full Code Here

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

  @Test()
  public void testASN1ValueEncoding()
         throws Exception
  {
    ByteStringBuilder builder = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(builder);
    VLVResponseControl vlvResponse = new VLVResponseControl(true, 0, 15, 0,
        ByteString.valueOf("foo"));
    vlvResponse.writeValue(writer);

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

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

  @Test(expectedExceptions = { DirectoryException.class })
  public void testDecodeControlNotCritical()
         throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    writer.writeStartSequence();
    writer.writeOctetString("uid=test,o=test");
    writer.writeEndSequence();
    LDAPControl c =
        new LDAPControl(OID_PROXIED_AUTH_V1, false, bsb.toByteString());

    ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
  }
View Full Code Here

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

  @Test(expectedExceptions = { DirectoryException.class })
  public void testDecodeControlValueEmptySequence()
         throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    writer.writeStartSequence();
    writer.writeEndSequence();
    LDAPControl c =
        new LDAPControl(OID_PROXIED_AUTH_V1, true, bsb.toByteString());

    ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
  }
View Full Code Here

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

  @Test
  public void testDecodeControlValueMultiElementSequence()
         throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    writer.writeStartSequence();
    writer.writeOctetString("uid=element1,o=test");
    writer.writeOctetString("uid=element2,o=test");
    writer.writeEndSequence();
    LDAPControl c =
        new LDAPControl(OID_PROXIED_AUTH_V1, true, bsb.toByteString());

    assertEquals(ByteString.valueOf("uid=element1,o=test"),
        ProxiedAuthV1Control.DECODER.decode(c.isCritical(),
View Full Code Here

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

  @Test(expectedExceptions = { DirectoryException.class })
  public void testDecodeControlValueInvalidDN()
         throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    writer.writeStartSequence();
    writer.writeOctetString("invaliddn");
    writer.writeEndSequence();
    LDAPControl c =
        new LDAPControl(OID_PROXIED_AUTH_V1, true, bsb.toByteString());

    ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
  }
View Full Code Here

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

  @Test()
  public void testDecodeControlValueEmptyDN()
         throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    writer.writeStartSequence();
    writer.writeOctetString("");
    writer.writeEndSequence();
    LDAPControl c =
        new LDAPControl(OID_PROXIED_AUTH_V1, true, bsb.toByteString());

    ProxiedAuthV1Control proxyControl = ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
    assertTrue(proxyControl.getAuthorizationDN().isNullDN());
View Full Code Here

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

  @Test()
  public void testDecodeControlValueNonEmptyDN()
         throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    writer.writeStartSequence();
    writer.writeOctetString("uid=test,o=test");
    writer.writeEndSequence();
    LDAPControl c =
        new LDAPControl(OID_PROXIED_AUTH_V1, true, bsb.toByteString());

    ProxiedAuthV1Control proxyControl = ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
    assertEquals(proxyControl.getAuthorizationDN(),
View Full Code Here

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

                    CONFIG_DIR_NAME + File.separator +
                    COMPRESSED_SCHEMA_FILE_NAME;
      String tempPath = path + ".tmp";

      outputStream = new FileOutputStream(tempPath);
      ASN1Writer writer = ASN1.getWriter(outputStream);


      // 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.
      writer.writeStartSequence();
      for (Map.Entry<ByteSequence,Map<ObjectClass,String>> mapEntry :
           ocDecodeMap.entrySet())
      {
        writer.writeStartSequence();
        writer.writeOctetString(mapEntry.getKey());
        Map<ObjectClass,String> ocMap = mapEntry.getValue();

        for (String ocName : ocMap.values())
        {
          writer.writeOctetString(ocName);
        }
        writer.writeEndSequence();
      }
      writer.writeEndSequence();


      // The second element in the file should be an integer element that holds
      // the value to use to initialize the object class counter.
      writer.writeInteger(ocCounter.get());


      // 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.
      writer.writeStartSequence();
      for (ByteSequence token : atDecodeMap.keySet())
      {
        writer.writeStartSequence();
        AttributeType attrType = atDecodeMap.get(token);
        Set<String> options = aoDecodeMap.get(token);

        writer.writeOctetString(token);
        writer.writeOctetString(attrType.getNameOrOID());
        for (String option : options)
        {
          writer.writeOctetString(option);
        }
        writer.writeEndSequence();
      }
      writer.writeEndSequence();


      // The fourth element in the file should be an integer element that holds
      // the value to use to initialize the attribute description counter.
      writer.writeInteger(adCounter.get());


      // Close the writer and swing the temp file into place.
      outputStream.close();
      File liveFile = new File(path);
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.