Sitelet https://github.com/JimmyCheng059/java/commit/7bfe76d07d82e6892531eff71580ae5f574c46b7
Skip to content

Commit 7bfe76d

Browse files
author
Devendra
committed
reverting back to e7d2804
1 parent aa29b43 commit 7bfe76d

34 files changed

Lines changed: 118 additions & 280 deletions

‎android/src/com/pubnub/api/Pubnub.java‎

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,6 @@
1111
*/
1212

1313
public class Pubnub extends PubnubCore {
14-
15-
/** The default initialization vector. */
16-
private static final String DEFAULT_IV = "0123456789012345";
17-
18-
/**
19-
*
20-
*
21-
* Prepare PubNub State.
22-
*
23-
* @param String
24-
* Publish Key.
25-
* @param String
26-
* Subscribe Key.
27-
* @param String
28-
* Secret Key.
29-
* @param String
30-
* Cipher Key.
31-
* @param boolean SSL Enabled.
32-
*
33-
* @param initialization_vector The initialization vector used to create the cipher.
34-
*/
35-
public Pubnub(String publish_key, String subscribe_key, String secret_key,
36-
String cipher_key, boolean ssl_on, String initialization_vector) {
37-
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, initialization_vector);
38-
}
39-
4014
/**
4115
* Pubnub Constructor
4216
*
@@ -53,7 +27,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
5327
*/
5428
public Pubnub(String publish_key, String subscribe_key, String secret_key,
5529
String cipher_key, boolean ssl_on) {
56-
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, DEFAULT_IV );
30+
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on);
5731
}
5832

5933
/**
@@ -70,7 +44,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
7044
*/
7145
public Pubnub(String publish_key, String subscribe_key, String secret_key,
7246
boolean ssl_on) {
73-
super(publish_key, subscribe_key, secret_key, "", ssl_on, "");
47+
super(publish_key, subscribe_key, secret_key, "", ssl_on);
7448
}
7549

7650
/**
@@ -82,7 +56,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
8256
* Subscribe Key
8357
*/
8458
public Pubnub(String publish_key, String subscribe_key) {
85-
super(publish_key, subscribe_key, "", "", false, "");
59+
super(publish_key, subscribe_key, "", "", false);
8660
}
8761

8862
/**
@@ -93,7 +67,7 @@ public Pubnub(String publish_key, String subscribe_key) {
9367
* @param ssl
9468
*/
9569
public Pubnub(String publish_key, String subscribe_key, boolean ssl) {
96-
super(publish_key, subscribe_key, "", "", ssl, "");
70+
super(publish_key, subscribe_key, "", "", ssl);
9771
}
9872

9973
/**
@@ -102,7 +76,7 @@ public Pubnub(String publish_key, String subscribe_key, boolean ssl) {
10276
* @param secret_key
10377
*/
10478
public Pubnub(String publish_key, String subscribe_key, String secret_key) {
105-
super(publish_key, subscribe_key, secret_key, "", false, "");
79+
super(publish_key, subscribe_key, secret_key, "", false);
10680
}
10781

10882
/**

‎blackberry/src/com/pubnub/api/Pubnub.java‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,27 @@
55

66
public class Pubnub extends PubnubCore {
77

8-
/** The default initialization vector. */
9-
private static final String DEFAULT_IV = "0123456789012345";
10-
11-
public Pubnub(String publish_key, String subscribe_key, String secret_key,
12-
String cipher_key, boolean ssl_on, String initialization_vector) {
13-
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, initialization_vector );
14-
}
15-
16-
178
public Pubnub(String publish_key, String subscribe_key, String secret_key,
189
String cipher_key, boolean ssl_on) {
19-
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, DEFAULT_IV );
10+
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on);
2011
}
2112

2213
public Pubnub(String publish_key, String subscribe_key, String secret_key,
2314
boolean ssl_on) {
24-
super(publish_key, subscribe_key, secret_key, "", ssl_on, "");
15+
super(publish_key, subscribe_key, secret_key, "", ssl_on);
2516
}
2617

2718

2819
public Pubnub(String publish_key, String subscribe_key) {
29-
super(publish_key, subscribe_key, "", "", false, "");
20+
super(publish_key, subscribe_key, "", "", false);
3021
}
3122

3223
public Pubnub(String publish_key, String subscribe_key, boolean ssl) {
33-
super(publish_key, subscribe_key, "", "", ssl, "");
24+
super(publish_key, subscribe_key, "", "", ssl);
3425
}
3526

3627
public Pubnub(String publish_key, String subscribe_key, String secret_key) {
37-
super(publish_key, subscribe_key, secret_key, "", false, "");
28+
super(publish_key, subscribe_key, secret_key, "", false);
3829
}
3930

