test/com/sun/jndi/ldap/Base64Test.java

Print this page

        

*** 27,42 **** * @summary Confirm that old and new Base64 encodings are compatible. * @modules java.base/sun.misc */ import java.io.*; import java.util.*; import javax.naming.*; import javax.naming.directory.*; - import sun.misc.BASE64Decoder; - /* * RFC 2713 specifies an encoding for Java objects stored in an LDAP directory. * Section 3.6 specifies how a binary-valued JNDI RefAddr object is encoded * in the value of a javaReferenceAttribute LDAP attribute: first the RefAddr * object is serialized and then it is encoded using Base64. --- 27,41 ---- * @summary Confirm that old and new Base64 encodings are compatible. * @modules java.base/sun.misc */ import java.io.*; + import java.lang.reflect.Method; import java.util.*; import javax.naming.*; import javax.naming.directory.*; /* * RFC 2713 specifies an encoding for Java objects stored in an LDAP directory. * Section 3.6 specifies how a binary-valued JNDI RefAddr object is encoded * in the value of a javaReferenceAttribute LDAP attribute: first the RefAddr * object is serialized and then it is encoded using Base64.
*** 46,61 **** * as the line separator at intervals of 76 characters. Previously the * JNDI/LDAP provider used a private Base64 encoder which inserted '\n' * as the line separator. It is a compatible change. * * This test demonstrates that there is no compatability problem when ! * encoding and decoding using either Base64 coder: * ! * encode with s.m.BASE64Encoder, decode with s.m.BASE64Decoder => OK ! * encode with s.m.BASE64Encoder, decode with j.u.Base64.Decoder => OK ! * encode with j.u.Base64.Encoder, decode with s.m.BASE64Decoder => OK ! * encode with j.u.Base64.Encoder, decode with j.u.Base64.Decoder => OK * * * NOTE: The two Base64 encodings used in this test were captured from * LDAP protocol exchanges during attempts by the JNDI/LDAP provider * to store a JNDI Reference test object. --- 45,58 ---- * as the line separator at intervals of 76 characters. Previously the * JNDI/LDAP provider used a private Base64 encoder which inserted '\n' * as the line separator. It is a compatible change. * * This test demonstrates that there is no compatability problem when ! * decoding using the new Base64 coder: * ! * encoded bytes captured from s.m.BASE64Encoder, decode with j.u.Base64.Decoder => OK ! * encoded bytes captured from j.u.Base64.Encoder, decode with j.u.Base64.Decoder => OK * * * NOTE: The two Base64 encodings used in this test were captured from * LDAP protocol exchanges during attempts by the JNDI/LDAP provider * to store a JNDI Reference test object.
*** 146,174 **** public static void main(String[] args) throws Exception { System.out.println("\nOriginal RefAddr object:\n" + BINARY_REF_ADDR); System.out.println("Old Base64 encoded serialized RefAddr object:\n" + ! OLD_ENCODING); ! System.out.println("Decode using old Base64 decoder..."); ! deserialize(new BASE64Decoder().decodeBuffer(OLD_ENCODING)); ! ! System.out.println("----"); ! ! System.out.println("\nOriginal RefAddr object:\n" + BINARY_REF_ADDR); ! System.out.println("Old Base64 encoded serialized RefAddr object:\n" + ! OLD_ENCODING); System.out.println("Decode using new Base64 decoder..."); ! deserialize(new BASE64Decoder().decodeBuffer(OLD_ENCODING)); ! ! System.out.println("----"); ! ! System.out.println("\nOriginal RefAddr object:\n" + BINARY_REF_ADDR); ! System.out.println("New Base64 encoded serialized RefAddr object:\n" + ! NEW_ENCODING + "\n"); ! System.out.println("Decode using old Base64 decoder..."); ! deserialize(new BASE64Decoder().decodeBuffer(OLD_ENCODING)); System.out.println("----"); System.out.println("\nOriginal RefAddr object:\n" + BINARY_REF_ADDR); System.out.println("New Base64 encoded serialized RefAddr object:\n" + --- 143,155 ---- public static void main(String[] args) throws Exception { System.out.println("\nOriginal RefAddr object:\n" + BINARY_REF_ADDR); System.out.println("Old Base64 encoded serialized RefAddr object:\n" + ! OLD_ENCODING + "\n"); System.out.println("Decode using new Base64 decoder..."); ! deserialize(Base64.getMimeDecoder().decode(OLD_ENCODING)); System.out.println("----"); System.out.println("\nOriginal RefAddr object:\n" + BINARY_REF_ADDR); System.out.println("New Base64 encoded serialized RefAddr object:\n" +