List of usage examples for javax.security.auth.login LoginException getMessage
public String getMessage()
From source file:com.eucalyptus.objectstorage.pipeline.handlers.S3Authentication.java
/** * Authenticate using S3-spec REST authentication * * @param httpRequest/*from w w w . j a v a 2 s. c om*/ * @param authMap * @throws com.eucalyptus.objectstorage.exceptions.s3.AccessDeniedException */ static void authenticateVersion2(MappingHttpRequest httpRequest, Map<AuthorizationField, String> authMap) throws S3Exception { // Standard S3 authentication signed by SecretKeyID String verb = httpRequest.getMethod().getName(); String date = getDate(httpRequest); String addrString = getS3AddressString(httpRequest, true); String content_md5 = httpRequest.getHeader("Content-MD5"); content_md5 = content_md5 == null ? "" : content_md5; String content_type = httpRequest.getHeader(HttpHeaders.Names.CONTENT_TYPE); content_type = content_type == null ? "" : content_type; String securityToken = httpRequest.getHeader(ObjectStorageProperties.X_AMZ_SECURITY_TOKEN); String canonicalizedAmzHeaders = getCanonicalizedAmzHeaders(httpRequest, false); String data = verb + "\n" + content_md5 + "\n" + content_type + "\n" + date + "\n" + canonicalizedAmzHeaders + addrString; String accessKeyId = authMap.get(AuthorizationField.AccessKeyId); String signature = authMap.get(AuthorizationField.Signature); try { SecurityContext.getLoginContext(new ObjectStorageWrappedCredentials(httpRequest.getCorrelationId(), data, accessKeyId, signature, securityToken)).login(); } catch (LoginException ex) { if (ex.getMessage().contains("The AWS Access Key Id you provided does not exist in our records")) { throw new InvalidAccessKeyIdException(accessKeyId); } // Try using the '/services/ObjectStorage' portion of the addrString and retry the signature calc if (httpRequest.getUri().startsWith(ComponentIds.lookup(ObjectStorage.class).getServicePath()) || httpRequest.getUri().startsWith(ObjectStorageProperties.LEGACY_WALRUS_SERVICE_PATH)) { try { String modifiedAddrString = getS3AddressString(httpRequest, false); data = verb + "\n" + content_md5 + "\n" + content_type + "\n" + date + "\n" + canonicalizedAmzHeaders + modifiedAddrString; SecurityContext .getLoginContext(new ObjectStorageWrappedCredentials(httpRequest.getCorrelationId(), data, accessKeyId, signature, securityToken)) .login(); } catch (S3Exception ex2) { LOG.debug("CorrelationId: " + httpRequest.getCorrelationId() + " Authentication failed due to signature match issue:", ex2); throw ex2; } catch (Exception ex2) { LOG.debug("CorrelationId: " + httpRequest.getCorrelationId() + " Authentication failed due to signature match issue:", ex2); throw new SignatureDoesNotMatchException(data); } } else { LOG.debug("CorrelationId: " + httpRequest.getCorrelationId() + " Authentication failed due to signature mismatch:", ex); throw new SignatureDoesNotMatchException(data); } } catch (Exception e) { LOG.warn("CorrelationId: " + httpRequest.getCorrelationId() + " Unexpected failure trying to authenticateVersion2 request", e); throw new InternalErrorException(e); } }
From source file:org.trustedanalytics.examples.hbase.api.ExceptionHandlerAdvice.java
@ExceptionHandler @ResponseStatus(HttpStatus.FORBIDDEN)//from w w w . j av a 2 s . com @ResponseBody public String handleLoginException(LoginException ex) { LOG.error("Error logging in", ex); return ex.getMessage(); }
From source file:com.redhat.rhn.frontend.action.LoginAction.java
/** * Log a user into the site and create the user's session. * @param username User's login name./* w w w .j a va 2s . c om*/ * @param password User's unencrypted password. * @param request HttpServletRequest for this action. * @param response HttpServletResponse for this action. * @return Any action error messages that may have occurred. */ private User loginUser(String username, String password, HttpServletRequest request, HttpServletResponse response, ActionErrors e) { User user = null; try { user = UserManager.loginUser(username, password); } catch (LoginException ex) { e.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ex.getMessage())); } return user; }
From source file:com.cubusmail.server.services.CubusService.java
public void logout() throws Exception { try {//from w w w .j av a2 s . co m LoginContext context = new LoginContext(MailboxLoginModule.class.getSimpleName(), SessionManager.get().getSubject()); context.logout(); SessionManager.invalidateSession(); } catch (LoginException e) { log.error(e.getMessage(), e); throw new GWTLogoutException(e.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:io.druid.security.kerberos.DruidKerberosAuthenticationHandler.java
@Override public void destroy() { keytab = null;/*from w w w . ja va2 s . c o m*/ serverSubject = null; for (LoginContext loginContext : loginContexts) { try { loginContext.logout(); } catch (LoginException ex) { log.warn(ex, ex.getMessage()); } } loginContexts.clear(); }
From source file:com.vmware.o11n.plugin.powershell.remote.impl.winrm.KerberosTokenGenerator.java
@Override public String generateToken() { try {//from ww w . ja v a 2s . c om try { login(user, password); } catch (LoginException e) { String msg = e.getMessage(); if (!StringUtils.isNotBlank(msg)) { msg = "Login failed."; } throw new AuthenticationException(msg, e); } try { initiateSecurityContext(); } catch (GSSException e) { String msg = e.getMessage(); if (msg == null) { msg = "Login failed"; } throw new AuthenticationException(msg, e); } //TODO : Hidden option to change it With Negotiate return "Kerberos " + new String(Base64.encodeBase64(serviceTicket), CHARSET_UTF_8); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
From source file:com.cubusmail.server.services.CubusService.java
public GWTMailbox login(String username, String password) throws Exception { try {/*from w w w . j a va 2 s .com*/ LoginContext context = new LoginContext(MailboxLoginModule.class.getSimpleName(), new MailboxCallbackHandler(username, password)); context.login(); // if no exception thrown, login was successful SessionManager.createSession(context.getSubject()); IMailbox mailbox = SessionManager.get().getMailbox(); UserAccount account = this.userAccountDao.getUserAccountByUsername(username); // create useraccount if (account == null) { account = createUserAccount(mailbox); if (getThreadLocalRequest().getLocale() != null) { String lang = getThreadLocalRequest().getLocale().getLanguage(); account.getPreferences().setLanguage(lang); } } else { if (account.getIdentities() == null || account.getIdentities().size() == 0) { account.addIdentity(createDefaultIdentity(mailbox)); } account.setLastLogin(new Date()); this.userAccountDao.saveUserAccount(account); } mailbox.setUserAccount(account); GWTMailbox gwtMailbox = ConvertUtil.convert(mailbox); return gwtMailbox; } catch (LoginException e) { log.error(e.getMessage(), e); if (IErrorCodes.EXCEPTION_AUTHENTICATION_FAILED.equals(e.getMessage())) { throw new GWTAuthenticationException(e.getMessage()); } else if (IErrorCodes.EXCEPTION_CONNECT.equals(e.getMessage())) { throw new GWTConnectionException(e.getMessage()); } else { throw new GWTLoginException(e.getMessage()); } } }
From source file:be.fedict.hsm.ws.impl.JAASSOAPHandler.java
@Override public boolean handleFault(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty) { try {/*from ww w . j av a2 s . co m*/ logout(context); } catch (LoginException e) { this.securityAuditGeneratorBean.webServiceAuthenticationError(); throw new ProtocolException("JAAS logout error: " + e.getMessage(), e); } } return true; }
From source file:com.logiclander.jaasmine.authentication.SimpleAuthenticationService.java
/** * {@inheritDoc}//w w w.ja va2 s.c o m */ @Override public void logout(Subject s) { try { doLogout(applicationName, s); } catch (LoginException ex) { if (logger.isInfoEnabled()) { String msg = String.format("Logout failed: %s", ex.getMessage()); logger.info(msg); } } }
From source file:com.logiclander.jaasmine.authentication.SimpleAuthenticationService.java
/** * {@inheritDoc}/*from w w w . j av a 2s .com*/ */ @Override public Subject login(String userId, char[] password) { Subject s = null; try { CallbackHandler cbh = new SimpleCallbackHandler(userId, password); s = doLogin(applicationName, cbh); } catch (LoginException ex) { if (logger.isInfoEnabled()) { String msg = String.format("Could not log in %s: %s", userId, ex.getMessage()); logger.info(msg); } s = null; } return s; }