2

adapter UserAuthenticationSecurityCheck where we have introduced some properties in the adapter.xml file outside the securityCheckDefinition. Which i am able to configure in the Adapter -> Configuration tab in the mfp console.

We are trying to access the configuartion value via ConfigurationAPI with importing import com.ibm.mfp.adapter.api.ConfigurationAPI inside the UserAuthenticationSecurityCheck extended class.

But we are getting a null pointer exception during this process. I am able to access them inside the java-adapter class via ConfigurationAPI but not inside the security UserAuthenticationSecurityCheck class.

Wanted to access the below image properties inside the UserAuthenticationSecurityCheck extended class.

enter image description here

public class userSecurityCheck extends UserAuthenticationSecurityCheck {

    @Context
    ConfigurationAPI configurationAPI;


    @Override
    protected boolean validateCredentials(Map<String, Object> credentials){

        String instancename = credentials.get("instancename").toString();
        // java null pointer exception is happening at the below line
        String httpUrl = configurationAPI.getPropertyValue(instancename);
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Kawinesh S K
  • 3,148
  • 1
  • 16
  • 29
  • 1
    Sounds to me like what you're really looking for is an extension point to extend the configurable elements in UserAuthenticationSecurityCheck. Is that a fair characterization? I don't know if MFP supports subclassing those objects or not. I'll try to find out for you though. – John Gerken Jun 13 '18 at 14:47
  • @JohnGerken Please view the updated question – Kawinesh S K Jun 14 '18 at 05:01

1 Answers1

0

There is indeed a way to specify configurable properties on the "Security Check" flavour of adapter, and it is different from the regular type of adapter. It is documented here. I have validated that this approach works. The documentation omits a few key elements, like package names, so below is so very simple example code to demonstrate:

UserAuth.java:

public class UserAuth extends UserAuthenticationSecurityCheck {
  @Override
  protected boolean validateCredentials(Map<String, Object> credentials) {
    String test_property = ((UserAuthSecurityCheckConfig) this.config).test_property;
    LOG.warning("auth test_property=" + test_property);
    return true;
  }

  @Override
  public SecurityCheckConfiguration createConfiguration(Properties properties) {
      return new UserAuthSecurityCheckConfig(properties);
  }
}

UserAuthSecurityCheckConfig.java:

import java.util.Properties;
import com.ibm.mfp.security.checks.base.UserAuthenticationSecurityCheckConfig;

public class UserAuthSecurityCheckConfig extends UserAuthenticationSecurityCheckConfig {
    public String test_property;

    public UserAuthSecurityCheckConfig(Properties properties) {
        super(properties);
        this.test_property = this.getStringProperty("test_property", properties, "defaultValueInCode");
    }
}

adapter.xml:

<securityCheckDefinition name="UserLogin" class="com.xyz.UserAuth">
    <property name="test_property" displayName="Test Property Auth" defaultValue="foo_default_in_xml"  />
</securityCheckDefinition>
Andrew Ferrier
  • 16,664
  • 13
  • 47
  • 76