Package io.getstream.chat.java.models
Class App
- java.lang.Object
-
- io.getstream.chat.java.models.framework.StreamResponseObject
-
- io.getstream.chat.java.models.App
-
- All Implemented Interfaces:
StreamResponse,StreamResponseWithRateLimit
public class App extends StreamResponseObject
-
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description App()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)static @NotNull App.AppCheckPushRequestData.AppCheckPushRequestcheckPush()Creates a check push request.static @NotNull App.AppCheckSnsRequestData.AppCheckSnsRequestcheckSns()Creates a check SNS request.static @NotNull App.AppCheckSqsRequestData.AppCheckSqsRequestcheckSqs()Creates a check SQS request.static byte[]decodeSnsPayload(@NotNull java.lang.String notificationBody)Reverses an SNS HTTP notification envelope.static byte[]decodeSqsPayload(@NotNull java.lang.String body)Reverses the SQS firehose envelope: the messageBodyis base64-decoded and, when the result begins with the gzip magic, it is gzip-decompressed.static @NotNull App.DeletePushProviderRequestdeletePushProvider(@NotNull java.lang.String providerType, @NotNull java.lang.String name)Creates a delete push provider requestbooleanequals(java.lang.Object o)static @NotNull App.AppGetRequestget()Creates a get request.@Nullable App.AppConfiggetApp()static @NotNull App.AppGetRateLimitsRequestgetRateLimits()Creates a get rate limits request.static byte[]gunzipPayload(@org.jetbrains.annotations.NotNull byte[] body)Returnsbodyunchanged unless it starts with the gzip magic (1f 8b, per RFC 1952), in which case the gzip stream is inflated and the decompressed bytes are returned.inthashCode()static @NotNull App.ListPushProvidersRequestlistPushProviders()Creates a list push providers requeststatic @NotNull EventparseEvent(@org.jetbrains.annotations.NotNull byte[] payload)Parse a JSON-encoded webhook event into a typedEvent.static @NotNull EventparseSns(@NotNull java.lang.String notificationBody)Decode an SNS-delivered payload (unwraps envelope JSON when needed) and return the parsedEvent.static @NotNull EventparseSqs(@NotNull java.lang.String messageBody)Decode the SQSBody(base64, then gzip-if-magic) and return the parsedEvent.static @NotNull App.AppRevokeTokensRequestrevokeTokens(@Nullable java.util.Date revokeTokensIssuedBefore)Creates a revoke tokens requestvoidsetApp(@Nullable App.AppConfig app)java.lang.StringtoString()static @NotNull App.AppUpdateRequestData.AppUpdateRequestupdate()Creates an update request.static @NotNull App.PushProviderRequestData.PushProviderRequestupsertPushProvider()Creates an upsert push provider requeststatic @NotNull EventverifyAndParseWebhook(@org.jetbrains.annotations.NotNull byte[] body, @NotNull java.lang.String signature)Singleton-secret overload: uses the API secret of the configuredClientsingleton.static @NotNull EventverifyAndParseWebhook(@org.jetbrains.annotations.NotNull byte[] body, @NotNull java.lang.String signature, @NotNull java.lang.String secret)static booleanverifySignature(@org.jetbrains.annotations.NotNull byte[] body, @NotNull java.lang.String signature, @NotNull java.lang.String secret)Constant-time HMAC-SHA256 verification ofsignatureagainst the digest ofbodyusingsecretas the key.booleanverifyWebhook(@NotNull java.lang.String body, @NotNull java.lang.String signature)Validates if hmac signature is correct for the message body.static booleanverifyWebhookSignature(@NotNull java.lang.String body, @NotNull java.lang.String signature)Validates if hmac signature is correct for the message body using the singleton client's API secret.static booleanverifyWebhookSignature(@NotNull java.lang.String apiSecret, @NotNull java.lang.String body, @NotNull java.lang.String signature)Validates if hmac signature is correct for message body.-
Methods inherited from class io.getstream.chat.java.models.framework.StreamResponseObject
getDuration, getRateLimit, setDuration, setRateLimit
-
-
-
-
Method Detail
-
get
@NotNull public static @NotNull App.AppGetRequest get()
Creates a get request.- Returns:
- the created request
-
update
@NotNull public static @NotNull App.AppUpdateRequestData.AppUpdateRequest update()
Creates an update request.- Returns:
- the created request
-
getRateLimits
@NotNull public static @NotNull App.AppGetRateLimitsRequest getRateLimits()
Creates a get rate limits request.- Returns:
- the created request
-
checkSqs
@NotNull public static @NotNull App.AppCheckSqsRequestData.AppCheckSqsRequest checkSqs()
Creates a check SQS request.- Returns:
- the created request
-
checkSns
@NotNull public static @NotNull App.AppCheckSnsRequestData.AppCheckSnsRequest checkSns()
Creates a check SNS request.- Returns:
- the created request
-
checkPush
@NotNull public static @NotNull App.AppCheckPushRequestData.AppCheckPushRequest checkPush()
Creates a check push request.- Returns:
- the created request
-
revokeTokens
@NotNull public static @NotNull App.AppRevokeTokensRequest revokeTokens(@Nullable @Nullable java.util.Date revokeTokensIssuedBefore)
Creates a revoke tokens request- Parameters:
revokeTokensIssuedBefore- the limit date to revoke tokens- Returns:
- the created request
-
upsertPushProvider
@NotNull public static @NotNull App.PushProviderRequestData.PushProviderRequest upsertPushProvider()
Creates an upsert push provider request- Returns:
- the created request
-
listPushProviders
@NotNull public static @NotNull App.ListPushProvidersRequest listPushProviders()
Creates a list push providers request- Returns:
- the created request
-
deletePushProvider
@NotNull public static @NotNull App.DeletePushProviderRequest deletePushProvider(@NotNull @NotNull java.lang.String providerType, @NotNull @NotNull java.lang.String name)
Creates a delete push provider request- Parameters:
providerType- push provider typename- push provider name- Returns:
- the created request
-
verifyWebhook
public boolean verifyWebhook(@NotNull @NotNull java.lang.String body, @NotNull @NotNull java.lang.String signature)Validates if hmac signature is correct for the message body.Kept for backward compatibility. New integrations should call
verifyAndParseWebhook(byte[], String)(or the SQS / SNS variants), which also handle gzip payload compression.- Parameters:
body- raw body from http request converted to a string.signature- the signature provided in X-Signature header- Returns:
- true if the signature is valid
-
verifyWebhookSignature
public static boolean verifyWebhookSignature(@NotNull @NotNull java.lang.String apiSecret, @NotNull @NotNull java.lang.String body, @NotNull @NotNull java.lang.String signature)Validates if hmac signature is correct for message body. Backward-compatible alias forverifySignature(byte[], String, String).- Parameters:
apiSecret- the secret keybody- raw body from http request converted to a string.signature- the signature provided in X-Signature header- Returns:
- true if the signature is valid
-
verifyWebhookSignature
public static boolean verifyWebhookSignature(@NotNull @NotNull java.lang.String body, @NotNull @NotNull java.lang.String signature)Validates if hmac signature is correct for the message body using the singleton client's API secret.- Parameters:
body- the message bodysignature- the signature provided in X-Signature header- Returns:
- true if the signature is valid
-
verifySignature
public static boolean verifySignature(@NotNull @org.jetbrains.annotations.NotNull byte[] body, @NotNull @NotNull java.lang.String signature, @NotNull @NotNull java.lang.String secret)Constant-time HMAC-SHA256 verification ofsignatureagainst the digest ofbodyusingsecretas the key.The signature is always computed over the uncompressed JSON bytes, so callers that decoded a gzipped or base64-wrapped payload must pass the inflated bytes here.
- Parameters:
body- the uncompressed body bytessignature- the signature provided inX-Signaturesecret- the app's API secret- Returns:
- true if the signature matches
-
gunzipPayload
public static byte[] gunzipPayload(@NotNull @org.jetbrains.annotations.NotNull byte[] body)Returnsbodyunchanged unless it starts with the gzip magic (1f 8b, per RFC 1952), in which case the gzip stream is inflated and the decompressed bytes are returned.Magic-byte detection (rather than relying on a header) lets the same handler stay correct when middleware auto-decompresses the request before your code sees it.
-
decodeSqsPayload
public static byte[] decodeSqsPayload(@NotNull @NotNull java.lang.String body)Reverses the SQS firehose envelope: the messageBodyis base64-decoded and, when the result begins with the gzip magic, it is gzip-decompressed. The same call works whether or not Stream is currently compressing payloads.- Parameters:
body- the SQS messageBody- Returns:
- the raw JSON bytes Stream signed
-
decodeSnsPayload
public static byte[] decodeSnsPayload(@NotNull @NotNull java.lang.String notificationBody)Reverses an SNS HTTP notification envelope. WhennotificationBodyis a JSON envelope ({"Type":"Notification","Message":"..."}), the innerMessagefield is extracted and run through the SQS pipeline (base64-decode, then gzip-if-magic). When the input is not a JSON envelope it is treated as the already-extractedMessagestring, so call sites that pre-unwrap continue to work.
-
parseEvent
@NotNull public static @NotNull Event parseEvent(@NotNull @org.jetbrains.annotations.NotNull byte[] payload)
Parse a JSON-encoded webhook event into a typedEvent. Unknown event types still parse successfully becauseEvent.getType()is a free-form string; unknown nested fields and unknown enum values are tolerated so the handler stays forward-compatible with new Stream server releases.- Throws:
InvalidWebhookError- when the bytes are not valid JSON
-
verifyAndParseWebhook
@NotNull public static @NotNull Event verifyAndParseWebhook(@NotNull @org.jetbrains.annotations.NotNull byte[] body, @NotNull @NotNull java.lang.String signature, @NotNull @NotNull java.lang.String secret)
Decompressesbodywhen gzipped, verifies the HMACsignature, and returns the parsedEvent. Works for HTTP webhooks regardless of whether payload compression is enabled.- Parameters:
body- raw HTTP request body bytes Stream signedsignature- value of theX-Signatureheadersecret- the app's API secret- Returns:
- the parsed event
- Throws:
InvalidWebhookError- when the signature does not match, the gzip envelope is malformed, or the payload is not JSON
-
verifyAndParseWebhook
@NotNull public static @NotNull Event verifyAndParseWebhook(@NotNull @org.jetbrains.annotations.NotNull byte[] body, @NotNull @NotNull java.lang.String signature)
Singleton-secret overload: uses the API secret of the configuredClientsingleton.
-
parseSqs
@NotNull public static @NotNull Event parseSqs(@NotNull @NotNull java.lang.String messageBody)
Decode the SQSBody(base64, then gzip-if-magic) and return the parsedEvent. Stream does not HMAC-sign SQS message bodies.
-
parseSns
@NotNull public static @NotNull Event parseSns(@NotNull @NotNull java.lang.String notificationBody)
Decode an SNS-delivered payload (unwraps envelope JSON when needed) and return the parsedEvent. No HMAC verification.
-
getApp
@Nullable public @Nullable App.AppConfig getApp()
-
setApp
public void setApp(@Nullable @Nullable App.AppConfig app)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classStreamResponseObject
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classStreamResponseObject
-
canEqual
protected boolean canEqual(java.lang.Object other)
- Overrides:
canEqualin classStreamResponseObject
-
hashCode
public int hashCode()
- Overrides:
hashCodein classStreamResponseObject
-
-