Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Create a custom Java component and add the below dependencies to that project.
    1. com.wso2.finance.open.banking.sca.keymanager 

      Info

      com.wso2.finance.open.banking.sca.keymanager-1.3.0 is available in <WSO2_OBAM_HOME>/repository/components/lib/com.wso2.finance.open.banking.sca.keymanager-1.34.0.jar

    2. org.wso2.carbon.apimgt.impl

      Info

      org.wso2.carbon.apimgt.impl_6.4.50 is available in <WSO2_OBAM_HOME>/repository/components/plugins/org.wso2.carbon.apimgt.impl_6.4.50.jar

  • Add a Java class to your custom module extending the SCABasedKeyManagerClient class. Override the setAuthenticators method to define the required authenticators. The sample SampleKeyManagerClient module below sets two authentication steps(local authentication and federated authentication steps respectively) using this extension.


    Code Block
    languagejava
    /**
     * Sample class to set authenticators in KeyManagerClient
     **/
    public class SampleKeyManagerClient extends SCABasedKeyManagerClient {
    
        private static final String BASIC_AUTHENTICATOR_NAME = "FOOBasicCustomAuth";
        private static final String BASIC_AUTHENTICATOR_DISPLAY_NAME = "FOO Authenticator";
        private static final String FEDERATED_AUTHENTICATOR_NAME = "BARFedCustomAuth";
    
        @Override
        public void setAuthenticators(LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig,
                                      OAuthApplicationInfo oAuthApplicationInfo)
                throws RemoteException, IdentityApplicationManagementServiceIdentityApplicationManagementException,
                APIManagementException {
            AuthenticationStep[] authenticationSteps = new AuthenticationStep[2];
    
            //Step 1 - Basic authentication
            LocalAuthenticatorConfig localAuthenticatorConfig = new LocalAuthenticatorConfig();
            LocalAuthenticatorConfig[] localAuthenticatorConfigs = new LocalAuthenticatorConfig[1];
            AuthenticationStep basicAuthenticationStep = new AuthenticationStep();
    
            localAuthenticatorConfig.setName(BASIC_AUTHENTICATOR_NAME);
            localAuthenticatorConfig.setDisplayName(BASIC_AUTHENTICATOR_DISPLAY_NAME);
            localAuthenticatorConfig.setEnabled(true);
            localAuthenticatorConfigs[0] = localAuthenticatorConfig;
    
            basicAuthenticationStep.setStepOrder(1);
            basicAuthenticationStep.setLocalAuthenticatorConfigs(localAuthenticatorConfigs);
            basicAuthenticationStep.setAttributeStep(true);
            basicAuthenticationStep.setSubjectStep(true);
            //set step 1
            authenticationSteps[0] = basicAuthenticationStep;
    
            //Step 2 - Federated authentication
            IdentityProvider identityProvider = null;
    
            IdentityApplicationManagementServiceStub stub = super.getIdentityApplicationManagementServiceStub();
    
            if (stub != null) {
                IdentityProvider[] federatedIdPs = stub.getAllIdentityProviders();
                if (federatedIdPs != null && federatedIdPs.length > 0) {
                    for (IdentityProvider registeredIdentityProvider : federatedIdPs) {
                        if (registeredIdentityProvider.getIdentityProviderName().equals(FEDERATED_AUTHENTICATOR_NAME)) {
                            identityProvider = registeredIdentityProvider;
                            break;
                        }
                    }
                }
            } else {
                throw new APIManagementException("Retrieving IdentityApplicationManagementServiceStub failed.");
            }
    
            IdentityProvider[] identityProviders = new IdentityProvider[1];
            identityProviders[0] = identityProvider;
    
            AuthenticationStep authenticationStep = new AuthenticationStep();
            authenticationStep.setStepOrder(2);
            authenticationStep.setFederatedIdentityProviders(identityProviders);
    
            //set step 2
            authenticationSteps[1] = authenticationStep;
    
            //set authentication steps
            localAndOutboundAuthenticationConfig.setAuthenticationSteps(authenticationSteps);
        }
    }
    
    
    

...

  • Build the module.
  • Add the .jar file to <WSO2_OB_OBAMAPIM_HOME> /repository/components/lib

    Note

    If the module is an OSGi service place the .jar in <WSO2_OB_OBAMAPIM_HOME>/repository/components/dropins

  • Modify the <KeyManagerClientImpl> element in <WSO2_OBAMOB_APIM_HOME>/repository/conf/api-manager.xml  file with the fully qualified name (FQN) of your Java class

  • Start the WSO2 OB AM server.

...