throw new CredentialException("User could not be authenticated");
logger.warn("Invalid username or password for user {} ({})", kcc.getUserName(), e.getMessage()); CredentialException ce = new CredentialException("Invalid username and/or password or disabled or expired account!"); ce.setStackTrace(e.getStackTrace()); loginMetric.getInvalidUserPassword().inc(); throw ce;
private String[] readFields(final byte[] buffer) throws CredentialException { List<String> fields = new ArrayList<>(); int pos = 0; Buffer b = Buffer.buffer(); while (pos < buffer.length) { byte val = buffer[pos]; if (val == 0x00) { fields.add(b.toString(StandardCharsets.UTF_8)); b = Buffer.buffer(); } else { b.appendByte(val); } pos++; } fields.add(b.toString(StandardCharsets.UTF_8)); if (fields.size() != 3) { throw new CredentialException("client provided malformed PLAIN response"); } else if (fields.get(1) == null || fields.get(1).length() == 0) { throw new CredentialException("PLAIN response must contain an authentication ID"); } else if(fields.get(2) == null || fields.get(2).length() == 0) { throw new CredentialException("PLAIN response must contain a password"); } else { return fields.toArray(new String[3]); } }
throw new CredentialException("client provided malformed PLAIN response"); } else if (fields.get(1) == null || fields.get(1).length() == 0) { throw new CredentialException("PLAIN response must contain an authentication ID"); } else if (fields.get(2) == null || fields.get(2).length() == 0) { throw new CredentialException("PLAIN response must contain a password"); } else { return fields.toArray(new String[3]);
throw new CredentialException("client provided malformed PLAIN response"); } else if (fields.get(1) == null || fields.get(1).length() == 0) { throw new CredentialException("PLAIN response must contain an authentication ID"); } else if (fields.get(2) == null || fields.get(2).length() == 0) { throw new CredentialException("PLAIN response must contain a password"); } else { return fields.toArray(new String[3]);
throw new CredentialException("unsupported credentials"); getBytes("UTF-8")); } catch (IOException ioe) { throw new CredentialException("Could not get password: " + ioe.getMessage()); throw new CredentialException("Invalid credentials");
throw new CredentialException("unsupported credentials"); getBytes("UTF-8")); } catch (IOException ioe) { throw new CredentialException("Could not get password: " + ioe.getMessage()); throw new CredentialException("Invalid credentials");
throw new CredentialException("unsupported credentials"); getBytes("UTF-8")); } catch (IOException ioe) { throw new CredentialException("Could not get password: " + ioe.getMessage()); throw new CredentialException("Invalid credentials");
/** * Always authenticates the given user unless the credentials are not * of type <code>NamePasswordCredentials</code>, in which case a * <code>CredentialException</code> is thrown. * * @param credentials the identity's credentials, which must be an * instance of <code>NamePasswordCredentials</code> * * @return the identity of the given user * * @throws CredentialException if the wrong type of credentials were * provided */ public Identity authenticateIdentity(IdentityCredentials credentials) throws CredentialException { if (!(credentials instanceof NamePasswordCredentials)) { throw new CredentialException("unsupported credentials type"); } return new IdentityImpl(((NamePasswordCredentials) credentials). getName()); }
/** * Always authenticates the given user unless the credentials are not * of type <code>NamePasswordCredentials</code>, in which case a * <code>CredentialException</code> is thrown. * * @param credentials the identity's credentials, which must be an * instance of <code>NamePasswordCredentials</code> * * @return the identity of the given user * * @throws CredentialException if the wrong type of credentials were * provided */ public Identity authenticateIdentity(IdentityCredentials credentials) throws CredentialException { if (!(credentials instanceof NamePasswordCredentials)) { throw new CredentialException("unsupported credentials type"); } return new IdentityImpl(((NamePasswordCredentials) credentials). getName()); }
/** * Always authenticates the given user unless the credentials are not * of type <code>NamePasswordCredentials</code>, in which case a * <code>CredentialException</code> is thrown. * * @param credentials the identity's credentials, which must be an * instance of <code>NamePasswordCredentials</code> * * @return the identity of the given user * * @throws CredentialException if the wrong type of credentials were * provided */ public Identity authenticateIdentity(IdentityCredentials credentials) throws CredentialException { if (!(credentials instanceof NamePasswordCredentials)) { throw new CredentialException("unsupported credentials type"); } return new IdentityImpl(((NamePasswordCredentials) credentials). getName()); }
throw new GeneralSecurityException("HTTP protocol error", e); } catch (final SSLPeerUnverifiedException e) { throw new CredentialException("Untrusted certificate presented by CAS proxy callback endpoint"); } catch (final SSLException e) { if (e.getCause() instanceof CertificateException) {
authenticatorMap.get(credentials.getCredentialsType()); if (authenticators == null) { throw new CredentialException("Unsupported credentials type: " + credentials.getCredentialsType()); throw new CredentialException("Could not authenticate identity");
authenticatorMap.get(credentials.getCredentialsType()); if (authenticators == null) { throw new CredentialException("Unsupported credentials type: " + credentials.getCredentialsType()); throw new CredentialException("Could not authenticate identity");
authenticatorMap.get(credentials.getCredentialsType()); if (authenticators == null) { throw new CredentialException("Unsupported credentials type: " + credentials.getCredentialsType()); throw new CredentialException("Could not authenticate identity");
@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(HttpServletRequest request, HttpServletResponse response, Model model) { HttpRequestResponseHolder holder = new HttpRequestResponseHolder(request, response); httpSessionSecurityContextRepository.loadContext(holder); try { // 使用提供的证书认证用户 List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_USER", "ROLE_ADMIN"); Authentication auth = new UsernamePasswordAuthenticationToken(request.getParameter("username"), request.getParameter("password"), authorities); SecurityContextHolder.getContext().setAuthentication(authenticationManager.authenticate(auth)); // 认证用户 if(!auth.isAuthenticated()) throw new CredentialException("用户不能够被认证"); } catch (Exception ex) { // 用户不能够被认证,重定向回登录页 logger.info(ex); return "login"; } // 从会话得到默认保存的请求 DefaultSavedRequest defaultSavedRequest = (DefaultSavedRequest) request.getSession().getAttribute("SPRING_SECURITY_SAVED_REQUEST"); // 为令牌请求生成认证参数Map Map<String, String> authParams = getAuthParameters(defaultSavedRequest); AuthorizationRequest authRequest = new DefaultOAuth2RequestFactory(clientDetailsService).createAuthorizationRequest(authParams); authRequest.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_USER", "ROLE_ADMIN")); model.addAttribute("authorizationRequest", authRequest); httpSessionSecurityContextRepository.saveContext(SecurityContextHolder.getContext(), holder.getRequest(), holder.getResponse()); return "authorize"; }
completer.handle(Future.failedFuture(new CredentialException("Missing client certificate"))); } else if (!X509Certificate.class.isInstance(peerCertificateChain[0])) { completer.handle(Future.failedFuture(new CredentialException("Only X.509 certificates are supported"))); } else { .compose(tenant -> { if (!tenant.isAdapterEnabled(Constants.PROTOCOL_ADAPTER_TYPE_AMQP)) { return Future.failedFuture(new CredentialException( String.format("AMQP adapter is disabled for Tenant [tenantId: %s]", tenant.getTenantId()))); return null; }).otherwise(t -> { completer.handle(Future.failedFuture(new CredentialException(t.getMessage()))); return null; });
if ((encrypted != null) || (algInfo != null) || (initVector != null)) { if (passwordProvider == null) { throw new CredentialException("Missing password provider for encrypted resource=" + resourceKey);
if (!checkRights(info, "edit") || (Boolean)info.get("exists") && !checkRights(info, "create")) CredentialException ex = new CredentialException("Permission denied: page is protected."); log(Level.WARNING, "edit", "Cannot edit - permission denied. " + ex); throw ex;
if ((encrypted != null) || (algInfo != null) || (initVector != null)) { if (passwordProvider == null) { throw new CredentialException("Missing password provider for encrypted resource=" + resourceKey);