0

I have a retail system where the central node is corp-0 and store node is store-1, store-2, etc. I am using SymmetricDS 3.5.13 to do sync between a store node and a corp node. I have to authenticate every store node that tries to connect the corp node, even after successful registration using my business logic. Using a class implementing INodePasswordFilter, how can I retrieve the connection requesting store's external-id ? Any help on the configuration and work flow of SymmetricDS password rendering and saving is appreciated. The class implementation I tried is as given below.

public class AuthenticationClinic implements INodePasswordFilter,IParameterFilter, INodeGroupExtensionPoint{
@Override
public String onNodeSecurityRender(String password) {

    // I have to get the NodeGroupId and ExternalId of the
            // requesting node here
            // String external_id= *Method to retrieve External Id of Requesting Node*
            // if(checking.checknodeauthenticity(external_id)) return password;
            // else return "dummy";

    return "dummy";
}

@Override
public String onNodeSecuritySave(String password) {

    return password;
}

@Override
public String[] getNodeGroupIdsToApplyTo() {
    return new String[] { "store" };
}

@Override
public String filterParameter(String key, String value) {
    return value;
}

 public boolean isAutoRegister() {
        return false;
 }

1 Answers1

1

Declare your filter to implement ISymmetricEngineAware, declare a field engine and a method

@Override
public void setSymmetricEngine(ISymmetricEngine engine) {
  this.engine = engine;
}

Then use the field engine to fetch the sql template:

ISqlTemplate sqlTemplate = engine.getSymmetricDialect().
   getPlatform().getSqlTemplate();




Use

ISqlTemplate sqlTemplate = AbstractSymmetricEngine.
  findEngineByName("my.symmetric.ds.engine").
  getSymmetricDialect().getPlatform().getSqlTemplate();

to query the database using one of the templates from NodeService.

Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148