88import com .pubnub .api .endpoints .Time ;
99import com .pubnub .api .endpoints .access .Audit ;
1010import com .pubnub .api .endpoints .access .Grant ;
11- import com .pubnub .api .endpoints .channel_groups .*;
11+ import com .pubnub .api .endpoints .channel_groups .AddChannelChannelGroup ;
12+ import com .pubnub .api .endpoints .channel_groups .AllChannelsChannelGroup ;
13+ import com .pubnub .api .endpoints .channel_groups .DeleteChannelGroup ;
14+ import com .pubnub .api .endpoints .channel_groups .RemoveChannelChannelGroup ;
15+ import com .pubnub .api .endpoints .channel_groups .ListAllChannelGroup ;
1216import com .pubnub .api .endpoints .presence .GetState ;
1317import com .pubnub .api .endpoints .presence .HereNow ;
1418import com .pubnub .api .endpoints .presence .SetState ;
1519import com .pubnub .api .endpoints .presence .WhereNow ;
1620import com .pubnub .api .endpoints .pubsub .Publish ;
17- import com .pubnub .api .endpoints .push .*;
21+ import com .pubnub .api .endpoints .push .AddChannelsToPush ;
22+ import com .pubnub .api .endpoints .push .RemoveChannelsFromPush ;
23+ import com .pubnub .api .endpoints .push .RemoveAllPushChannelsForDevice ;
24+ import com .pubnub .api .endpoints .push .ListPushProvisions ;
1825import com .pubnub .api .managers .BasePathManager ;
1926import com .pubnub .api .managers .PublishSequenceManager ;
2027import com .pubnub .api .managers .SubscriptionManager ;
28+ import com .pubnub .api .vendor .Crypto ;
2129import lombok .AccessLevel ;
2230import lombok .Getter ;
2331import lombok .extern .slf4j .Slf4j ;
@@ -43,11 +51,14 @@ public class PubNub {
4351
4452 private String sdkVersion ;
4553
54+ private static final int TIMESTAMP_DIVIDER = 1000 ;
55+ private static final int MAX_SEQUENCE = 65535 ;
56+
4657 public PubNub (final PNConfiguration initialConfig ) {
4758 this .configuration = initialConfig ;
4859 this .subscriptionManager = new SubscriptionManager (this );
4960 this .basePathManager = new BasePathManager (initialConfig );
50- this .publishSequenceManager = new PublishSequenceManager (65535 );
61+ this .publishSequenceManager = new PublishSequenceManager (MAX_SEQUENCE );
5162
5263 sdkVersion = fetchSDKVersion ();
5364 }
@@ -70,7 +81,9 @@ public final SubscribeBuilder subscribe() {
7081 return new SubscribeBuilder (this .subscriptionManager );
7182 }
7283
73- public final UnsubscribeBuilder unsubscribe () { return new UnsubscribeBuilder (this .subscriptionManager ); }
84+ public final UnsubscribeBuilder unsubscribe () {
85+ return new UnsubscribeBuilder (this .subscriptionManager );
86+ }
7487
7588 // start push
7689
@@ -95,6 +108,7 @@ public final ListPushProvisions auditPushChannelProvisions() {
95108 public final WhereNow whereNow () {
96109 return new WhereNow (this );
97110 }
111+
98112 public final HereNow hereNow () {
99113 return new HereNow (this );
100114 }
@@ -103,19 +117,23 @@ public final Time time() {
103117 return new Time (this );
104118 }
105119
106- public final History history () { return new History (this ); }
120+ public final History history () {
121+ return new History (this );
122+ }
107123
108124
109125 public final Audit audit () {
110126 return new Audit (this );
111127 }
128+
112129 public final Grant grant () {
113130 return new Grant (this );
114131 }
115132
116133 public final GetState getPresenceState () {
117134 return new GetState (this );
118135 }
136+
119137 public final SetState setPresenceState () {
120138 return new SetState (this , subscriptionManager );
121139 }
@@ -148,6 +166,7 @@ public final DeleteChannelGroup deleteChannelGroup() {
148166
149167 /**
150168 * Perform Cryptographic decryption of an input string using cipher key provided by PNConfiguration
169+ *
151170 * @param inputString String to be encrypted
152171 * @return String containing the encryption of inputString using cipherKey
153172 */
@@ -161,10 +180,11 @@ public final String decrypt(String inputString) throws PubNubException {
161180
162181 /**
163182 * Perform Cryptographic decryption of an input string using the cipher key
183+ *
164184 * @param inputString String to be encrypted
165- * @param cipherKey cipher key to be used for encryption
166- * @throws PubNubException throws exception in case of failed encryption
185+ * @param cipherKey cipher key to be used for encryption
167186 * @return String containing the encryption of inputString using cipherKey
187+ * @throws PubNubException throws exception in case of failed encryption
168188 */
169189 public final String decrypt (final String inputString , final String cipherKey ) throws PubNubException {
170190 if (inputString == null ) {
@@ -176,6 +196,7 @@ public final String decrypt(final String inputString, final String cipherKey) th
176196
177197 /**
178198 * Perform Cryptographic encryption of an input string and the cipher key provided by PNConfiguration
199+ *
179200 * @param inputString String to be encrypted
180201 * @return String containing the encryption of inputString using cipherKey
181202 */
@@ -189,10 +210,11 @@ public final String encrypt(final String inputString) throws PubNubException {
189210
190211 /**
191212 * Perform Cryptographic encryption of an input string and the cipher key.
213+ *
192214 * @param inputString String to be encrypted
193- * @param cipherKey cipher key to be used for encryption
194- * @throws PubNubException throws exception in case of failed encryption
215+ * @param cipherKey cipher key to be used for encryption
195216 * @return String containing the encryption of inputString using cipherKey
217+ * @throws PubNubException throws exception in case of failed encryption
196218 */
197219 public final String encrypt (final String inputString , final String cipherKey ) throws PubNubException {
198220 if (inputString == null ) {
@@ -203,7 +225,7 @@ public final String encrypt(final String inputString, final String cipherKey) th
203225 }
204226
205227 public int getTimestamp () {
206- return (int ) ((new Date ().getTime ()) / 1000 );
228+ return (int ) ((new Date ().getTime ()) / TIMESTAMP_DIVIDER );
207229 }
208230
209231 /**
@@ -229,6 +251,7 @@ public final void reconnect() {
229251
230252 /**
231253 * fetch the SDK version from the resource files.
254+ *
232255 * @return Stringified representation of the SDK version.
233256 */
234257 private String fetchSDKVersion () {
0 commit comments