directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject svn commit: r1726933 - /directory/site/trunk/content/kerby/kerby-asn1.mdtext
Date Wed, 27 Jan 2016 02:00:36 GMT
Author: plusplusjiajia
Date: Wed Jan 27 02:00:36 2016
New Revision: 1726933

URL: http://svn.apache.org/viewvc?rev=1726933&view=rev
Log:
Refine the kerby asn1 page.

Modified:
    directory/site/trunk/content/kerby/kerby-asn1.mdtext

Modified: directory/site/trunk/content/kerby/kerby-asn1.mdtext
URL: http://svn.apache.org/viewvc/directory/site/trunk/content/kerby/kerby-asn1.mdtext?rev=1726933&r1=1726932&r2=1726933&view=diff
==============================================================================
--- directory/site/trunk/content/kerby/kerby-asn1.mdtext (original)
+++ directory/site/trunk/content/kerby/kerby-asn1.mdtext Wed Jan 27 02:00:36 2016
@@ -24,31 +24,30 @@ Notice: Licensed to the Apache Software
 
 ### A ASN1 parser with easy and simple API
 
-```
-// encoding
-Asn1Integer aValue = new Asn1Integer(8899);
-byte[] encoded = aValue.encode();
-
-// decoding
-byte[] contentToDecode = ...
-Asn1Integer decodedValue = new Asn1Integer();
-decodedValue.decode(contentToDecode);
-Integer value = decodedValue.getValue();
-```
+    // encoding
+    Asn1Integer aValue = new Asn1Integer(8899);
+    byte[] encoded = aValue.encode();
+
+    // decoding
+    byte[] contentToDecode = ...
+    Asn1Integer decodedValue = new Asn1Integer();
+    decodedValue.decode(contentToDecode);
+    Integer value = decodedValue.getValue();
+
 
 ### Data-driven ASN1 encoding/decoding framework and parser
 
 With the following definition from Kerberos protocol
-```
- AuthorizationData ::= SEQUENCE OF SEQUENCE {
-     ad-type         [0] Int32,
-     ad-data         [1] OCTET STRING
- }
- ```
+
+    AuthorizationData ::= SEQUENCE OF SEQUENCE {
+         ad-type         [0] Int32,
+         ad-data         [1] OCTET STRING
+     }
+
 
 You can model AuthzDataEntry as follows
-```java
-public class AuthorizationDataEntry extends KrbSequenceType {
+
+    public class AuthorizationDataEntry extends KrbSequenceType {
     /**
      * The possible fields
      */
@@ -116,51 +115,50 @@ public class AuthorizationDataEntry exte
     public void setAuthzData(byte[] authzData) {
         setFieldAsOctets(AuthorizationDataEntryField.AD_DATA, authzData);
     }
-}
-```
+    }
 
 And then define AuthorizationData simply
-```java
-public class AuthorizationData extends KrbSequenceOfType<AuthorizationDataEntry> {
 
-}
-```
+    public class AuthorizationData extends KrbSequenceOfType<AuthorizationDataEntry>
{
+
+    }
+
 
 Then you can process with above definitions, encode and decode, without caring about the
details.
 
 Think about how to implement the following more complex and pratical sample from [ITU-T Rec.
X.680 ISO/IEC 8824-1](http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf):
-```
-A.1 ASN.1 description of the record structure
-The structure of the hypothetical personnel record is formally described below using ASN.1
specified in
-ITU-T Rec. X.680 | ISO/IEC 8824-1 for defining types.
-
-PersonnelRecord ::= [APPLICATION 0] IMPLICIT SET {
-    Name Name,
-    title [0] VisibleString,
-    number EmployeeNumber,
-    dateOfHire [1] Date,
-    nameOfSpouse [2] Name,
-    children [3] IMPLICIT
-    SEQUENCE OF ChildInformation DEFAULT {}
-}
-
-ChildInformation ::= SET {
-    name Name,
-    dateOfBirth [0] Date
-}
-
-Name ::= [APPLICATION 1] IMPLICIT SEQUENCE {
-    givenName VisibleString,
-    initial VisibleString,
-    familyName VisibleString
-}
+
+    A.1 ASN.1 description of the record structure
+    The structure of the hypothetical personnel record is formally described below using
ASN.1 specified in
+    ITU-T Rec. X.680 | ISO/IEC 8824-1 for defining types.
+
+    PersonnelRecord ::= [APPLICATION 0] IMPLICIT SET {
+        Name Name,
+        title [0] VisibleString,
+        number EmployeeNumber,
+        dateOfHire [1] Date,
+        nameOfSpouse [2] Name,
+        children [3] IMPLICIT
+        SEQUENCE OF ChildInformation DEFAULT {}
+    }
+
+    ChildInformation ::= SET {
+        name Name,
+        dateOfBirth [0] Date
+    }
+
+    Name ::= [APPLICATION 1] IMPLICIT SEQUENCE {
+        givenName VisibleString,
+        initial VisibleString,
+        familyName VisibleString
+    }
 
 EmployeeNumber ::= [APPLICATION 2] IMPLICIT INTEGER
 Date ::= [APPLICATION 3] IMPLICIT VisibleString -- YYYYMMDD
 ```
 Similarly as above, we can have (from the unit test codes):
-```java
-public class PersonnelRecord extends Asn1TaggingSet {
+
+    public class PersonnelRecord extends Asn1TaggingSet {
     protected enum PersonnelRecordField implements EnumType {
         NAME,
         TITLE,
@@ -374,8 +372,8 @@ public class PersonnelRecord extends Asn
             this(null);
         }
     }
-}
-```
+    }
+
 ### Asn1 API and parsing/dumping facilities
 * ASN1 dumping tool to help analyze ASN1 encoding stream or packet. It can be used to exercise
the framework with all kinds of testing binary inputs.
 * The shortcut API for ASN1 parser, encoding, decoding.



Mime
View raw message