本文整理了Java中org.springframework.security.authentication.DisabledException.<init>()
方法的一些代码示例,展示了DisabledException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DisabledException.<init>()
方法的具体详情如下:
包路径:org.springframework.security.authentication.DisabledException
类名称:DisabledException
方法名:<init>
[英]Constructs a DisabledException
with the specified message.
[中]使用指定的消息构造一个DisabledException
。
代码示例来源:origin: spring-projects/spring-security
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
logger.debug("User account is locked");
throw new LockedException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.locked",
"User account is locked"));
}
if (!user.isEnabled()) {
logger.debug("User account is disabled");
throw new DisabledException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.disabled",
"User is disabled"));
}
if (!user.isAccountNonExpired()) {
logger.debug("User account is expired");
throw new AccountExpiredException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.expired",
"User account has expired"));
}
}
}
代码示例来源:origin: org.springframework.security/spring-security-core
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
logger.debug("User account is locked");
throw new LockedException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.locked",
"User account is locked"));
}
if (!user.isEnabled()) {
logger.debug("User account is disabled");
throw new DisabledException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.disabled",
"User is disabled"));
}
if (!user.isAccountNonExpired()) {
logger.debug("User account is expired");
throw new AccountExpiredException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.expired",
"User account has expired"));
}
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void testRejectsNullAuthentication() {
AuthenticationException exception = new DisabledException("TEST");
try {
new AuthenticationFailureDisabledEvent(null, exception);
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException expected) {
}
}
代码示例来源:origin: spring-projects/spring-security
private void raiseExceptionForErrorCode(int code, NamingException exception) {
String hexString = Integer.toHexString(code);
Throwable cause = new ActiveDirectoryAuthenticationException(hexString,
exception.getMessage(), exception);
switch (code) {
case PASSWORD_EXPIRED:
throw new CredentialsExpiredException(messages.getMessage(
"LdapAuthenticationProvider.credentialsExpired",
"User credentials have expired"), cause);
case ACCOUNT_DISABLED:
throw new DisabledException(messages.getMessage(
"LdapAuthenticationProvider.disabled", "User is disabled"), cause);
case ACCOUNT_EXPIRED:
throw new AccountExpiredException(messages.getMessage(
"LdapAuthenticationProvider.expired", "User account has expired"),
cause);
case ACCOUNT_LOCKED:
throw new LockedException(messages.getMessage(
"LdapAuthenticationProvider.locked", "User account is locked"), cause);
default:
throw badCredentials(cause);
}
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void testAbstractAuthenticationFailureEvent() {
Authentication auth = getAuthentication();
AuthenticationException exception = new DisabledException("TEST");
AbstractAuthenticationFailureEvent event = new AuthenticationFailureDisabledEvent(
auth, exception);
assertThat(event.getAuthentication()).isEqualTo(auth);
assertThat(event.getException()).isEqualTo(exception);
}
代码示例来源:origin: spring-projects/spring-security
publisher.publishAuthenticationFailure(new AccountExpiredException("", cause), a);
publisher.publishAuthenticationFailure(new ProviderNotFoundException(""), a);
publisher.publishAuthenticationFailure(new DisabledException(""), a);
publisher.publishAuthenticationFailure(new DisabledException("", cause), a);
publisher.publishAuthenticationFailure(new LockedException(""), a);
publisher.publishAuthenticationFailure(new LockedException("", cause), a);
代码示例来源:origin: spring-projects/spring-security
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
throw new LockedException(messages.getMessage(
"AccountStatusUserDetailsChecker.locked", "User account is locked"));
}
if (!user.isEnabled()) {
throw new DisabledException(messages.getMessage(
"AccountStatusUserDetailsChecker.disabled", "User is disabled"));
}
if (!user.isAccountNonExpired()) {
throw new AccountExpiredException(
messages.getMessage("AccountStatusUserDetailsChecker.expired",
"User account has expired"));
}
if (!user.isCredentialsNonExpired()) {
throw new CredentialsExpiredException(messages.getMessage(
"AccountStatusUserDetailsChecker.credentialsExpired",
"User credentials have expired"));
}
}
}
代码示例来源:origin: org.springframework.security/spring-security-core
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
throw new LockedException(messages.getMessage(
"AccountStatusUserDetailsChecker.locked", "User account is locked"));
}
if (!user.isEnabled()) {
throw new DisabledException(messages.getMessage(
"AccountStatusUserDetailsChecker.disabled", "User is disabled"));
}
if (!user.isAccountNonExpired()) {
throw new AccountExpiredException(
messages.getMessage("AccountStatusUserDetailsChecker.expired",
"User account has expired"));
}
if (!user.isCredentialsNonExpired()) {
throw new CredentialsExpiredException(messages.getMessage(
"AccountStatusUserDetailsChecker.credentialsExpired",
"User credentials have expired"));
}
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
AuthenticationManager m = delegate; // fix the reference we are working with
if (m == null) {
throw new DisabledException("Authentication service is still not ready yet");
} else {
return m.authenticate(authentication);
}
}
代码示例来源:origin: org.molgenis/molgenis-security
@Override
public void check(UserDetails userDetails) {
if (!userDetails.isEnabled()) {
throw new DisabledException(
messages.getMessage("AccountStatusUserDetailsChecker.disabled", "User is not active")
+ ' '
+ userDetails.toString());
}
}
}
代码示例来源:origin: liuht777/Taroco
/**
* 通过 Username 加载用户详情
*
* @param username 用户名
* @return UserDetails
* @throws UsernameNotFoundException 用户没找到
*/
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// 查询用户信息,包含角色列表
UserVO userVo = userService.findUserByUsername(username);
if (userVo == null) {
throw new UsernameNotFoundException("用户名/密码错误");
}
if (CommonConstant.DEL_FLAG.equals(userVo.getDelFlag())) {
throw new DisabledException("用户: " + username + " 不可用");
}
return new UserDetailsImpl(userVo);
}
代码示例来源:origin: craftingjava/springuni-particles
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String password = (String) authentication.getCredentials();
try {
User user = userService.login(username, password);
Collection<GrantedAuthority> authorities = user.getAuthorities()
.stream()
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toSet());
return new UsernamePasswordAuthenticationToken(user.getId(), null, authorities);
} catch (NoSuchUserException e) {
throw new UsernameNotFoundException(e.getMessage(), e);
} catch (UnconfirmedUserException e) {
throw new DisabledException(e.getMessage(), e);
}
}
代码示例来源:origin: org.springframework.security/org.springframework.security.core
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
logger.debug("User account is locked");
throw new LockedException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.locked",
"User account is locked"), user);
}
if (!user.isEnabled()) {
logger.debug("User account is disabled");
throw new DisabledException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.disabled",
"User is disabled"), user);
}
if (!user.isAccountNonExpired()) {
logger.debug("User account is expired");
throw new AccountExpiredException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.expired",
"User account has expired"), user);
}
}
}
代码示例来源:origin: com.foreach.across.modules/user-module
public void check( UserDetails user ) {
if ( !user.isAccountNonLocked() ) {
LOG.debug( "User account is locked" );
throw new LockedException( messages.getMessage( "AbstractUserInDirectoryAuthenticationProvider.locked",
"User account is locked" ) );
}
if ( !user.isEnabled() ) {
LOG.debug( "User account is disabled" );
throw new DisabledException(
messages.getMessage( "AbstractUserInDirectoryAuthenticationProvider.disabled",
"User is disabled" ) );
}
if ( !user.isAccountNonExpired() ) {
LOG.debug( "User account is expired" );
throw new AccountExpiredException(
messages.getMessage( "AbstractUserInDirectoryAuthenticationProvider.expired",
"User account has expired" ) );
}
}
}
代码示例来源:origin: org.molgenis/molgenis-security
@Override
@RunAsSystem
public void changePassword(String username, String newPassword) {
User user = dataService.query(USER, User.class).eq(USERNAME, username).findOne();
if (user == null) {
throw new MolgenisUserException(format("Unknown user [%s]", username));
}
if (!user.isActive()) {
throw new DisabledException(MolgenisLoginController.ERROR_MESSAGE_DISABLED);
}
user.setPassword(newPassword);
user.setChangePassword(false);
dataService.update(USER, user);
LOG.info("Changed password of user [{}]", username);
}
代码示例来源:origin: spring-projects/spring-ws
/**
* Checks the validity of a user's account and credentials.
* @param user the user to check
* @throws AccountExpiredException if the account has expired
* @throws CredentialsExpiredException if the credentials have expired
* @throws DisabledException if the account is disabled
* @throws LockedException if the account is locked
*/
public static void checkUserValidity(UserDetails user)
throws AccountExpiredException, CredentialsExpiredException, DisabledException, LockedException {
if (!user.isAccountNonLocked()) {
throw new LockedException("Account for user '" + user + "' is locked");
}
if (!user.isEnabled()) {
throw new DisabledException("User '" + user + "' is disabled");
}
if (!user.isAccountNonExpired()) {
throw new AccountExpiredException("Account for user '" + user + "' has expired");
}
if (!user.isCredentialsNonExpired()) {
throw new CredentialsExpiredException("Credentials for user '" + user + "' have expired");
}
}
}
代码示例来源:origin: org.carewebframework/org.carewebframework.vista.security.base
private void checkAuthResult(AuthResult result, IUser user) throws AuthenticationException {
switch (result.status) {
case SUCCESS:
return;
case CANCELED:
throw new AuthenticationCancelledException(StringUtils.defaultIfEmpty(result.reason,
"Authentication attempt was cancelled."));
case EXPIRED:
Sessions.getCurrent().setAttribute(org.carewebframework.security.spring.Constants.SAVED_USER, user);
throw new CredentialsExpiredException(
StringUtils.defaultIfEmpty(result.reason, "Your password has expired."));
case FAILURE:
throw new BadCredentialsException(StringUtils.defaultIfEmpty(result.reason,
"Your username or password was not recognized."));
case LOCKED:
throw new LockedException(StringUtils.defaultIfEmpty(result.reason,
"Your user account has been locked and cannot be accessed."));
case NOLOGINS:
throw new DisabledException(StringUtils.defaultIfEmpty(result.reason, "Logins are currently disabled."));
}
}
代码示例来源:origin: ORCID/ORCID-Source
private void checkStatuses(ProfileEntity profile) {
if (profile.getPrimaryRecord() != null) {
throw new DeprecatedProfileException("orcid.frontend.security.deprecated_with_primary", profile.getPrimaryRecord().getId(), profile.getId());
}
if (profile.getDeactivationDate() != null && !securityMgr.isAdmin()) {
throw new DisabledException("Account not active, please call helpdesk");
}
if (!profile.getClaimed() && !securityMgr.isAdmin()) {
throw new UnclaimedProfileExistsException("Unclaimed profile");
}
}
代码示例来源:origin: org.springframework.security/org.springframework.security.core
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
throw new LockedException(messages.getMessage("AccountStatusUserDetailsChecker.locked", "User account is locked"), user);
}
if (!user.isEnabled()) {
throw new DisabledException(messages.getMessage("AccountStatusUserDetailsChecker.disabled", "User is disabled"), user);
}
if (!user.isAccountNonExpired()) {
throw new AccountExpiredException(messages.getMessage("AccountStatusUserDetailsChecker.expired",
"User account has expired"), user);
}
if (!user.isCredentialsNonExpired()) {
throw new CredentialsExpiredException(messages.getMessage("AccountStatusUserDetailsChecker.credentialsExpired",
"User credentials have expired"), user);
}
}
}
代码示例来源:origin: apache/servicemix-bundles
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
throw new LockedException(messages.getMessage(
"AccountStatusUserDetailsChecker.locked", "User account is locked"));
}
if (!user.isEnabled()) {
throw new DisabledException(messages.getMessage(
"AccountStatusUserDetailsChecker.disabled", "User is disabled"));
}
if (!user.isAccountNonExpired()) {
throw new AccountExpiredException(
messages.getMessage("AccountStatusUserDetailsChecker.expired",
"User account has expired"));
}
if (!user.isCredentialsNonExpired()) {
throw new CredentialsExpiredException(messages.getMessage(
"AccountStatusUserDetailsChecker.credentialsExpired",
"User credentials have expired"));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!