4031
/**

‎gwt/3.3/src/pubnub/api/Pubnub.java‎

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ public class Pubnub {
4444
private String SUBSCRIBE_KEY = "";
4545
private String SECRET_KEY = "";
4646
public String CIPHER_KEY = "";
47-
public String INITIALIZATION_VECTOR = "";
48-
49-
/** The default initialization vector. */
50-
private static final String DEFAULT_IV = "0123456789012345";
51-
5247
private boolean SSL = false;
5348
private String sessionUUID = "";
5449
private String parameters = "";
@@ -74,34 +69,10 @@ private class ChannelStatus {
7469
* @param String
7570
* Cipher Key.
7671
* @param boolean SSL Enabled.
77-
*
78-
* @param initialization_vector The initialization vector used to create the cipher.
79-
*/
80-
public Pubnub(String publish_key, String subscribe_key, String secret_key,
81-
String cipher_key, boolean ssl_on, String initialization_vector) {
82-
this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, initialization_vector);
83-
}
84-
85-
/**
86-
* PubNub 3.1 with Cipher Key
87-
*
88-
* Prepare PubNub State.
89-
*
90-
* @param String
91-
* Publish Key.
92-
* @param String
93-
* Subscribe Key.
94-
* @param String
95-
* Secret Key.
96-
* @param String
97-
* Cipher Key.
98-
* @param boolean SSL Enabled.
99-
*
100-
* .
10172
*/
10273
public Pubnub(String publish_key, String subscribe_key, String secret_key,
103-
String cipher_key, boolean ssl_on) {
104-
this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, DEFAULT_IV);
74+
String cipher_key, boolean ssl_on) {
75+
this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on);
10576
}
10677

10778
/**
@@ -119,7 +90,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
11990
*/
12091
public Pubnub(String publish_key, String subscribe_key, String secret_key,
12192
boolean ssl_on) {
122-
this.init(publish_key, subscribe_key, secret_key, "", ssl_on, "");
93+
this.init(publish_key, subscribe_key, secret_key, "", ssl_on);
12394
}
12495

12596
/**
@@ -133,7 +104,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
133104
* Subscribe Key.
134105
*/
135106
public Pubnub(String publish_key, String subscribe_key) {
136-
this.init(publish_key, subscribe_key, "", "", false, "");
107+
this.init(publish_key, subscribe_key, "", "", false);
137108
}
138109

139110
/**
@@ -149,7 +120,7 @@ public Pubnub(String publish_key, String subscribe_key) {
149120
* Secret Key.
150121
*/
151122
public Pubnub(String publish_key, String subscribe_key, String secret_key) {
152-
this.init(publish_key, subscribe_key, secret_key, "", false, "");
123+
this.init(publish_key, subscribe_key, secret_key, "", false);
153124
}
154125

