【【Java杂货铺】用Security做权限极简入门】教程文章相关的互联网学习教程文章

java – 创建bean’org.springframework.security.filterChains’时出错:无法解析’org.springframework.security.web.D【代码】

我正在尝试使用OAuth2,我是新手,请帮我解决这个问题*org.springframework.web.context.ContextLoader initWebApplicationContextSEVERE: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting ...

java – Spring Security在登录后总是返回403 accessDeniedPage【代码】

参见英文答案 > Springboot Security hasRole not working 1个我是Spring的新手,我一直在尝试使用spring security实现一个简单的登录页面.但它总是在提供登录凭据后访问Denied url.在我提供正确的用户名和密码后,loadUserByUsername()方法始终返回用户.但我不知道如何找到返回用户对象后发生的事情. 用户只有一个角色.该方法返回具有SUPER_USER角色的用户. 这是我的spring安全配置类import org...

java – 使用OAuth2自定义Spring Security的auth错误【代码】

我想知道我是否可以自定义以下授权错误:{"error": "unauthorized","error_description": "Full authentication is required to access this resource" }我在用户请求没有权限时得到它.我想将它定制为与Spring Boot错误非常相似:{"timestamp":1445441285803,"status":401,"error":"Unauthorized","message":"Bad credentials","path":"/oauth/token" }有可能吗? 非常感谢.解决方法:我知道了 :) https://stackoverflow.com/a/371...

java – 在反向代理后面需要使用Spring Security的HTTPS【代码】

我有一个使用Spring Security保护的Spring MVC应用程序.大多数应用程序使用简单的HTTP来节省资源,但是一小部分处理更多机密信息并需要HTTPS通道. 从security-config.xml中提取:<sec:http authentication-manager-ref="authenticationManager" ... >...<sec:intercept-url pattern="/sec/**" requires-channel="https"/><sec:intercept-url pattern="/**" requires-channel="http"/> </sec:http>一切正常,直到我们决定将其迁移到主...

java – Spring Security – 拒绝访问(用户不是匿名的)spring-security-core-4.0.3.RELEASE【代码】

任何人都可以在这个Spring Security Config文件中看到失败? 登录后,我得到一个调试消息:Access is denied (user is not anonymous); delegating toAccessDeniedHandlerorg.springframework.security.access.AccessDeniedException: Access isdenied但我可以访问该应用程序.@Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers("/register/verification/*/*").anonymo...

android – Glide – javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorExcept【代码】

我将服务器从HTTP迁移到HTTPS我已经使用自签名证书来发送带有HttpUrlConnection的网络请求并且它工作但是对于图像加载它不起作用,因为我使用Glide进行图像加载.javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.while loading images from https URL through glide libraryGlide.with(mContext).load(currentItem.getImage_path().replace(" ...

线程“main”中的异常java.security.InvalidKeyException:非法的键大小或默认参数【代码】

参见英文答案 > InvalidKeyException Illegal key size 5个下面的代码抛出此错误消息: 线程“main”中的异常java.security.InvalidKeyException:非法的键大小或默认参数Cipher dcipher;byte[] salt = new String("12345678").getBytes(); int iterationCount = 1024; int keyStrength = 256; SecretKey key; byte[] iv;Decrypter(String passPhrase) throws Exception {SecretKeyFactory fac...

java.security.InvalidKeyException:android中的非法密钥大小或默认参数【代码】

我收到以下错误,我有点卡住了:线程“main”中的异常java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1011)at javax.crypto.Cipher.implInit(Cipher.java:786)at javax.crypto.Cipher.chooseProvider(Cipher.java:849)at javax.crypto.Cipher.init(Cipher.java:1213)at javax.crypto.Cipher.init(Cipher.java:1153)at net.nakou.indie.wtext.engi...

Appengine DevMode:拒绝访问(“java.lang.RuntimePermission”“accessClassInPackage.sun.security.util”)【代码】

我将我的PC升级到Ubuntu 12.04,然后恢复了我的工作区和Eclipse的备份.现在,当我尝试启动AppEngine / GWT应用程序时,我遇到了java安全管理器的问题.Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.security.util")at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)at java.security.AccessController.checkPermi...

java – 基于Spring Security Token的身份验证【代码】

我有一个休息api,我在使用spring security Basic Authorization进行身份验证,其中客户端为每个请求发送用户名和密码.现在,我想实现基于令牌的身份验证,我将在用户首先进行身份验证时在响应头中发送令牌.对于进一步的请求,客户端可以在标头中包含该标记,该标记将用于向用户验证资源.我有两个身份验证提供程序tokenAuthenticationProvider和daoAuthenticationProvider@Component public class TokenAuthenticationProvider implement...

java – 如何从spring security获取当前登录的用户对象?【代码】

我使用的是Spring安全版3.1.4.RELEASE.如何访问当前登录的用户对象?SecurityContextHolder.getContext().getAuthentication().getPrinciple()返回用户名,而不是用户对象.那么如何使用返回的用户名并获取UserDetails对象? 我试过以下代码:public UserDetails getLoggedInUser(){final Authentication auth = SecurityContextHolder.getContext().getAuthentication();if (auth != null && auth.isAuthenticated() && !(auth inst...

具有Spring Security和Java配置的自定义验证管理器【代码】

我正在使用Spring Security与SpringMVC创建一个Web应用程序(为了清楚起见,我将其称为WebApp),它与现有应用程序相对应(我将其称为BackendApp). 我想将身份验证职责委托给BackendApp(这样我就不需要同步这两个应用程序). 为了实现这一点,我希望WebApp(运行spring security)通过REST与用户在表单中提供的用户名和密码进行BackendApp通信,并根据BackendApp的响应是200 OK还是401 Unauthorized进行身份验证. 我知道我需要编写一个自定义...

java – 在spring boot app中禁用spring security【代码】

我有一个Spring Boot web应用程序,配置了spring security.我想暂时禁用身份验证(直到需要). 我将它添加到application.properties:security.basic.enable: false management.security.enabled: false 这是我的一部分 但我仍然有一个基本的安全性:启动时生成一个默认的安全密码,我仍然收到HTTP身份验证提示框. 我的pom.xml:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-...

javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚【代码】

我正在使用Retrofit来访问我的REST API.但是,当我把我的API放在ssl后面并通过http:// myhost / myapi访问它时,我收到此错误: 我的API落后于SSL,我是否需要做一些额外的事情? 这是我如何连接:private final String API = "https://myhost/myapi";private final RestAdapter REST_ADAPTER = new RestAdapter.Builder().setServer(API).setLogLevel(RestAdapter.LogLevel.FULL).build();01-10 09:49:55.621 2076-2100/com.myap...

java – Spring Security .permitAll()在升级到Spring Boot 2.0.2后不再有效【代码】

我使用的是一个向移动应用程序公开REST API的Web应用程序.我将我的Spring Boot版本从1.5.3.RELEASE升级到2.0.2.RELEASE,在修复了一些重大修改后,我面临着一个我无法解决的问题. 我跟着这个Spring Boot 2.0 Migration Guide和Spring Boot Security 2.0,也看了Security changes in Spring Boot 2.0 M4. 问题是该应用程序使用JWT身份验证,并且有一个端点(/ auth / login)接受用户凭据并生成一个长期存在的JWT作为回报. 有一个过滤器,用...