author | stefank |
Mon, 25 Aug 2014 09:10:13 +0200 | |
changeset 26314 | f8bc1966fb30 |
parent 25859 | 3317bb8137f4 |
child 34687 | d302ed125dc9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.jndi.ldap; |
|
27 |
||
28 |
import java.io.OutputStream; |
|
29 |
import java.io.IOException; |
|
30 |
import java.io.ByteArrayInputStream; |
|
31 |
||
32 |
import sun.misc.HexDumpEncoder; |
|
33 |
||
34 |
/** |
|
35 |
* Base class that defines common fields, constants, and debug method. |
|
36 |
* |
|
37 |
* @author Jagane Sundar |
|
38 |
*/ |
|
39 |
public abstract class Ber { |
|
40 |
||
41 |
protected byte buf[]; |
|
42 |
protected int offset; |
|
43 |
protected int bufsize; |
|
44 |
||
45 |
protected Ber() { |
|
46 |
} |
|
47 |
||
48 |
public static void dumpBER(OutputStream outStream, String tag, byte[] bytes, |
|
49 |
int from, int to) { |
|
50 |
||
51 |
try { |
|
52 |
outStream.write('\n'); |
|
53 |
outStream.write(tag.getBytes("UTF8")); |
|
54 |
||
55 |
new HexDumpEncoder().encodeBuffer( |
|
56 |
new ByteArrayInputStream(bytes, from, to), |
|
57 |
outStream); |
|
58 |
||
59 |
outStream.write('\n'); |
|
60 |
} catch (IOException e) { |
|
61 |
try { |
|
62 |
outStream.write( |
|
63 |
"Ber.dumpBER(): error encountered\n".getBytes("UTF8")); |
|
64 |
} catch (IOException e2) { |
|
65 |
// ignore |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
//////////////////////////////////////////////////////////////////////////// |
|
71 |
// |
|
72 |
// some ASN defines |
|
73 |
// |
|
74 |
//////////////////////////////////////////////////////////////////////////// |
|
75 |
||
76 |
public static final int ASN_BOOLEAN = 0x01; |
|
77 |
public static final int ASN_INTEGER = 0x02; |
|
78 |
public static final int ASN_BIT_STRING = 0x03; |
|
79 |
public static final int ASN_SIMPLE_STRING = 0x04; |
|
80 |
public static final int ASN_OCTET_STR = 0x04; |
|
81 |
public static final int ASN_NULL = 0x05; |
|
82 |
public static final int ASN_OBJECT_ID = 0x06; |
|
83 |
public static final int ASN_SEQUENCE = 0x10; |
|
84 |
public static final int ASN_SET = 0x11; |
|
85 |
||
86 |
||
87 |
public static final int ASN_PRIMITIVE = 0x00; |
|
88 |
public static final int ASN_UNIVERSAL = 0x00; |
|
89 |
public static final int ASN_CONSTRUCTOR = 0x20; |
|
90 |
public static final int ASN_APPLICATION = 0x40; |
|
91 |
public static final int ASN_CONTEXT = 0x80; |
|
92 |
public static final int ASN_PRIVATE = 0xC0; |
|
93 |
||
94 |
public static final int ASN_ENUMERATED = 0x0a; |
|
95 |
||
96 |
final static class EncodeException extends IOException { |
|
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
5506
diff
changeset
|
97 |
private static final long serialVersionUID = -5247359637775781768L; |
2 | 98 |
EncodeException(String msg) { |
99 |
super(msg); |
|
100 |
} |
|
101 |
} |
|
102 |
||
103 |
final static class DecodeException extends IOException { |
|
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
5506
diff
changeset
|
104 |
private static final long serialVersionUID = 8735036969244425583L; |
2 | 105 |
DecodeException(String msg) { |
106 |
super(msg); |
|
107 |
} |
|
108 |
} |
|
109 |
} |