SimpleAsn1Example.java
( ASN.1 Examples | Home )// ---------------------------------------------------------------- // -- Copyright (c) 2003-2011, Monfox, LLC. All Rights Reserved -- // ---------------------------------------------------------------- import monfox.log.*; import monfox.stack.osi.asn1.*; import monfox.stack.osi.api.ValueException; /** * The application provides many examples of working with most of the * ASN.1 AbstractData types defined in the DynamicTMN(R) ASN.1 API. * <p><br> * See the usage below: * <pre> * USAGE * * java SimpleAsn1Example * * </pre> * */ public class SimpleAsn1Example { public static void main(String args[]) { // -- // -- initialize the logger // -- Logger.setProvider(new SimpleLogger.Provider("SimpleAsn1Example.log")); // -- // -- initialize the ASN.1 API and metadata // -- Asn1Api api = new Asn1Api(); api.getConfig().isLaxMode(true); // -- // -- load the metadata // -- try { System.out.println("-- [ loading metadata ] --"); api.loadMetadata("SimpleAsn1Example.ser"); } catch(Exception e) { System.err.println("\n\n initialization failed: \n" + e +"\n\n"); System.exit(1); } showBOOLEAN(api); showINTEGER(api); showENUMERATED(api); showREAL(api); showBIT_STRING(api); showNULL(api); showOBJECT_IDENTIFIER(api); showStructuredData(api); showCHOICE(api); showSEQUENCE_OF(api); showAbstractString(api); } /** * Example usage of the ENUMERATED ASN.1 value class. */ public static void showENUMERATED(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- ENUMERATED Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating an ENUMERATED Component // -- // SimpleNum ::= ENUMERATED { zero(0), one(1), two(2), fifty(50) } ENUMERATED eVal = (ENUMERATED)api.newData("SimpleEnum"); eVal.setValue("fifty"); System.out.println(" eVal: " + eVal); if (eVal.equals("fifty")) { System.out.println(" value = FIFTY"); } // ------------------------------------ // -- Using AVN to create the value // ------------------------------------ AbstractData eVal2 = api.newData("SimpleEnum","two"); if (eVal2.equals("two")) { System.out.println(" value = TWO"); } testCoder(api,eVal); // Encode and Decode the Value... } catch(ValueException ve) { System.out.println("ValueException : '" + ve + "'"); } } /** * Example usage of the INTEGER ASN.1 value class. */ public static void showINTEGER(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- INTEGER Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating an INTEGER Component // -- // SimpleInteger ::= INTEGER{ zero(0), one(1), two(2), fifty(50) } INTEGER iVal1 = (INTEGER)api.newData("SimpleInteger"); iVal1.setValue("one"); if ( iVal1.equals("one") && (iVal1.hasName() && iVal1.getName().equals("one")) && (iVal1.longValue() == 1) ) { System.out.println(" iVal = ONE"); } System.out.println(" iVal1 : " + iVal1); System.out.println(" iVal1 : " + iVal1.intValue()); // -------------------------------------------------------------* // -- Using AVN to create the value // -------------------------------------------------------------* INTEGER iVal2 = (INTEGER)api.newData("SimpleInteger", "99"); System.out.println(" iVal2 : " + iVal2); System.out.println(" iVal2 : " + iVal2.longValue()); testCoder(api,iVal1); // Encode and Decode the Value... } catch(ValueException ve) { System.out.println("ValueException : '" + ve + "'"); } } /** * Example usage of the NULL ASN.1 value class. */ public static void showNULL(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- NULL Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating a NULL Component // -- NULL val1 = (NULL)api.newData("SimpleNull"); // *** Using AVN to create the value *** NULL val2 = (NULL)api.newData("SimpleNull", "NULL"); System.out.println(" val1 : " + val1); System.out.println(" val2 : " + val2); testCoder(api,val1); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } /** * Example usage of the BOOLEAN ASN.1 value class. */ public static void showBOOLEAN(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- BOOLEAN Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating a BOOLEAN Component // -- BOOLEAN val1 = (BOOLEAN)api.newData("SimpleBoolean"); val1.setValue(true); // *** Using AVN to create the value *** BOOLEAN val2 = (BOOLEAN)api.newData("BOOLEAN", "FALSE"); // -- // -- Examining a BOOLEAN Component // -- System.out.println(" val1 = " + val1); System.out.println(" val2 = " + val2); if (val1.booleanValue() == true) { System.out.println(" val1 == true"); } else { System.out.println(" val1 == false"); } testCoder(api,val1); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } /** * Example usage of the OBJECT_IDENTIFIER ASN.1 value class. */ public static void showOBJECT_IDENTIFIER(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- OBJECT_IDENTIFIER Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating an OBJECT_IDENTIFIER Component // -- // -- // -- Set value using Dot form notation OID // -- OBJECT_IDENTIFIER oid1 = (OBJECT_IDENTIFIER)api.newData("OBJECT IDENTIFIER"); oid1.fromValueNotation("1.3.6.1.4.1.3817.1"); // -- // -- Set value using normal AVN form OID // -- OBJECT_IDENTIFIER oid2 = (OBJECT_IDENTIFIER)api.newData("OBJECT IDENTIFIER"); oid2.fromValueNotation("{ 1 3 6 1 4 1 3817 1 2 3}"); // -- // -- Set value using ASN.1 defined OID // -- OBJECT_IDENTIFIER oid3 = (OBJECT_IDENTIFIER)api.newData("OBJECT IDENTIFIER", "simpleNode"); // -- // -- Set value using label with extensions // -- OBJECT_IDENTIFIER oid4 = (OBJECT_IDENTIFIER)api.newData("OBJECT IDENTIFIER", "simpleNode.1.1.1"); // -- // -- Display the OIDs using the default format // -- System.out.println(" oid1 : " + oid1); System.out.println(" oid2 : " + oid2); System.out.println(" oid3 : " + oid3); System.out.println(" oid4 : " + oid4); AVNFormat label_form = new AVNFormat(AVNFormat.USE_OID_LABELS); AVNFormat dot_form = new AVNFormat(AVNFormat.USE_DOT_FORM_OIDS); AVNFormat avn_form = new AVNFormat(); // -- // -- Show the different ways of displaying OIDs // -- System.out.println(" label form : " + oid3.toString(label_form)); System.out.println(" dot form : " + oid3.toString(dot_form)); System.out.println(" AVN form : " + oid3.toString(avn_form)); // -- // -- Examining an OBJECT_IDENTIFIER Component // -- testOID(oid1, oid2); testOID(oid2, oid1); testOID(oid2, oid3); testOID(oid3, oid4); testOID(oid4, oid3); testOID(oid1, "{1 3 6 1 4 1 3817 1}"); testOID(oid1, "1.3.6.1.4.1.3817.1"); testOID(oid1, "1.3.6.1.4.1.3817.1.1.1"); testOID(oid3, "simpleNode"); testOID(oid4, "simpleNode"); testCoder(api,oid4); // Encode and Decode the Value... } catch(ValueException ve) { ve.printStackTrace(); System.err.println("ValueException: " + ve); } } /** * Perform an OID comparison. */ public static void testOID(OBJECT_IDENTIFIER oid, OBJECT_IDENTIFIER oid2) { if (oid.equals(oid2)) System.out.println(" " + oid + " == " + oid2); else System.out.println(" " + oid + " != " + oid2); // -- // -- contains() refers to tree containment as in // -- // -- 'parent oid contains child'. // -- // -- Example: 1.2.3 contains 1.2.3.4 // -- if (oid.contains(oid2)) System.out.println(" " + oid + " contains " + oid2); else System.out.println(" " + oid + " does not contain " + oid2); } /** * Perform an OID/String-OID comparison. */ public static void testOID(OBJECT_IDENTIFIER oid, String oid_str) { if (oid.equals(oid_str)) { System.out.println(" " + oid + " == " + oid_str); } else { System.out.println(" " + oid + " != " + oid_str); } // -- // -- contains() refers to tree containment as in // -- // -- 'parent oid contains child'. // -- // -- Example: 1.2.3 contains 1.2.3.4 // -- if (oid.contains(oid_str)) { System.out.println(" " + oid + " contains " + oid_str); } else { System.out.println(" " + oid + " does not contain " + oid_str); } } /** * Example usage of the StructuredData ASN.1 value class (SET/SEQUENCE). */ public static void showStructuredData(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- StructuredData (SET/SEQUENCE) Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating a StructuredData Component // -- // SimpleNodeId ::= CHOICE // { // name GraphicString, // number INTEGER, // null NULL // } // // SimpleNodeInfo ::= SEQUENCE // { // address SEQUENCE // { // street GraphicString, // city GraphicString, // state GraphicString, // zip GraphicString // } OPTIONAL, // versionId CHOICE // { // number INTEGER, // name GraphicString // }, // supportedIds SET OF SimpleNodeId // } // -- // -- Create the StructuredData with the desired ASN.1 Type // -- StructuredData info = (StructuredData)api.newData("SimpleNodeInfo"); // -- // -- Set the street field using set() w/ dot notation // -- info.set("address.street", "100 Main Street"); // -- // -- Set the city field using ref() & setValue() // -- info.ref("address.city").setValue("Alpharetta"); // -- // -- Set the city field using ref() & set() // -- info.ref("address").set("state", "Georgia"); // -- // -- Set the city field using ref() & setValue() // -- info.ref("address").ref("zip").setValue("30022"); // -- // -- Set the versionId field(CHOICE) and select from CHOICE // -- info.ref("versionId").select("number", 12); // -- // -- Create and Populate the supportedIds SET OF -- // -- SET_OF ids = (SET_OF)info.ref("supportedIds"); // -- // -- Below are some different ways to create SimpleNodeIds // -- ids.add("name: \"Norcross-1\""); ids.add("\"Norcross-2\""); ids.refAppend().select("name", "Norcross-3"); ids.add("number: 1"); ids.add("2"); ids.refAppend().select("number", 3); ids.add("null: NULL"); ids.add("NULL"); // -- // -- Display the StructuredData Component -- // -- Using different output formats -- // -- System.out.println("--[ default AVNFormat ]---------------------"); System.out.println(info); System.out.println("--[ expanded AVNFormat]---------------------"); System.out.println(info.toString(AVNFormat.Expanded)); System.out.println("--[compact AVNFormat ]---------------------"); System.out.println(info.toString(AVNFormat.Compact)); System.out.println("--------------------------------------------"); // -- // -- Create SimpleNodeInfo from AVN Strings *** // -- // -- AVN for SimpleNodeInfo. label names provided // -- String info2_str = "{ address { street \"200 Pine Street\", " + " city \"Norcross\", " + " state \"Georgia\", " + " zip \"30092\" }, " + " versionId number: 133," + " supportedIds { name: \"node-1\", \"node-2\"," + " number: 3, 4, null: NULL, NULL }" + "}"; // -- // -- AVN for SimpleNodeInfo. label names/choice labels omitted // -- String info3_str = "{ { \"200 Pine Street\", " + " \"Norcross\", " + " \"Georgia\", " + " \"30092\" }, " + " 133," + " { \"node-1\", \"node-2\", 3, 4, NULL, NULL }" + "}"; AbstractData info2= api.newData("SimpleNodeInfo",info2_str); AbstractData info3= api.newData("SimpleNodeInfo",info3_str); System.out.println("--[info 2 in expanded AVNFormat]---------------"); System.out.println(info2.toString(AVNFormat.Expanded)); System.out.println("--[info 3 in Expanded AVNFormat]---------------"); System.out.println(info3.toString(AVNFormat.Expanded)); System.out.println("-----------------------------------------------"); // -- // -- Extract fields from the StructuredData // -- AbstractData version_id = info.get("versionId"); AbstractData state = info.get("address.state"); // -- // -- You can also cast returned values -- // -- AbstractString city = (AbstractString)info.get("address.city"); System.out.println(" versionId : " + version_id); System.out.println(" city : " + city); System.out.println(" state : " + state); // -- // -- Iterate through SET OF elements // -- SET_OF sids = (SET_OF)info.get("supportedIds"); System.out.println(" supported ids: "); AbstractData.Iterator iter = sids.getComponents(); for(iter.reset(); !iter.done(); iter.next()) { System.out.println(" " + iter.curr() ); } testCoder(api,info); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } /** * Example usage of the CHOICE ASN.1 value class. */ public static void showCHOICE(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- CHOICE Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating a CHOICE using the CHOICE // -- AbstractData class // -- // SimpleNodeId ::= CHOICE // { // name GraphicString, // number INTEGER, // null NULL // } // -- // -- Using select() to pick an alternative // -- CHOICE node_id1 = (CHOICE)api.newData("SimpleNodeId"); node_id1.select("name", "node-1"); // -- // -- Using ref() to pick the alternative // -- CHOICE node_id2 = (CHOICE)api.newData("SimpleNodeId"); node_id2.ref("name").setValue("node-2"); // -- // -- Using ref() to pick the alternative // -- CHOICE node_id3 = (CHOICE)api.newData("SimpleNodeId"); node_id3.ref("number").setValue(3); // -- // -- Using ref() to pick the alternative // -- CHOICE node_id4 = (CHOICE)api.newData("SimpleNodeId"); node_id3.ref("number").setValue(3); node_id4.ref("null"); // NULL, no need to provide a value // -- // -- Populating a CHOICE using AVN // -- // -- // -- Using alternative label 'name' // -- CHOICE node_id5 = (CHOICE)api.newData("SimpleNodeId", "name: \"node-5\""); // -- // -- No alternative provided. Parser determines alternative // -- CHOICE node_id6 = (CHOICE)api.newData("SimpleNodeId", "\"node-6\""); // -- // -- Using alternative label 'number' // -- CHOICE node_id7 = (CHOICE)api.newData("SimpleNodeId", "number: 7"); // -- // -- No alternative provided. Parser determines alternative // -- CHOICE node_id8 = (CHOICE)api.newData("SimpleNodeId", "8"); // -- // -- No alternative provided. Parser determines alternative // -- CHOICE node_id9 = (CHOICE)api.newData("SimpleNodeId","NULL"); System.out.println(" node_id1 = " + node_id1); System.out.println(" node_id2 = " + node_id2); System.out.println(" node_id3 = " + node_id3); System.out.println(" node_id4 = " + node_id4); System.out.println(" node_id5 = " + node_id5); System.out.println(" node_id6 = " + node_id6); System.out.println(" node_id7 = " + node_id7); System.out.println(" node_id8 = " + node_id8); System.out.println(" node_id9 = " + node_id9); // -- // -- Build a list of SimpleNodeIds -- // -- SEQUENCE_OF node_list = (SEQUENCE_OF)api.newData("SimpleNodeIdList"); node_list.add(node_id1); node_list.add(node_id2); node_list.add(node_id3); node_list.add(node_id4); node_list.add(node_id5); node_list.add(node_id6); node_list.add(node_id7); node_list.add(node_id8); node_list.add(node_id9); System.out.print(" node-list : "); System.out.println(node_list); // -- // -- Extracting CHOICE info using the // -- CHOICE class // -- System.out.println(" examining node ids :"); AbstractData.Iterator iter = node_list.getComponents(); for(iter.reset(); !iter.done(); iter.next()) { AbstractData node_id = iter.curr(); if ( node_id.getName().equals("name")) { System.out.println(" name => " + node_id.get()); } else if ( node_id.getName().equals("number")) { System.out.println(" number => " + node_id.get()); } else if ( node_id.getName().equals("null")) { System.out.println(" null node id"); } else { System.out.println(" no node-id provided"); } } testCoder(api,node_id1); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } /** * Example usage of the SET_OF ASN.1 value class. */ public static void showSET_OF(Asn1Api api) { // Set showSEQUENCE_OF } /** * Example usage of the SEQUENCE_OF ASN.1 value class. */ public static void showSEQUENCE_OF(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- SEQUENCE_OF Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating a SEQUENCE_OF using the // -- SEQUENCE_OF class // -- // SimpleUserList ::= SEQUENCE OF SimpleUserInfo // // SimpleUserInfo ::= SEQUENCE // { // name GraphicString, // id INTEGER, // dept INTEGER OPTIONAL // } // SEQUENCE_OF showr_list = (SEQUENCE_OF)api.newData("SimpleUserList"); // -- // -- Add an element using AVN // -- showr_list.add("{ name \"Wakko\", id 1, dept 12 }"); // -- // -- Add an element using AVN, no field labels // -- showr_list.add("{ \"Yakko\", id 2, dept 12 }"); // -- // -- Add new element and return it for population // -- AbstractData showr3 = showr_list.refAppend(); showr3.set("name", "Dot"); showr3.set("id", 3); showr3.set("dept", 12); // -- // -- Build a new data component and add it -- // -- StructuredData showr4 = new StructuredData(api, "SimpleUserInfo"); showr4.set("name", "Blinky"); showr4.set("id", 4); showr4.set("dept", 13); showr_list.add(showr4); String showr_list2_str = "{ { name \"Felix\", id 100 }, " + " { \"Garfield\", 200, 111 }, " + " { \"Eek\", 300} " + "}"; SEQUENCE_OF showr_list2 = (SEQUENCE_OF)api.newData("SimpleUserList", showr_list2_str); testCoder(api,showr_list2); // Encode and Decode the Value... System.out.println(" SimpleUserList : " + showr_list); System.out.println(" SimpleUserList2 : " + showr_list2); showr_list.addAll(showr_list2); // Combine the Lists. System.out.println(" SimpleUserList(After Combining) : " + showr_list); int i = 0; AbstractData.Iterator iter = showr_list.getComponents(); for(iter.reset(); !iter.done(); iter.next()) { System.out.println(" [" + (i++) + "] = " + iter.curr()); } System.out.println(" element 0 = " + showr_list.get(0)); System.out.println(" element 2 = " + showr_list.get(2)); AbstractData showr_dot = showr_list.find("name", "Dot"); AbstractData showr_eek = showr_list.find("name", "Eek"); AbstractData showr_id2 = showr_list.find("id", "2"); System.out.println(" dot's Info = " + showr_dot); System.out.println(" eek's Info = " + showr_eek); System.out.println(" user 2 = " + showr_id2); testCoder(api,showr_list); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } /** * Example usage of the BIT_STRING ASN.1 value class. */ public static void showBIT_STRING(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- BIT_STRING Examples"); System.out.println("--------------------------------"); try { // ********************************************* // *** Populating a BIT_STRING using the *** // *** BIT_STRING class *** // ********************************************* // SimpleBitString::=BIT STRING { locked(0), alarmed(1), active(2)} BIT_STRING bs = (BIT_STRING)api.newData("SimpleBitString"); bs.setBit("locked"); bs.setBit("alarmed"); bs.setBit("active"); bs.setBit(4); System.out.println(" bs (all)= " + bs); bs.resetBit("alarmed"); System.out.println(" bs (all-alarmed) = " + bs); if (bs.isBitSet("locked") && bs.isBitSet("active")) { System.out.println(" locked & active"); } if (bs.isBitSet("locked") && bs.isBitSet("alarmed")) { System.out.println(" locked & alarmed"); } for(int i=0;i<=bs.maxBit();i++) { Bit bit = bs.getBit(i); System.out.println(" [" + i + "] = " + bit.booleanValue()); } testCoder(api,bs); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } /** * Example usage of the AbstractString ASN.1 value class. */ public static void showAbstractString(Asn1Api api) { System.out.println("\n\n\n\n"); System.out.println("--------------------------------"); System.out.println("-- AbstractString Examples --"); System.out.println("--------------------------------"); try { AbstractString location = (AbstractString)api.newData("SimpleLocationName", "Norcross"); AbstractString string = (AbstractString)api.newData("PrintableString", "Hi There"); AbstractString octets = (AbstractString)api.newData("SimpleBuffer", "'AABBCCDDEEFF'H"); System.out.println(" location (DEFAULT) = " + location); System.out.println(" location (HEX_FORMAT) = " + location.toString(AbstractString.HEX_FORMAT) ); System.out.println(" location (BIN_FORMAT) = " + location.toString(AbstractString.BIN_FORMAT) ); System.out.println(" location (CHAR_FORMAT) = " + location.toString(AbstractString.CHAR_FORMAT) ); System.out.println(" location (toCharString) = " + location.toCharString()); System.out.println(" location (toHexString) = " + location.toHexString()); System.out.println(" location (toBinaryString) = " + location.toBinaryString()); System.out.println(" string = " + string); System.out.println(" octets = " + octets); char buf[] = { 0x11, 0x22, 0x33, 0x44 }; AbstractString buffer = (AbstractString)api.newData("OCTET STRING"); buffer.setValue(buf); System.out.println(" buffer = " + buffer); System.out.println(" buffer = " + buffer.toHexString()); System.out.println(" buffer = " + buffer.toBinaryString()); System.out.println(" buffer = " + buffer.toCharString()); testCoder(api,location); // Encode and Decode the Value... testCoder(api,buffer); // Encode and Decode the Value... } catch(ValueException ve) { System.err.println("ValueException: " + ve); } } public static void showREAL(Asn1Api api) { System.out.println("\n"); System.out.println("--------------------------------"); System.out.println("-- REAL Examples"); System.out.println("--------------------------------"); try { // -- // -- Populating a REAL // -- // ProtStatus ::= REAL { normal(0), loopback(1) } REAL r1 = (REAL)api.newData("SimpleReal", "-123e-3"); // Using float REAL r2 = (REAL)api.newData("SimpleReal"); // Using float r2.setValue(-0.123); REAL r3 = (REAL)api.newData("SimpleReal"); r3.fromValueNotation("-0.123"); // Using AVN REAL r4 = (REAL)api.newData("SimpleReal"); r4.fromValueNotation("-123e-3"); // Using AVN System.out.println(" r1 : " + r1 + " = (" + r1.doubleValue() + ")"); System.out.println(" r2 : " + r2 + " = (" + r2.doubleValue() + ")"); System.out.println(" r3 : " + r3 + " = (" + r3.doubleValue() + ")"); System.out.println(" r4 : " + r4 + " = (" + r4.doubleValue() + ")"); testCoder(api,r1); } catch(ValueException ve) { System.out.println("ValueException : '" + ve + "'"); } } public static void testCoder(Asn1Api api, AbstractData value) { System.out.println("\n--[ encode/decode ]-------------n"); try { monfox.stack.osi.asn1.metadata.AbstractType type = value.getType(); System.out.println("-- ASN.1 type : " + type); System.out.println("-- ASN.1 value : " + value + "\n"); ByteBuffer ber_buf = api.getAsn1Coder(Asn1Coder.BER).encode(value); System.out.println("-- BER encoding : \n" + ber_buf); ByteBuffer der_buf = api.getAsn1Coder(Asn1Coder.DER).encode(value); System.out.println("-- DER encoding : \n" + der_buf); ByteBuffer cer_buf = api.getAsn1Coder(Asn1Coder.CER).encode(value); System.out.println("-- CER encoding : \n" + cer_buf); AbstractData new_value = api.getAsn1Coder(Asn1Coder.BER).decode(type, ber_buf); System.out.println(" decoded value : " + new_value); } catch (Exception e) { System.out.println(" <<< Exception >>> : " + e); } System.out.println("\n--------------------------------"); } }