155126
/**
@@ -166,15 +137,13 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key) {
166137
* @param String
167138
* Cipher Key.
168139
* @param boolean SSL Enabled.
169-
* @param String Initialization vector used to configure the cipher.
170140
*/
171141
public void init(String publish_key, String subscribe_key,
172-
String secret_key, String cipher_key, boolean ssl_on, String initialization_vector) {
142+
String secret_key, String cipher_key, boolean ssl_on) {
173143
this.PUBLISH_KEY = publish_key;
174144
this.SUBSCRIBE_KEY = subscribe_key;
175145
this.SECRET_KEY = secret_key;
176146
this.CIPHER_KEY = cipher_key;
177-
this.INITIALIZATION_VECTOR = initialization_vector;
178147
this.SSL = ssl_on;
179148

180149
if (this.sessionUUID.equals(""))
@@ -223,7 +192,7 @@ public JSONArray publish(HashMap<String, Object> args) {
223192
JSONObject obj = (JSONObject) message;
224193
if (this.CIPHER_KEY.length() > 0) {
225194
// Encrypt Message
226-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
195+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
227196
message = pc.encrypt(obj);
228197
} else {
229198
message = obj;
@@ -233,7 +202,7 @@ public JSONArray publish(HashMap<String, Object> args) {
233202
String obj = (String) message;
234203
if (this.CIPHER_KEY.length() > 0) {
235204
// Encrypt Message
236-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
205+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
237206
try {
238207
message = pc.encrypt(obj);
239208
} catch (Exception e) {
@@ -249,7 +218,7 @@ public JSONArray publish(HashMap<String, Object> args) {
249218

250219
if (this.CIPHER_KEY.length() > 0) {
251220
// Encrypt Message
252-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
221+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
253222
message = pc.encryptJSONArray(obj);
254223
} else {
255224
message = obj;
@@ -468,7 +437,7 @@ private void _subscribe(HashMap<String, Object> args) {
468437

469438
if (this.CIPHER_KEY.length() > 0) {
470439
// Decrypt Message
471-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
440+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
472441
message = pc.decrypt(message);
473442
}
474443
if (callback != null)
@@ -479,7 +448,7 @@ private void _subscribe(HashMap<String, Object> args) {
479448
if (arr != null) {
480449
if (this.CIPHER_KEY.length() > 0) {
481450
PubnubCrypto pc = new PubnubCrypto(
482-
this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
451+
this.CIPHER_KEY);
483452
arr = pc.decryptJSONArray(arr);
484453
;
485454
}
@@ -489,7 +458,7 @@ private void _subscribe(HashMap<String, Object> args) {
489458
String msgs = messages.getString(0);
490459
if (this.CIPHER_KEY.length() > 0) {
491460
PubnubCrypto pc = new PubnubCrypto(
492-
this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
461+
this.CIPHER_KEY);
493462
msgs = pc.decrypt(msgs);
494463
}
495464
if (callback != null)
@@ -689,7 +658,7 @@ private void _presence(HashMap<String, Object> args) {
689658

690659
if (this.CIPHER_KEY.length() > 0) {
691660
// Decrypt Message
692-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
661+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
693662
message = pc.decrypt(message);
694663
}
695664
if (callback != null)
@@ -700,7 +669,7 @@ private void _presence(HashMap<String, Object> args) {
700669
if (arr != null) {
701670
if (this.CIPHER_KEY.length() > 0) {
702671
PubnubCrypto pc = new PubnubCrypto(
703-
this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
672+
this.CIPHER_KEY);
704673
arr = pc.decryptJSONArray(arr);
705674
}
706675
if (callback != null)
@@ -709,7 +678,7 @@ private void _presence(HashMap<String, Object> args) {
709678
String msgs = messages.getString(0);
710679
if (this.CIPHER_KEY.length() > 0) {
711680
PubnubCrypto pc = new PubnubCrypto(
712-
this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
681+
this.CIPHER_KEY);
713682
msgs = pc.decrypt(msgs);
714683
}
715684
if (callback != null)
@@ -748,7 +717,7 @@ public JSONArray here_now(String channel) {
748717

749718
if (this.CIPHER_KEY.length() > 0) {
750719
// Decrypt Messages
751-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
720+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
752721
return pc.decryptJSONArray(response);
753722
} else {
754723
return response;
@@ -798,7 +767,7 @@ public JSONArray history(HashMap<String, Object> args) {
798767

799768
if (this.CIPHER_KEY.length() > 0) {
800769
// Decrypt Messages
801-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
770+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
802771
return pc.decryptJSONArray(response);
803772
} else {
804773
return response;
@@ -835,7 +804,7 @@ public JSONArray detailedHistory(String channel, long start, long end, int count
835804
JSONArray response = _request(url);
836805

837806
if (this.CIPHER_KEY.length() > 0) {
838-
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY, this.INITIALIZATION_VECTOR);
807+
PubnubCrypto pc = new PubnubCrypto(this.CIPHER_KEY);
839808
try {
840809
return pc.decryptJSONArray(response.getJSONArray(0));
841810
} catch (JSONException e) {
@@ -1221,10 +1190,8 @@ class PubnubCrypto {
12211190

12221191
private final String CIPHER_KEY;
12231192

1224-
private final String INITIALIZATION_VECTOR;
1225-
public PubnubCrypto(String CIPHER_KEY, String INITIALIZATION_VECTOR) {
1193+
public PubnubCrypto(String CIPHER_KEY) {
12261194
this.CIPHER_KEY = CIPHER_KEY;
1227-
this.INITIALIZATION_VECTOR = INITIALIZATION_VECTOR;
12281195
}
12291196

12301197
/**
@@ -1369,7 +1336,7 @@ public String decrypt(String cipher_text) throws Exception {
13691336
*/
13701337
private byte[] transform(boolean encrypt_or_decrypt, byte[] input_bytes) throws Exception {
13711338
ByteArrayOutputStream output = new ByteArrayOutputStream();
1372-
byte[] iv_bytes = INITIALIZATION_VECTOR.getBytes();
1339+
byte[] iv_bytes = "0123456789012345".getBytes();
13731340
byte[] key_bytes = md5(this.CIPHER_KEY);
13741341

13751342
SecretKeySpec key = new SecretKeySpec(key_bytes, "AES");

0 commit comments

Comments
 (0)