Package org.forgerock.android.auth
Class PushNotification
- java.lang.Object
-
- org.forgerock.android.auth.PushNotification
-
- All Implemented Interfaces:
java.lang.Comparable<PushNotification>
public class PushNotification extends java.lang.ObjectPushNotification is a model class which represents a message that was received from an external source. A notification could be raised against any mechanism. Currently used by Push mechanism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPushNotification.PushNotificationBuilderBuilder class responsible for producing Notifications.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(java.lang.String title, java.lang.String subtitle, boolean allowDeviceCredentials, androidx.appcompat.app.AppCompatActivity activity, FRAListener<java.lang.Void> listener)Accepts the push notification request with Biometric Authentication.voidaccept(java.lang.String challengeResponse, FRAListener<java.lang.Void> listener)Accepts the push notification request with the challenge response.voidaccept(FRAListener<java.lang.Void> listener)Accepts the push authentication request.static PushNotification.PushNotificationBuilderbuilder()Returns a builder for creating a PushNotification.intcompareTo(PushNotification another)voiddeny(FRAListener<java.lang.Void> listener)Deny any type of push authentication request.static PushNotificationdeserialize(java.lang.String jsonString)Deserializes the specified Json into an object of thePushNotificationobject.booleanequals(java.lang.Object o)java.lang.StringgetAmlbCookie()Get load balance cookie from OpenAMjava.lang.StringgetChallenge()Get challenge from message payloadjava.lang.StringgetContextInfo()Get the contextual information to this notification.java.lang.StringgetCustomPayload()Get the custom attributes added to this notification.java.lang.StringgetId()Gets the unique identifier for the PushNotification.java.lang.StringgetMechanismUID()Get the mechanism Id that this notification was intended for.java.lang.StringgetMessage()Get the message of this notificationjava.lang.StringgetMessageId()Get the message Id of this notificationint[]getNumbersChallenge()Get numbers used for push challengePushTypegetPushType()Get the type of Push notification.java.util.CalendargetTimeAdded()Get the time that this notification was received.java.util.CalendargetTimeExpired()Get the time that the notification will or did expire.longgetTtl()Get time-to-live value from message payloadinthashCode()booleanisApproved()Determine whether the authentication the notification is related to succeeded.booleanisExpired()Determine if the notification has expired.booleanisPending()Determines if the PushNotification has been interacted with by the user.booleanmatches(PushNotification other)Returns true if the two objects would conflict if added to a storage system.java.lang.StringtoJson()Creates a JSON string representation ofModelObjectobject.
-
-
-
Method Detail
-
getId
public java.lang.String getId()
Gets the unique identifier for the PushNotification.- Returns:
- The unique identifier.
-
getMechanismUID
public java.lang.String getMechanismUID()
Get the mechanism Id that this notification was intended for.- Returns:
- The receiving Mechanism.
-
getMessageId
public java.lang.String getMessageId()
Get the message Id of this notification- Returns:
- The messageId value
-
getMessage
public java.lang.String getMessage()
Get the message of this notification- Returns:
- The message value
-
getChallenge
public java.lang.String getChallenge()
Get challenge from message payload- Returns:
- The challenge value
-
getAmlbCookie
public java.lang.String getAmlbCookie()
Get load balance cookie from OpenAM- Returns:
- The load balance cookie value
-
getTtl
public long getTtl()
Get time-to-live value from message payload- Returns:
- The time-to-live value
-
getTimeAdded
public java.util.Calendar getTimeAdded()
Get the time that this notification was received.- Returns:
- The date the notification was received.
-
getTimeExpired
public java.util.Calendar getTimeExpired()
Get the time that the notification will or did expire.- Returns:
- The expiry date.
-
getContextInfo
public java.lang.String getContextInfo()
Get the contextual information to this notification.- Returns:
- JSON String containing context information to this notification.
-
getCustomPayload
public java.lang.String getCustomPayload()
Get the custom attributes added to this notification.- Returns:
- JSON String containing custom attributes added to the payload of this notification.
-
getPushType
public PushType getPushType()
Get the type of Push notification.- Returns:
- the push type.
-
getNumbersChallenge
public int[] getNumbersChallenge()
Get numbers used for push challenge- Returns:
- the numbers as int array. Returns {null} if "numbersChallenge" is not available
-
isApproved
public boolean isApproved()
Determine whether the authentication the notification is related to succeeded.- Returns:
- True if the authentication succeeded, false otherwise.
-
isPending
public boolean isPending()
Determines if the PushNotification has been interacted with by the user.- Returns:
- True if the PushNotification has not been interacted with, false otherwise.
-
isExpired
public final boolean isExpired()
Determine if the notification has expired.- Returns:
- True if the notification has expired, false otherwise.
-
toJson
public java.lang.String toJson()
Creates a JSON string representation ofModelObjectobject. Sensitive information are not exposed.- Returns:
- a JSON string object
-
accept
public final void accept(@NonNull FRAListener<java.lang.Void> listener)Accepts the push authentication request. Use this method to approve notification of typePushType.DEFAULT.- Parameters:
listener- Listener for receiving the authentication result.
-
accept
public final void accept(@NonNull java.lang.String challengeResponse, @NonNull FRAListener<java.lang.Void> listener)Accepts the push notification request with the challenge response. Use this method to handle notification of typePushType.CHALLENGE.- Parameters:
challengeResponse- the response for the Push Challengelistener- Listener for receiving the authentication result.
-
accept
@RequiresApi(23) public final void accept(java.lang.String title, java.lang.String subtitle, boolean allowDeviceCredentials, @NonNull androidx.appcompat.app.AppCompatActivity activity, @NonNull FRAListener<java.lang.Void> listener)Accepts the push notification request with Biometric Authentication. Use this method to handle notification of typePushType.BIOMETRIC.- Parameters:
title- the title to be displayed on the prompt.subtitle- the subtitle to be displayed on the prompt.allowDeviceCredentials- iftrue, accepts device PIN, pattern, or password to process notification.activity- the activity of the client application that will host the prompt.listener- listener for receiving the push authentication result.
-
deny
public final void deny(@NonNull FRAListener<java.lang.Void> listener)Deny any type of push authentication request.- Parameters:
listener- Listener for receiving the HTTP call response code.
-
deserialize
public static PushNotification deserialize(java.lang.String jsonString)
Deserializes the specified Json into an object of thePushNotificationobject.- Parameters:
jsonString- the json string representing the object to be deserialized- Returns:
- a
PushNotificationobject from the string. ReturnsnullifjsonStringisnullor ifjsonStringis empty.
-
matches
public boolean matches(PushNotification other)
Returns true if the two objects would conflict if added to a storage system.- Parameters:
other- The object to compare.- Returns:
- True if key traits of the objects match, false otherwise.
-
compareTo
public int compareTo(PushNotification another)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
builder
public static PushNotification.PushNotificationBuilder builder()
Returns a builder for creating a PushNotification.- Returns:
- The PushNotification builder.
-
-