com.networknt.config.Config.getMapper()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中com.networknt.config.Config.getMapper()方法的一些代码示例,展示了Config.getMapper()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getMapper()方法的具体详情如下:
包路径:com.networknt.config.Config
类名称:Config
方法名:getMapper

Config.getMapper介绍

暂无

代码示例

代码示例来源:origin: networknt/light-4j

private static TokenResponse handleResponse(String responseBody) {
  TokenResponse tokenResponse = null;
  try {
    if (responseBody != null && responseBody.length() > 0) {
      tokenResponse = Config.getInstance().getMapper().readValue(responseBody, TokenResponse.class);
    } else {
      logger.error("Error in token retrieval, response = " + responseBody);
    }
  } catch (IOException | RuntimeException e) {
    logger.error("Error in token retrieval", e);
  }
  return tokenResponse;
}

代码示例来源:origin: networknt/light-4j

public static String maskJson(DocumentContext ctx, String key) {
  Map<String, Object> jsonConfig = (Map<String, Object>) config.get(MASK_TYPE_JSON);
  if (jsonConfig != null) {
    Map<String, Object> patternMap = (Map<String, Object>) jsonConfig.get(key);
    if (patternMap != null) {
      JsonNode configNode = Config.getInstance().getMapper().valueToTree(patternMap);
      Iterator<Map.Entry<String, JsonNode>> iterator = configNode.fields();
      while (iterator.hasNext()) {
        Map.Entry<String, JsonNode> entry = iterator.next();
        applyMask(entry, ctx);
      }
      return ctx.jsonString();
    } else {
      logger.warn("mask.json doesn't contain the key {} ", Encode.forJava(key));
    }
  }
  return ctx.jsonString();
}

代码示例来源:origin: networknt/light-4j

@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
  exchange.getResponseHeaders().put(
      Headers.CONTENT_TYPE, "application/json");
  Map<String, Object> resMap = new HashMap<>();
  resMap.put("access_token", JwtIssuer.getJwt(mockClaims()));
  resMap.put("token_type", "bearer");
  resMap.put("expires_in", 600);
  exchange.getResponseSender().send(ByteBuffer.wrap(
      Config.getInstance().getMapper().writeValueAsBytes(
          resMap)));
}

代码示例来源:origin: networknt/light-4j

if(logger.isDebugEnabled()) {
  try {
    logger.debug("serviceUrls = " + Config.getInstance().getMapper().writeValueAsString(serviceUrls));
  } catch(Exception e) {

代码示例来源:origin: networknt/light-4j

if(logger.isDebugEnabled()) {
  try {
    logger.debug("response = " + Config.getInstance().getMapper().writeValueAsString(response));
  } catch (Exception e) {}
  if(logger.isDebugEnabled()) try {logger.debug("services = " + Config.getInstance().getMapper().writeValueAsString(services));} catch (Exception e) {}
  if (services != null && !services.isEmpty()
      && response.getConsulIndex() > lastConsulIndexId) {

代码示例来源:origin: networknt/light-4j

auditFunc.accept(Config.getInstance().getMapper().writeValueAsString(auditMap));
      } else {
        auditFunc.accept(Config.getInstance().getMapper().writeValueAsString(auditMap));
  });
} else {
  auditFunc.accept(Config.getInstance().getMapper().writeValueAsString(auditMap));

代码示例来源:origin: networknt/light-4j

@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
  ServerInfoConfig config = (ServerInfoConfig)Config.getInstance().getJsonObjectConfig(CONFIG_NAME, ServerInfoConfig.class);
  if(config.isEnableServerInfo()) {
    Map<String, Object> infoMap = new LinkedHashMap<>();
    infoMap.put("deployment", getDeployment());
    infoMap.put("environment", getEnvironment(exchange));
    infoMap.put("security", getSecurity());
    infoMap.put("specification", Config.getInstance().getJsonMapConfigNoCache("swagger"));
    infoMap.put("component", ModuleRegistry.getRegistry());
    exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json");
    exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(infoMap));
  } else {
    setExchangeStatus(exchange, STATUS_SERVER_INFO_DISABLED);
  }
}

代码示例来源:origin: networknt/light-4j

String body = reference.get().getAttachment(Http2Client.RESPONSE_BODY);
if(logger.isDebugEnabled()) logger.debug("body = " + body);
List<Map<String, Object>> services = Config.getInstance().getMapper().readValue(body, new TypeReference<List<Map<String, Object>>>(){});
List<ConsulService> ConsulServcies = new ArrayList<>(
    services.size());

代码示例来源:origin: networknt/light-4j

