use of org.gluu.oxauth.client.ciba.fcm.FirebaseCloudMessagingRequest in project oxAuth by GluuFederation.
the class CIBAEndUserNotificationService method notifyEndUserUsingFCM.
/**
* Method responsible to send notifications to the end user using Firebase Cloud Messaging.
* @param deviceRegistrationToken Device already registered.
* @param scope Scope of the authorization request
* @param acrValues Acr values used to the authorzation request
* @param authReqId Authentication request id.
*/
private void notifyEndUserUsingFCM(String scope, String acrValues, String authReqId, String deviceRegistrationToken) {
String clientId = appConfiguration.getBackchannelClientId();
String redirectUri = appConfiguration.getBackchannelRedirectUri();
String url = appConfiguration.getCibaEndUserNotificationConfig().getNotificationUrl();
String key = cibaEncryptionService.decrypt(appConfiguration.getCibaEndUserNotificationConfig().getNotificationKey(), true);
String to = deviceRegistrationToken;
String title = "oxAuth Authentication Request";
String body = "Client Initiated Backchannel Authentication (CIBA)";
RedirectUri authorizationRequestUri = new RedirectUri(appConfiguration.getAuthorizationEndpoint());
authorizationRequestUri.addResponseParameter(CLIENT_ID, clientId);
authorizationRequestUri.addResponseParameter(RESPONSE_TYPE, "id_token");
authorizationRequestUri.addResponseParameter(SCOPE, scope);
authorizationRequestUri.addResponseParameter(ACR_VALUES, acrValues);
authorizationRequestUri.addResponseParameter(REDIRECT_URI, redirectUri);
authorizationRequestUri.addResponseParameter(STATE, UUID.randomUUID().toString());
authorizationRequestUri.addResponseParameter(NONCE, UUID.randomUUID().toString());
authorizationRequestUri.addResponseParameter(PROMPT, "consent");
authorizationRequestUri.addResponseParameter(AUTH_REQ_ID, authReqId);
String clickAction = authorizationRequestUri.toString();
FirebaseCloudMessagingRequest firebaseCloudMessagingRequest = new FirebaseCloudMessagingRequest(key, to, title, body, clickAction);
FirebaseCloudMessagingClient firebaseCloudMessagingClient = new FirebaseCloudMessagingClient(url);
firebaseCloudMessagingClient.setRequest(firebaseCloudMessagingRequest);
FirebaseCloudMessagingResponse firebaseCloudMessagingResponse = firebaseCloudMessagingClient.exec();
log.debug("CIBA: firebase cloud messaging result status " + firebaseCloudMessagingResponse.getStatus());
}
Aggregations