IppUri.java
8.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
* Decompiled with CFR 0_118.
*/
package com.scene7.is.ipp.messages;
import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.IppLongString;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
public class IppUri {
private String uri_;
private String username_;
private String password_;
private String[] httpHeaderNames_;
private String[] httpHeaderValues_;
public IppUri(String uri, String username, String password, String[] httpHeaderNames, String[] httpHeaderValues) {
this.uri_ = uri;
this.username_ = username;
this.password_ = password;
this.httpHeaderNames_ = httpHeaderNames;
this.httpHeaderValues_ = httpHeaderValues;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[");
buffer.append("uri: ").append(String.valueOf(this.uri_)).append(" ");
buffer.append("username: ").append(String.valueOf(this.username_)).append(" ");
buffer.append("password: ").append(String.valueOf(this.password_)).append(" ");
buffer.append("httpHeaderNames: ").append(String.valueOf(this.httpHeaderNames_)).append(" ");
buffer.append("httpHeaderValues: ").append(String.valueOf(this.httpHeaderValues_)).append(" ");
buffer.append("]");
return buffer.toString();
}
public boolean equals(Object o) {
int i;
if (!(o instanceof IppUri)) {
return false;
}
IppUri e = (IppUri)o;
if (!this.uri_.equals(e.uri_)) {
return false;
}
if (!this.username_.equals(e.username_)) {
return false;
}
if (!this.password_.equals(e.password_)) {
return false;
}
if (this.httpHeaderNames_.length != e.httpHeaderNames_.length) {
return false;
}
for (i = 0; i < this.httpHeaderNames_.length; ++i) {
if (this.httpHeaderNames_[i].equals(e.httpHeaderNames_[i])) continue;
return false;
}
if (this.httpHeaderValues_.length != e.httpHeaderValues_.length) {
return false;
}
for (i = 0; i < this.httpHeaderValues_.length; ++i) {
if (this.httpHeaderValues_[i].equals(e.httpHeaderValues_[i])) continue;
return false;
}
return true;
}
public static IppUri Unstuff(byte[] arr, Offset arrayPos) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppUri align");
String uri = IppLongString.Unstuff(arr, arrayPos);
String username = IppLongString.Unstuff(arr, arrayPos);
String password = IppLongString.Unstuff(arr, arrayPos);
String[] httpHeaderNames = IppLongString.UnstuffArray(arr, arrayPos);
String[] httpHeaderValues = IppLongString.UnstuffArray(arr, arrayPos);
return new IppUri(uri, username, password, httpHeaderNames, httpHeaderValues);
}
public static IppUri[] UnstuffArray(byte[] arr, Offset arrayPos) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppUri alignemt");
int count = IppInt.Unstuff(arr, arrayPos);
int size = IppInt.Unstuff(arr, arrayPos);
Ipp.Assert(count == 0 || size >= 36, "IppUri count");
Offset roff = new Offset(IppInt.Unstuff(arr, arrayPos));
Offset loff = new Offset(roff.val);
IppUri[] result = new IppUri[count];
for (int i = 0; i < count; ++i) {
loff.val = roff.val;
result[i] = IppUri.Unstuff(arr, loff);
roff.val += size;
}
return result;
}
public static IppUri[] UnstuffFixedArray(byte[] arr, Offset arrayPos, int count) {
IppUri[] result = new IppUri[count];
for (int i = 0; i < count; ++i) {
result[i] = IppUri.Unstuff(arr, arrayPos);
}
return result;
}
public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, IppUri val) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppUri align");
if (val != null) {
IppLongString.Stuff(arr, arrayPos, varPos, val.uri());
IppLongString.Stuff(arr, arrayPos, varPos, val.username());
IppLongString.Stuff(arr, arrayPos, varPos, val.password());
IppLongString.StuffArray(arr, arrayPos, varPos, val.httpHeaderNames());
IppLongString.StuffArray(arr, arrayPos, varPos, val.httpHeaderValues());
} else {
Ipp.StuffNullBytes(arr, arrayPos, 36);
}
}
public static void StuffArray(byte[] arr, Offset arrayPos, Offset varPos, IppUri[] val) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppUri stuffarray align");
int len = val != null ? val.length : 0;
IppInt.Stuff(arr, arrayPos, varPos, len);
IppInt.Stuff(arr, arrayPos, varPos, 36);
Ipp.StuffOffset(arr, arrayPos, varPos, len > 0 ? 4 : 1);
Offset varvarPos = new Offset(varPos.val + 36 * len);
for (int i = 0; i < len; ++i) {
IppUri.Stuff(arr, varPos, varvarPos, val[i]);
}
varPos.val = varvarPos.val;
}
public static void StuffFixedArray(byte[] arr, Offset arrayPos, Offset varPos, int count, IppUri[] val) {
Ipp.Assert(val.length == count, "IppUri count");
for (int i = 0; i < count; ++i) {
IppUri.Stuff(arr, arrayPos, varPos, val[i]);
}
}
public static void Print(Writer tf, String label, IppUri it) throws IOException {
String ll = label + "IppUri: ";
if (it == null) {
tf.write(ll + "NULL!!\n");
return;
}
tf.write(ll + "\n");
IppLongString.Print(tf, ll + "uri: ", it.uri());
IppLongString.Print(tf, ll + "username: ", it.username());
IppLongString.Print(tf, ll + "password: ", it.password());
IppLongString.PrintArray(tf, ll + "httpHeaderNames: ", it.httpHeaderNames());
IppLongString.PrintArray(tf, ll + "httpHeaderValues: ", it.httpHeaderValues());
}
public static void PrintArray(Writer tf, String label, IppUri[] it) throws IOException {
String ll = label + "IppUri Array, length: ";
tf.write(ll);
if (it == null) {
tf.write("NULL!!!\n");
return;
}
tf.write("" + it.length + "\n");
for (int i = 0; i < it.length; ++i) {
ll = label + "IppUri[" + String.valueOf(i) + "]: ";
IppUri.Print(tf, ll, it[i]);
}
}
public void adjustVarPos(Offset varPos) {
int i;
try {
varPos.val += this.uri_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
try {
varPos.val += this.username_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
try {
varPos.val += this.password_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
if (this.httpHeaderNames_ != null) {
varPos.val = varPos.val + 3 & -4;
varPos.val += this.httpHeaderNames_.length * 4;
for (i = 0; i < this.httpHeaderNames_.length; ++i) {
try {
varPos.val += this.httpHeaderNames_[i].getBytes("UTF-8").length + 1;
continue;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
}
if (this.httpHeaderValues_ != null) {
varPos.val = varPos.val + 3 & -4;
varPos.val += this.httpHeaderValues_.length * 4;
for (i = 0; i < this.httpHeaderValues_.length; ++i) {
try {
varPos.val += this.httpHeaderValues_[i].getBytes("UTF-8").length + 1;
continue;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
}
}
public String uri() {
return this.uri_;
}
public String username() {
return this.username_;
}
public String password() {
return this.password_;
}
public String[] httpHeaderNames() {
return this.httpHeaderNames_;
}
public String[] httpHeaderValues() {
return this.httpHeaderValues_;
}
}