s = s.trim();
if (s.startsWith("{")) {
  body = Config.getInstance().getMapper().readValue(s, new TypeReference<HashMap<String, Object>>() {
  });
} else if (s.startsWith("[")) {
  body = Config.getInstance().getMapper().readValue(s, new TypeReference<List<Object>>() {
  });
} else {

代码示例来源:origin: com.networknt/client

private static TokenResponse handleResponse(String responseBody) {
  TokenResponse tokenResponse = null;
  try {
    if (responseBody != null && responseBody.length() > 0) {
      tokenResponse = Config.getInstance().getMapper().readValue(responseBody, TokenResponse.class);
    } else {
      logger.error("Error in token retrieval, response = " + responseBody);
    }
  } catch (IOException | RuntimeException e) {
    logger.error("Error in token retrieval", e);
  }
  return tokenResponse;
}

代码示例来源:origin: com.networknt/security

@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
  exchange.getResponseHeaders().put(
      Headers.CONTENT_TYPE, "application/json");
  Map<String, Object> resMap = new HashMap<>();
  resMap.put("access_token", JwtIssuer.getJwt(mockClaims()));
  resMap.put("token_type", "bearer");
  resMap.put("expires_in", 600);
  exchange.getResponseSender().send(ByteBuffer.wrap(
      Config.getInstance().getMapper().writeValueAsBytes(
          resMap)));
}

代码示例来源:origin: networknt/light-oauth2

@Override
  public void handleRequest(HttpServerExchange exchange) throws Exception {
    IMap<String, Provider> providers = CacheStartupHookProvider.hz.getMap("providers");

    exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
    exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(providers));
    processAudit(exchange);
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
  if (oauth_config.isEnableAudit() ) {
    AuditInfo auditInfo = new AuditInfo();
    auditInfo.setServiceId(Oauth2Service.REFRESHTOKEN);
    auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
    auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
    auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
    auditInfo.setResponseCode(exchange.getStatusCode());
    auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
    auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
    saveAudit(auditInfo);
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
  if (oauth_config.isEnableAudit() ) {
    AuditInfo auditInfo = new AuditInfo();
    auditInfo.setServiceId(Oauth2Service.CODE);
    auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
    auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
    auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
    auditInfo.setResponseCode(exchange.getStatusCode());
    auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
    auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
    saveAudit(auditInfo);
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
  if (oauth_config.isEnableAudit() ) {
    AuditInfo auditInfo = new AuditInfo();
    auditInfo.setServiceId(Oauth2Service.USER);
    auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
    auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
    auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
    auditInfo.setResponseCode(exchange.getStatusCode());
    auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
    auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
    saveAudit(auditInfo);
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
  if (oauth_config.isEnableAudit() ) {
    AuditInfo auditInfo = new AuditInfo();
    auditInfo.setServiceId(Oauth2Service.SERVICE);
    auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
    auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
    auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
    auditInfo.setResponseCode(exchange.getStatusCode());
    auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
    auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
    saveAudit(auditInfo);
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
  if (oauth_config.isEnableAudit() ) {
    AuditInfo auditInfo = new AuditInfo();
    auditInfo.setServiceId(Oauth2Service.CLIENT);
    auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
    auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
    auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
    auditInfo.setResponseCode(exchange.getStatusCode());
    auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
    auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
    saveAudit(auditInfo);
  }
}

代码示例来源:origin: networknt/light-oauth2

private void processAudit(HttpServerExchange exchange) throws Exception {
    if (oauth_config.isEnableAudit() ) {
      AuditInfo auditInfo = new AuditInfo();
      auditInfo.setServiceId(Oauth2Service.AUTHORIZE);
      auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
      auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
      auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
      auditInfo.setResponseCode(exchange.getStatusCode());
      auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
      auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
      saveAudit(auditInfo);
    }
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
    if (oauth_config.isEnableAudit() ) {
      AuditInfo auditInfo = new AuditInfo();
      auditInfo.setServiceId(Oauth2Service.TOKEN);
      auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
      auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
      auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
      auditInfo.setResponseCode(exchange.getStatusCode());
      auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
      auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
      saveAudit(auditInfo);
    }
  }
}

代码示例来源:origin: networknt/light-oauth2

protected void processAudit(HttpServerExchange exchange) throws Exception{
  if (oauth_config.isEnableAudit() ) {
    AuditInfo auditInfo = new AuditInfo();
    auditInfo.setServiceId(Oauth2Service.CLIENT);
    auditInfo.setEndpoint(exchange.getHostName() + exchange.getRelativePath());
    auditInfo.setRequestHeader(exchange.getRequestHeaders().toString());
    auditInfo.setRequestBody(Config.getInstance().getMapper().writeValueAsString(exchange.getAttachment(BodyHandler.REQUEST_BODY)));
    auditInfo.setResponseCode(exchange.getStatusCode());
    auditInfo.setResponseHeader(exchange.getResponseHeaders().toString());
    auditInfo.setResponseBody(Config.getInstance().getMapper().writeValueAsString(exchange.getResponseCookies()));
    saveAudit(auditInfo);
  }
}

相关文章