コード例 #1
0
  /**
   * This method constructs the URLs for each of the API Endpoints called by the device agent Ex:
   * Register API, Push-Data API
   *
   * @throws AgentCoreOperationException if any error occurs at socket level whilst trying to
   *     retrieve the deviceIP of the network-interface read from the configs file
   */
  public static void initializeServerEndPoints() {
    AgentManager agentManager = AgentManager.getInstance();
    String serverSecureEndpoint = agentManager.getAgentConfigs().getHTTPS_ServerEndpoint();
    String serverUnSecureEndpoint = agentManager.getAgentConfigs().getHTTP_ServerEndpoint();
    String backEndContext = agentManager.getAgentConfigs().getControllerContext();
    String scepBackEndContext = agentManager.getAgentConfigs().getScepContext();

    String deviceControllerAPIEndpoint = serverSecureEndpoint + backEndContext;

    String deviceEnrollmentEndpoint =
        serverUnSecureEndpoint + scepBackEndContext + AgentConstants.DEVICE_ENROLLMENT_API_EP;
    agentManager.setEnrollmentEP(deviceEnrollmentEndpoint);

    String registerEndpointURL =
        deviceControllerAPIEndpoint + AgentConstants.DEVICE_REGISTER_API_EP;
    agentManager.setIpRegistrationEP(registerEndpointURL);

    String pushDataEndPointURL =
        deviceControllerAPIEndpoint + AgentConstants.DEVICE_PUSH_TEMPERATURE_API_EP;
    agentManager.setPushDataAPIEP(pushDataEndPointURL);

    log.info(
        AgentConstants.LOG_APPENDER
            + "IoT Server's Device Controller API Endpoint: "
            + deviceControllerAPIEndpoint);
    log.info(AgentConstants.LOG_APPENDER + "Device Enrollment EndPoint: " + registerEndpointURL);
    log.info(
        AgentConstants.LOG_APPENDER + "DeviceIP Registration EndPoint: " + registerEndpointURL);
    log.info(AgentConstants.LOG_APPENDER + "Push-Data API EndPoint: " + pushDataEndPointURL);
  }