@@ -94,9 +94,73 @@ public final Grant.GrantBuilder grant() {
9494 return Grant .builder ().pubnub (this );
9595 }
9696
97- public GetState .GetStateBuilder getPresenceState () { return GetState .builder ().pubnub (this ); }
98- public SetState .SetStateBuilder setPresenceState () { return SetState .builder ().pubnub (this ).subscriptionManager (subscriptionManager ); }
97+ public final GetState .GetStateBuilder getPresenceState () {
98+ return GetState .builder ().pubnub (this );
99+ }
100+ public final SetState .SetStateBuilder setPresenceState () {
101+ return SetState .builder ().pubnub (this ).subscriptionManager (subscriptionManager );
102+ }
103+
104+ public final Publish .PublishBuilder publish () {
105+ return Publish .builder ().pubnub (this );
106+ }
99107
100- public Publish .PublishBuilder publish () { return Publish .builder ().pubnub (this ); }
108+ // public methods
109+
110+ /**
111+ * Perform Cryptographic decryption of an input string using cipher key provided by PNConfiguration
112+ * @param inputString String to be encrypted
113+ * @return String containing the encryption of inputString using cipherKey
114+ */
115+ public final String decrypt (String inputString ) throws PubnubException {
116+ if (inputString == null ) {
117+ throw new PubnubException (PubnubError .PNERROBJ_INVALID_ARGUMENTS );
118+ }
119+
120+ return decrypt (inputString , this .getConfiguration ().getCipherKey ());
121+ }
122+
123+ /**
124+ * Perform Cryptographic decryption of an input string using the cipher key
125+ * @param inputString String to be encrypted
126+ * @param cipherKey cipher key to be used for encryption
127+ * @throws PubnubException throws exception in case of failed encryption
128+ * @return String containing the encryption of inputString using cipherKey
129+ */
130+ public final String decrypt (final String inputString , final String cipherKey ) throws PubnubException {
131+ if (inputString == null ) {
132+ throw new PubnubException (PubnubError .PNERROBJ_INVALID_ARGUMENTS );
133+ }
134+
135+ return new Crypto (cipherKey ).decrypt (inputString );
136+ }
137+
138+ /**
139+ * Perform Cryptographic encryption of an input string and the cipher key provided by PNConfiguration
140+ * @param inputString String to be encrypted
141+ * @return String containing the encryption of inputString using cipherKey
142+ */
143+ public final String encrypt (String inputString ) throws PubnubException {
144+ if (inputString == null ) {
145+ throw new PubnubException (PubnubError .PNERROBJ_INVALID_ARGUMENTS );
146+ }
147+
148+ return encrypt (inputString , this .getConfiguration ().getCipherKey ());
149+ }
150+
151+ /**
152+ * Perform Cryptographic encryption of an input string and the cipher key
153+ * @param inputString String to be encrypted
154+ * @param cipherKey cipher key to be used for encryption
155+ * @throws PubnubException throws exception in case of failed encryption
156+ * @return String containing the encryption of inputString using cipherKey
157+ */
158+ public final String encrypt (final String inputString , final String cipherKey ) throws PubnubException {
159+ if (inputString == null ) {
160+ throw new PubnubException (PubnubError .PNERROBJ_INVALID_ARGUMENTS );
161+ }
162+
163+ return new Crypto (cipherKey ).encrypt (inputString );
164+ }
101165
102166}
0 commit comments