com.networknt.utility.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(136)

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

Util介绍

[英]Generic utilities
[中]通用实用程序

代码示例

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

@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
  // check if the cid is in the request header
  String cId = exchange.getRequestHeaders().getFirst(HttpStringConstants.CORRELATION_ID);
  if(cId == null) {
    // if not, generate a UUID and put it into the request header
    cId = Util.getUUID();
    exchange.getRequestHeaders().put(HttpStringConstants.CORRELATION_ID, cId);
  }
  // Add the cId into MDC so that all log statement will have cId as part of it.
  MDC.put(CID, cId);
  //logger.debug("Init cId:" + cId);
  Handler.next(exchange, next);
}

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

public Map<String, Object> getHost(HttpServerExchange exchange) {
  Map<String, Object> hostMap = new LinkedHashMap<>();
  String ip = "unknown";
  String hostname = "unknown";
  InetAddress inetAddress = Util.getInetAddress();
  ip = inetAddress.getHostAddress();
  hostname = inetAddress.getHostName();
  hostMap.put("ip", ip);
  hostMap.put("hostname", hostname);
  hostMap.put("dns", exchange.getSourceAddress().getHostName());
  return hostMap;
}

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

public Map<String, Object> getDeployment() {
  Map<String, Object> deploymentMap = new LinkedHashMap<>();
  deploymentMap.put("apiVersion", Util.getJarVersion());
  deploymentMap.put("frameworkVersion", getFrameworkVersion());
  return deploymentMap;
}

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

normalisedValue = Util.quote(value);

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

private String jwtReference(String jwt, String clientId) {
    String uuid = Util.getUUID();
    Map<String, String> referenceMap = new HashMap<>();
    referenceMap.put("jwt", jwt);
    if(clientId != null) {
      referenceMap.put("clientId", clientId);
    }
    CacheStartupHookProvider.hz.getMap("references").set(uuid, referenceMap);
    return uuid;
  }
}

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

public MetricsHandler() {
  commonTags.put("apiName", Server.config.getServiceId());
  commonTags.put("environment", Server.config.getEnvironment());
  InetAddress inetAddress = Util.getInetAddress();
  // On Docker for Mac, inetAddress will be null as there is a bug.
  commonTags.put("ipAddress", inetAddress == null ? "unknown" : inetAddress.getHostAddress());
  commonTags.put("hostname", inetAddress == null ? "unknown" : inetAddress.getHostName()); // will be container id if in docker.
      
  if(logger.isDebugEnabled()) {
    logger.debug(commonTags.toString());
  }
}

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

return;
String version = Util.getJarVersion();
String service = config.getServiceId();
String tempDir = System.getProperty("java.io.tmpdir");

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

codeMap.put("userId", userId);
String code = Util.getUUID();
String redirectUri = params.get("redirect_uri");
if(redirectUri == null) {

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

logger.info("Registry IP from STATUS_HOST_IP is " + ipAddress);
if (ipAddress == null) {
  InetAddress inetAddress = Util.getInetAddress();
  ipAddress = inetAddress.getHostAddress();
  logger.info("Could not find IP from STATUS_HOST_IP, use the InetAddress " + ipAddress);

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

String code = Util.getUUID();
String redirectUri = params.get("redirect_uri");
if(redirectUri == null) {

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

public MetricsHandler() {
  commonTags.put("apiName", Server.config.getServiceId());
  commonTags.put("environment", Server.config.getEnvironment());
  InetAddress inetAddress = Util.getInetAddress();
  // On Docker for Mac, inetAddress will be null as there is a bug.
  commonTags.put("ipAddress", inetAddress == null ? "unknown" : inetAddress.getHostAddress());
  commonTags.put("hostname", inetAddress == null ? "unknown" : inetAddress.getHostName()); // will be container id if in docker.
      
  if(logger.isDebugEnabled()) {
    logger.debug(commonTags.toString());
  }
}

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

processAudit(exchange);
} else {
  String code = Util.getUUID();
  final SecurityContext context = exchange.getSecurityContext();
  String userId = context.getAuthenticatedAccount().getPrincipal().getName();

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

processAudit(exchange);
} else {
  String code = Util.getUUID();
  final SecurityContext context = exchange.getSecurityContext();
  String userId = context.getAuthenticatedAccount().getPrincipal().getName();

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

String clientSecret = Util.getUUID();
client.setClientSecret(HashUtil.generateStrongPasswordHash(clientSecret));

相关文章

微信公众号

最新文章

更多