本文整理了Java中org.springframework.security.authentication.LockedException
类的一些代码示例,展示了LockedException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LockedException
类的具体详情如下:
包路径:org.springframework.security.authentication.LockedException
类名称:LockedException
[英]Thrown if an authentication request is rejected because the account is locked. Makes no assertion as to whether or not the credentials were valid.
[中]如果由于帐户被锁定而拒绝身份验证请求,则引发。不断言凭据是否有效。
代码示例来源:origin: spring-projects/spring-security
public AuthenticationException resolveException(LoginException e) {
return new LockedException("This is just a test!");
}
});
代码示例来源:origin: org.flowable/flowable-ui-common
@ResponseStatus(HttpStatus.UNAUTHORIZED) // 401
@ExceptionHandler(LockedException.class)
@ResponseBody
public ErrorInfo handleLockedUser(LockedException e) {
ErrorInfo result = new ErrorInfo(e.getMessage());
result.setMessageKey(INACTIVE_USER_MESSAGE_KEY);
return result;
}
代码示例来源:origin: com.holon-platform.core/holon-spring-security
@Override
public Authentication authenticate(T authenticationToken) throws AuthenticationException {
if (authenticationToken == null) {
throw new InvalidTokenException("Null authentication token");
}
org.springframework.security.core.Authentication authentication = getAuthentication(authenticationToken);
if (authentication == null) {
throw new InvalidTokenException("Invalid authentication token: missing Spring Security Authentication");
}
try {
authentication = authenticationManager.authenticate(authentication);
} catch (UsernameNotFoundException e) {
throw new UnknownAccountException(e.getMessage());
} catch (BadCredentialsException e) {
throw new InvalidCredentialsException(e.getMessage());
} catch (CredentialsExpiredException | AccountExpiredException e) {
throw new ExpiredCredentialsException(e.getMessage());
} catch (DisabledException e) {
throw new DisabledAccountException(e.getMessage());
} catch (LockedException e) {
throw new LockedAccountException(e.getMessage());
} catch (Exception e) {
throw new UnexpectedAuthenticationException(e.getMessage(), e);
}
return SpringSecurityAuthentication.create(authentication);
}
代码示例来源: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: spring-projects/spring-security
@Test
public void authenticateWhenPostAuthenticationChecksFail() {
when(this.userDetailsService.findByUsername(any())).thenReturn(Mono.just(this.user));
doThrow(new LockedException("account is locked")).when(this.postAuthenticationChecks).check(any());
when(this.encoder.matches(any(), any())).thenReturn(true);
this.manager.setPasswordEncoder(this.encoder);
this.manager.setPostAuthenticationChecks(this.postAuthenticationChecks);
assertThatExceptionOfType(LockedException.class)
.isThrownBy(() -> this.manager.authenticate(new UsernamePasswordAuthenticationToken(this.user, this.user.getPassword())).block())
.withMessage("account is locked");
verify(this.postAuthenticationChecks).check(eq(this.user));
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void testLogsEvents() {
AuthenticationFailureDisabledEvent event = new AuthenticationFailureDisabledEvent(
getAuthentication(), new LockedException("TEST"));
LoggerListener listener = new LoggerListener();
listener.onApplicationEvent(event);
}
}
代码示例来源: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
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
@SuppressWarnings("deprecation")
public void statusExceptionIsPublished() throws Exception {
AuthenticationManager parent = mock(AuthenticationManager.class);
final LockedException expected = new LockedException("");
ProviderManager mgr = new ProviderManager(
Arrays.asList(createProviderWhichThrows(expected)), parent);
final Authentication authReq = mock(Authentication.class);
AuthenticationEventPublisher publisher = mock(AuthenticationEventPublisher.class);
mgr.setAuthenticationEventPublisher(publisher);
try {
mgr.authenticate(authReq);
fail("Expected exception");
}
catch (LockedException e) {
assertThat(e).isSameAs(expected);
}
verify(publisher).publishAuthenticationFailure(expected, authReq);
}
代码示例来源:origin: spring-projects/spring-security
@Override
protected DirContextOperations doAuthentication(
UsernamePasswordAuthenticationToken authentication) {
try {
return getAuthenticator().authenticate(authentication);
}
catch (PasswordPolicyException ppe) {
// The only reason a ppolicy exception can occur during a bind is that the
// account is locked.
throw new LockedException(this.messages.getMessage(
ppe.getStatus().getErrorCode(), ppe.getStatus().getDefaultMessage()));
}
catch (UsernameNotFoundException notFound) {
if (this.hideUserNotFoundExceptions) {
throw new BadCredentialsException(this.messages.getMessage(
"LdapAuthenticationProvider.badCredentials", "Bad credentials"));
}
else {
throw notFound;
}
}
catch (NamingException ldapAccessFailure) {
throw new InternalAuthenticationServiceException(
ldapAccessFailure.getMessage(), ldapAccessFailure);
}
}
代码示例来源:origin: spring-projects/spring-security
publisher.publishAuthenticationFailure(new DisabledException(""), a);
publisher.publishAuthenticationFailure(new DisabledException("", cause), a);
publisher.publishAuthenticationFailure(new LockedException(""), a);
publisher.publishAuthenticationFailure(new LockedException("", cause), a);
publisher.publishAuthenticationFailure(new AuthenticationServiceException(""), a);
publisher.publishAuthenticationFailure(new AuthenticationServiceException("",
代码示例来源: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: stackoverflow.com
else if(user.isLocked()) {
if(canUnlockUser(user)){
logger.info("|*|*| Unlocking account. Account Lock Timer Over.. |*|*|*|");
loginHistoryService.lockUserAccount(user.getUserId(), false);
} else {
throw new LockedException("Account is Locked");
}
}
代码示例来源:origin: stackoverflow.com
else if(user.isLocked()) {
if(canUnlockUser(user)){
logger.info("|*|*| Unlocking account. Account Lock Timer Over.. |*|*|*|");
loginHistoryService.lockUserAccount(user.getUserId(), false);
} else {
throw new LockedException("Account is Locked");
}
}
代码示例来源:origin: stackoverflow.com
throw new LockedException(error);
代码示例来源:origin: osiam/server
private void assertUserNotLocked(String username) {
if(isLockMechanismDisabled()) {
return;
}
Date logindate = lastFailedLogin.get(username);
if(logindate != null && isWaitTimeOver(logindate)) {
accessCounter.remove(username);
lastFailedLogin.remove(username);
}
if (accessCounter.get(username) != null && accessCounter.get(username) >= maxLoginFailures) {
throw new LockedException("The user '" + username + "' is temporary locked.");
}
}
代码示例来源:origin: stackoverflow.com
throw new LockedException(error);
代码示例来源:origin: com.erudika/para
throw new BadCredentialsException("Bad credentials.");
} else if (!user.isEnabled()) {
throw new LockedException("Account is locked.");
代码示例来源:origin: org.genesys-pgr/application-blocks-security
LOG.warn(e.getMessage());
throw new LockedException("Too many failed login attempts.");
内容来源于网络,如有侵权,请联系作者删除!