小编pac*_*o14的帖子

@PreAuthorize 如何检查角色?

我有几个 REST API。

我想将安全放在所有这些之上,以便仅允许某些角色使用这些功能。

我把@EnableGlobalMethodSecurity(prePostEnabled = true) 放在了配置类中。

我有一个带有存储角色的表的数据库。

@RequestMapping(path = "/error", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_ADMIN')") 
public ResponseEntity<ResponseWrapper> getError(...


INSERT INTO table USER_ROLE VALUES ('ADMIN','PASSWORD','ROLE_ADMIN');
Run Code Online (Sandbox Code Playgroud)

方法“hasRole”如何查询表USER_ROLE?为了与该表进行通信,我必须给 Spring 提供任何设置吗?

spring spring-security

5
推荐指数
1
解决办法
5675
查看次数

比较文件.class Bejond Compare 4

早上好,我正在使用Beyond Compare 4(4.1.9)来比较war文件.

我需要比较我在几个包中找到的文件.class.

我如何使用这个产品比较它们?

否则有另一个产品谁比较战争文件并编译.class文件?

java war .class-file beyondcompare4

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

将 findAll PagingAndSortingRepository 与过滤器结合使用

我需要使用 PagingAndSortingRepository 来获取元素列表。我还需要使用 RequestParam 过滤此列表。

在控制器中我有:

@RequestMapping(path = "/listfilter", method = RequestMethod.GET)
public Page<Element> getElements(
        @RequestParam("page") int page,
        @RequestParam("size") int size,
        @RequestParam("aaa") String filter) {

    Filter filter = new Filter();
    filter.setPageNum(page);
    filter.setPageSize(size);
    filter.setAaa(aaa);

    return controller.findElements(filter);
}
Run Code Online (Sandbox Code Playgroud)

如何将过滤后的列表传递给方法

Page<Element> findElements(Pageable pageable) {...}
Run Code Online (Sandbox Code Playgroud)

谢谢

java spring spring-mvc spring-boot

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

如何在LDIF文件中添加属性?

我想使用 LDIF 文件通过 Spring 测试 LDAP。

我不使用xml。

我实现了从 LDIF 文件读取所有基本属性。

如何添加一些自定义属性?

到目前为止我使用了这个语法

dn: cn=name,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
cn: name
sn: name
uid: name
mail: name@gmail.com
givenName: name
userPassword: namespassword
changetype: modify
add: telephonenumber
telephonenumber: 555-2468
Run Code Online (Sandbox Code Playgroud)

...但是它无法读取该文件,因为它无法识别“changeType”属性。

编辑问题

我有这个文件:

dn: dc=springframework,dc=org
objectclass: top
objectclass: domain
objectclass: extensibleObject
dc: springframework

dn: ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: groups

dn: ou=subgroups,ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: subgroups

dn: ou=people,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: people

dn: ou=space cadets,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit …
Run Code Online (Sandbox Code Playgroud)

java ldap spring-ldap ldif

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