小编tkr*_*tkr的帖子

Spring SQL Injection中的@Query注释是否安全?

对于Spring,传递给@Query注释的字符串的参数是否被视为纯数据,例如,如果您使用的是PreparedStatement类或任何旨在阻止SQL注入的方法?

final String MY_QUERY = "SELECT * FROM some_table WHERE some_column = ?1";

@Query(value=MY_QUERY, nativeQuery = true)
List<SomeEntity> findResults(String potentiallyMaliciousUserInput);
Run Code Online (Sandbox Code Playgroud)

结论:上面的代码是否容易受到SQL注入的影响?

java spring sql-injection spring-annotations

10
推荐指数
1
解决办法
1万
查看次数

为什么Spring Webflux只能并行接受256个请求?

在默认配置中,Spring Webflux似乎将并行请求数限制为256.

我的设置有这个非常简单的控制器:

@RestController
public class SimpleRestController {
  private final Log logger = LogFactory.getLog(getClass());

  private AtomicLong countEnter = new AtomicLong(0);
  private AtomicLong countExit = new AtomicLong(0);

  @GetMapping(value = "/delayed")
  public Mono<String> delayed() {
    logger.info("delayed ENTER " + countEnter.incrementAndGet());

    return Mono.just("result").delayElement(Duration.ofSeconds(60))

          .doOnNext(s -> logger.info("delayed EXIT " + countExit.incrementAndGet()));
  }
}
Run Code Online (Sandbox Code Playgroud)

配置只启用WebFlux:

@SpringBootConfiguration
@EnableWebFlux
public class SearchServiceConfiguration {
}
Run Code Online (Sandbox Code Playgroud)

依赖关系很少:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>10</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin> …
Run Code Online (Sandbox Code Playgroud)

reactor netty spring-boot spring-webflux

8
推荐指数
2
解决办法
942
查看次数

如何在JaxB中忽略元素名称的大小写

如标题中所述,我想忽略文档中元素名称的大小写.

static class XY433 {
    @XmlAttribute(name = "C200")
    String c200;
    @XmlAttribute(name = "C215")
    String c215;

    @XmlAttribute(name="F001")
    String f001;

    @XmlAttribute(name="f001")
    String lcf001; // I want to avoid this duplication
}
Run Code Online (Sandbox Code Playgroud)

我试图使用Blaise Doughan发布的代码:

private static class ToLowerCaseNamesStreamReaderDelegate extends StreamReaderDelegate {

    public ToLowerCaseNamesStreamReaderDelegate(XMLStreamReader xsr) {
        super(xsr);
    }

    @Override
    public String getAttributeLocalName(int index) {
        return super.getAttributeLocalName(index).toLowerCase();
    }

    @Override
    public String getLocalName() {
        return super.getLocalName().toLowerCase();
    }

}


@XmlRootElement(name="doc")
static class Doc {
    @XmlElement(name="element")
    List<Element> elements;
}

static class Element {
    @XmlAttribute(name = "abc")
    String abc; …
Run Code Online (Sandbox Code Playgroud)

java xml jaxb

4
推荐指数
1
解决办法
2万
查看次数

在哪里可以检索 Cognito 身份池的公钥?

实际上,我通过以下代码为未经身份验证的用户检索了已签名的 JWT。

AWS.config.region = 'eu-central-1'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    IdentityPoolId: 'eu-central-1:cccccc-cccc-cccc-cccc',
    RoleArn: 'arn:aws:iam::iiiiiiiiiiiii:role/Cognito_MyIdentityPoolUnauth_Role'
});
// Obtain Open ID Token (JWT)
AWS.config.credentials.get(function() {
    console.log(AWS.config.credentials.params.WebIdentityToken);
});
Run Code Online (Sandbox Code Playgroud)

如何检索公钥以验证签名?

我只能从用户池中找到涵盖令牌的文档。因为我想处理未经身份验证的用户,所以这对我没有帮助。

javascript amazon-web-services jwt amazon-cognito

3
推荐指数
1
解决办法
2493
查看次数

Java中"=="运算符的语义

我想知道:为什么这个代码导致了false?当
Coz ==运算符true是相同的存储点时,它应该返回.

public static void main(String[] args) {
    String a = new String("hello");

    System.out.println(a == "hello");
}
Run Code Online (Sandbox Code Playgroud)
  • 你能描述一下为什么会这样吗?

java

-3
推荐指数
1
解决办法
110
查看次数