/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.robotraconteur;

public class NativeUserAuthenticator implements IUserAuthenticator {
  private transient long swigCPtr;
  private transient boolean swigCMemOwn;

  protected NativeUserAuthenticator(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(NativeUserAuthenticator obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void swigSetCMemOwn(boolean own) {
    swigCMemOwn = own;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        RobotRaconteurJavaJNI.delete_NativeUserAuthenticator(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

	@Override
	public  AuthenticatedUser authenticateUser(String username, java.util.Map<String,Object> credentials, ServerContext context)
	{
		MessageElement c =(MessageElement) RobotRaconteurNode.s().<String,Object>packMapType(credentials,String.class, Object.class);
		return _AuthenticateUser(username, c, context);
	}



  private AuthenticatedUser _AuthenticateUser(String username, MessageElement credentials, ServerContext context) {
    long cPtr = RobotRaconteurJavaJNI.NativeUserAuthenticator__AuthenticateUser(swigCPtr, this, username, MessageElement.getCPtr(credentials), credentials, ServerContext.getCPtr(context), context);
    return (cPtr == 0) ? null : new AuthenticatedUser(cPtr, true);
  }

}
