Tag: authentication

Spring需要一个’AuthenticationManager’类型的bean

我一直在尝试按照在这里找到的教程来设置演示,以帮助我在我的本地机器上理解SSO,然后再在另一个项目中实现。 我遇到了一个让我陷入困境的问题。 我收到并告诉我添加一个bean的错误。 请告诉我我错过的代码。 我无法让程序运行。 文件系统树 AuthApplication.java package com.spud.auth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; @SpringBootApplication @EnableResourceServer public class AuthApplication { public static void main(String[] args) { SpringApplication.run(AuthApplication.class, args); } @Configuration protected static […]

如何使用DaoAuthenticationProvider以编程方式使用Spring Security对用户进行身份validation

我想知道我在这里做错了什么来validation用户。 我有一个应用程序,其中用户通过几个步骤来激活他们的帐户,并且在这样做时,我想绕过登录表单并将它们直接带到他们的仪表板。 这是我的自动登录function: protected void automatedLogin(String username, String password, HttpServletRequest request) { try { // Must be called from request filtered by Spring Security, otherwise SecurityContextHolder is not updated CustomUserDetailsService udService = new CustomUserDetailsService(userDAO, request); UserDetails uDetails = udService.loadUserByUsername(username); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(uDetails, password); token.setDetails(new WebAuthenticationDetails(request)); DaoAuthenticationProvider authenticator = new DaoAuthenticationProvider(); Authentication authentication = […]

身份validation:Kerberos还是SSL?

我正处于Java EE应用程序的“预设计”阶段(如果有这样的事情!),它将在客户端使用Swing框并实现Web和服务器层的组件。 我立即提出了一些技术选择,并一直在阅读Kerberos和SSL如何工作之间的差异。 我无法找到任何答案的一个领域是如何在Kerberos或SSL之间进行选择的主题。 换句话说,您如何判断何时使用任何一种协议? 假设Swing客户端不受特定传输(UDP,TCP或其他)的约束,并且可以使用/ any。 如何选择这两者中的哪一个更适合其应用? 谢谢!

Java – javax.net.ssl.SSLPeerUnverifiedException:peer未经过身份validation

我正在尝试使用自己的SSL客户端连接到我自己的SSL服务器,但是我收到以下错误: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at sun.security.ssl.SSLSessionImpl.getPeerCertificateChain(SSLSessionImpl.java:420) at server.run(Server.java:70) at server.main(Server.java:22) 我在stackoverflow上搜索了同样的问题,但我只能找到在Apache或其他HTTPS“系统”中使用它的人。 这是我的服务器代码: /* Server SSL */ import javax.net.ssl.*; import java.io.*; import java.net.InetAddress; import java.security.KeyStore; //import java.security.cert.X509Certificate; import java.util.Date; import javax.security.cert.X509Certificate; class server { ObjectOutputStream out; ObjectInputStream in; public static void main(String[] args) { new server().run(); } void run() { Date date = new Date(); […]

Spring安全打开弹出窗口

当用户执行需要进行身份validation但未执行身份validation的操作时,有人知道如何打开弹出窗口进行身份validation(使用spring security)。 例如:假设页面有一个“立即购买”按钮,将产品添加到购物车并执行结帐(立即购买页面),如果用户已经过身份validation,或者打开弹出窗口供用户执行身份validation。 如果validation成功,则弹簧重定向到“立即购买”页面,或者在打开弹出窗口时停留在该页面中(错误消息“错误登录”)。 我已经在谷歌搜索了一种解决方案,但没有运气。 有人可以指出我正确的方向吗? 谢谢

使用Spring Security在运行时切换身份validation方法?

通常,当您为应用程序声明不同的“”(在我的情况下为webapp)时,Spring Security将负责一个接一个地调用提供程序,以防止失败。 因此,假设我在配置文件中首先声明了DatabaseAuthenticationProvider和LDAPAuthenticationProvider,并且在运行时首先调用DatabaseAuthenticationProvider,如果身份validation失败,则尝试LDAPAuthentication。 这很酷 – 但是,我需要的是运行时切换。 我想有一个选择在这两种方法之间选择(基于数据库的身份validation/基于ldap的身份validation),并以某种方式基于这个全局设置来实现实现。 我该怎么做? 是否可以使用Spring-Security?

使用JNDI / Java中的当前用户在LDAP上进行身份validation

我以为我会发现更多关于这个话题,但我没有。 我必须编写一个java应用程序来检查特定用户是哪个用户。 但是要对服务器进行身份validation,我不能要求输入用户名和密码,也不能将其存储在源(或其他文件)中。 有没有办法让JNDI和Java与当前登录的用户进行身份validation?

JBOSS 7有两个上下文。 一个使用SSL Mutual Auth,另一个只使用SSL

我们在配置JBoss时遇到问题。 我们正在配置它,以便可以同时使用Mutual auth并且不使用它。 喜欢: https://example.com/contextA/ (需要SSL相互身份validation) https://example.com/contextB/ (只需SSL) 可能吗? 我能做的是使JBoss或所有JBoss使用SSL相互认证或不使用。 如何将其配置为同时进行? 我的contextA web.xml: ContextA services /* GET * CONFIDENTIAL CLIENT-CERT 我的contextA jboss-web.xml RequireCertificateDomain ContextB web.xml ContextB *.jsp true 10 true index.jsp SecureApplicationConstraint ContextB Auth applications are secured /login/* Only Users with roles are allowed USER CONFIDENTIAL SecureChannelConstraint Entire site is protected through SSL /contextB/* Require […]

如何使JMX自定义身份validation工作?

我在JMX上使用密码和基于访问文件的身份validation。 构建我的JMXConnectorServer时,我使用属性名称,它工作正常。 Map env = new HashMap(); env.put(ApplicationProperties.JMX_PWD_FILE_PROP, pwdFile); env.put(ApplicationProperties.JMX_ACCESS_FILE_PROP, accFile); connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, env, mBeanServer); 但是,现在我想使用自定义身份validation器,我实现了自己的LoginModule,在密码文件中有一个加密密码。 因此,想法是在密码文件中具有加密密码和纯文本用户名。 public class ABCDJMXLoginModule implements LoginModule { private CallbackHandler callbackHandler; private Subject subject; private String u_username; private String u_password; private JMXPrincipal user; private Properties userCredentials; private String passwordFile; private String f_username; private String f_password; private static final Logger […]

Spring安全性返回String作为主体而不是登录失败时的UserDetails?

要么我错过了什么,要么它是如何工作的…… 也就是说,我实现了UserDetailsService和子类(下面的AppUser )spring实用程序类User (实现UserDetails )。 如果重要,它会是这样的: @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { // try loading user by its name SystemUser user = null; try { user = this.sysUserService.getByUsername(username); if(user == null) throw new UsernameNotFoundException(“User not found!”); } catch(Exception e) { throw new DataRetrievalFailureException( “Could not load user with username: ” + username); } […]