7.1 Customizing E-Mail and SMS Messaging Provider

You can customize e-mail and SMS message provider by implementing the MessagingProvider interface.

Prerequisites

Ensure you have the following prerequisites before proceeding:
  • Oracle Linux 7.x environment
  • JDK 1.8.x for compilation
  • Apache Maven 3.6.2 or later
  • Any third-party jars necessary for your implementation.

Implement Custom Logic and Create Jar files

  1. Download the project zip file from the following location in the management container: /u01/oracle/libs/messagingprovider-interface-oaa_122140-20210426.jar and extract it to your working directory.
  2. Create an implementation of your custom logic for e-mail and SMS. For more information about the interface and methods, see the Javadoc reference.

    Note:

    E-mail and SMS must have separate implementation classes.

    In the implementation class that implements the sender interface, make sure that @Service declaration is created with necessary imports. This declaration helps the framework to load the custom implementation at runtime.

  3. Make changes to the pom file for compiling and generating a jar file that includes this implementation. Ensure the following:
    • The jersey-hk2 dependency must be declared as dependency in the pom file for the build.
    • The MessagingProvider interface must be used and declared as dependency in the pom file for the build.
    • The implementation must generate one jar and additional third-party jars. You can choose to implement the send method using one or more classes and package them into this jar file.
  4. Test the implementation to make sure that it works as necessary.

Integrate the Implementation with OAA

  1. Configure the custom implementation class in OAA.
    • For e-mail:

      Update the customProvider property of the ChallengeEmail enum with fully qualified class name of the implementation class.

      For example, if the name of the implementation class is com.company.MyCustomEmailMessagingSender, update the ChallengeEmail enum property as bharosa.uio.default.challenge.type.enum.ChallengeEmail.customizedProvider=com.company.MyCustomEmailMessagingSender

      To do this, use the ConfigProperty REST API as shown in the following sample request:

      curl  --request PUT 'https://<OAA_HOST>:<OAA_PORT>/oaa/runtime/config/property/v1' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Basic <AUTH_HEADER/TOKEN>' \
      --data-raw '[
      {
      "name": "bharosa.uio.default.challenge.type.enum.ChallengeEmail.customizedProvider"
      "value": "com.company.MyCustomEmailMessagingSender"
      }
      ]'
    • For SMS:

      Update the customProvider property of the ChallengeSMS enum with fully qualified class name of the implementation class.

      For example, if the name of the implementation class is com.company.MyCustomSMSMessagingSender, update the ChallengeSMS enum property as bharosa.uio.default.challenge.type.enum.ChallengeSMS.customizedProvider=com.company.MyCustomSMSMessagingSender

      To do this, use the ConfigProperty REST API as shown in the following sample request:

      curl  --request PUT 'http://<OAA_HOST>:<OAA_PORT>/oaa/runtime/config/property/v1' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Basic <AUTH_HEADER/TOKEN>' \
      --data-raw '[
      {
      "name": "bharosa.uio.default.challenge.type.enum.ChallengeSMS.customizedProvider"
      "value": "com.company.MyCustomSMSMessagingSender"
      }
      ]'

Make the Implementation Available at Runtime

When the email or SMS service pods are configured/started, shared volume information is made part of that configuration. It appears in the deployment.yaml file of that chart.

Create a persistent NFS volume and provide that information in the values.yaml for the email chart as shown in the following sample.

Note:

Do not change the mountPathPrefix value
# volume to store customized email sending implementation
customizedFactorImplVolume:
  # name of the volume
  name: "nfsvolume"
  # server where the volume is located
  server: 100.102.49.49
  # path on the server where the volume is located
  path: /public-uas-dev/FactorProviderImpls
  # prefix of volume's mounted path in email container
  mountPathPrefix: /u01/oracle/
  # relative path of mounted volume, relative to the above prefix
  mountRelativePath: nfsvol1/customprovider
  # indicate whether the volume should be readOnly
  readOnly: false
  # names of customizedJars expected in mounted volume, separated by comma
  customizedJars: "OAACustomMessaging-Provider.jar"
If the external volume is not NFS then perform the following:
  1. Edit the deployment.yaml file in the email chart as shown:
    {{- if .Values.customizedFactorImplVolume }}
            - name: {{.Values.customizedFactorImplVolume.name}}
              nfs:
                server: {{.Values.customizedFactorImplVolume.server}}
                path: {{.Values.customizedFactorImplVolume.path}}
    {{- end }}
  2. Copy the custom implementation and third party dependency jar files to the following folder: <mountPathPrefix><mountRelativePath>/.

Stop and start the nodes in the pod to start loading your custom implementation.