Examples of LoginException


Examples of javax.security.auth.login.LoginException

        PasswordCallback passwordCallback = new PasswordCallback("password", true);

        try {
            callbackHandler.handle(new Callback[]{usernameCallback, passwordCallback});
        } catch (UnsupportedCallbackException ex) {
            LoginException le = new LoginException("callback is not supported");
            le.initCause(ex);
            throw le;
        } catch (IOException ex) {
            LoginException le = new LoginException("io error in callback handler");
            le.initCause(ex);
            throw le;
        }

        String password = new String(passwordCallback.getPassword());
        Properties props = new Properties();
View Full Code Here

Examples of javax.security.auth.login.LoginException

    public static LoginException newLoginException(String msg, Object [] params) {
        String message = rb().getString(msg);
        if(params != null) {
            message = MessageFormat.format(message, params);
        }
        return new LoginException(message);
    }
View Full Code Here

Examples of net.sf.jml.exception.LoginException

                            // must logout and throw exception or something
                            if(nonce == null)
                            {
                                ((AbstractMessenger)messenger).
                                    fireExceptionCaught(
                                        new LoginException(
                                            "Login Failed, nonce is missing!"));
                                ((AbstractMessenger)messenger).logout();

                                return;
                            }

                            MsnOwner owner = session.getMessenger().getOwner();

                            if(!(owner instanceof MsnOwnerImpl))
                                return;

                            String username = owner.getEmail().getEmailAddress();
                            String pass = ((MsnOwnerImpl)owner).getPassword();

                            SSO sso = session.createSSO(username, pass, policy, nonce);

                            String ticket = sso.getTicket();

                             // must logout and throw exception or something
                            if(ticket == null)
                            {
                                ((AbstractMessenger)messenger).
                                    fireExceptionCaught(
                                        new LoginException(
                                            "Login Failed, error making ticket!"));
                                ((AbstractMessenger)messenger).logout();
                                return;
                            }
View Full Code Here

Examples of nexj.core.util.auth.LoginException

         case HTTP.STATUS_PROXY_AUTHENTICATION:

            // Disallow proxy auth if no proxy or through a tunnel
            if (!isHTTPProxy() || m_nTunnelStatus == TUNNEL_ESTABLISHED)
            {
               throw new LoginException("Proxy authentication disallowed to non-proxy");
            }

            m_currentAuthentication = m_proxyAuthentication;

            break;

         case HTTP.STATUS_FORBIDDEN:
            if (s_logger.isDebugEnabled())
            {
               s_logger.debug("Authentication error " +
                  m_nResponseStatus + ": " + m_sResponseMessage);
            }

            m_bAuthDone = false;

            if (m_currentAuthentication.getProvider() == null || m_currentAuthentication.getProvider().isAuthenticationDeterministic())
            {
               return true;
            }

            if (m_currentAuthentication.getSPNEGO() == SPNEGO_SILENT)
            {
               m_currentAuthentication.setSPNEGO(SPNEGO_CRED);
               m_nBasicCount = 0;
               m_sToken = null;

               if (m_authenticator != null)
               {
                  m_authenticator.dispose();
                  m_authenticator = null;
               }

               resetAuth();

               return false;
            }

            break;

         default:
            completeAuthentication();

            return true;
      }

      if (m_nBasicCount < 0 && m_currentAuthentication.getUserSaved() == null)
      {
         m_nBasicCount = 0;
      }

      if (m_bAuthDone)
      {
         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Authentication error " +
               m_nResponseStatus + ": " + m_sResponseMessage);
         }
      }

      int nProtocol = m_currentAuthentication.parseAuthProtocol();

      while (nProtocol == AUTH_SPNEGO)
      {
         if (m_authenticator == null)
         {
            try
            {
               m_authenticator = AuthenticatorFactory.create();
            }
            catch (Exception e)
            {
               m_serverAuthentication.setSPNEGO(SPNEGO_NONE);
               m_proxyAuthentication.setSPNEGO(SPNEGO_NONE);
               nProtocol = m_currentAuthentication.parseAuthProtocol();
            }
         }

         if (m_authenticator != null)
         {
            try
            {
               byte[] token;

               if (m_sToken == null)
               {
                  if (m_currentAuthentication.getSPNEGO() == SPNEGO_SILENT && !m_bAuthDone)
                  {
                     // Use mutual authentication due to bug #6733095 in Sun's JRE: http://bugs.sun.com/view_bug.do?bug_id=6733095
                     m_authenticator.init(Authenticator.PROTOCOL_SPNEGO, Authenticator.MODE_MUTUAL, m_currentAuthentication.getServiceName(), null, null, null);
                  }
                  else
                  {
                     m_currentAuthentication.setSPNEGO(SPNEGO_CRED);
                     m_bAuthDone = false;

                     if (m_nBasicCount < 0)
                     {
                        m_currentAuthentication.copyFromSaved();
                     }
                     else
                     {
                        m_currentAuthentication.clearUserPassword();
                     }

                     if (m_nBasicCount++ == MAX_BASIC_ATTEMPTS || !retrievePassword())
                     {
                        throw new IOException("Too many authentication attempts");
                     }

                     // Use mutual authentication due to bug #6733095 in Sun's JRE: http://bugs.sun.com/view_bug.do?bug_id=6733095
                     m_authenticator.init(Authenticator.PROTOCOL_SPNEGO, Authenticator.MODE_MUTUAL, m_currentAuthentication.getServiceName(), null, m_currentAuthentication.getUser(), m_currentAuthentication.getPassword());
                  }

                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Starting authentication sequence with service \"" + m_currentAuthentication.getServiceName() +
                        ((m_currentAuthentication.getUser() == null) ? "\"" : "\", user \"" + m_currentAuthentication.getUser() + "\""));
                  }

                  token = m_authenticator.nextToken(null);
               }
               else
               {
                  token = Base64Util.decode(m_sToken);

                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Authentication response token " + new Binary(token));
                  }

                  token = m_authenticator.nextToken(token);
               }

               resetAuth();

               if (token != null)
               {
                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Authentication request token " + new Binary(token));
                  }

                  setAuthToken(AUTH_SPNEGO, token);
               }

               if (m_authenticator.isDone())
               {
                  m_authenticator.dispose();
                  m_authenticator = null;
                  m_bAuthDone = true;
               }

               return false;
            }
            catch (CancellationException e)
            {
               throw e;
            }
            catch (Exception e)
            {
               s_logger.debug("Authentication error", e);

               if (m_currentAuthentication.getSPNEGO() == SPNEGO_SILENT &&
                  e instanceof LoginException)
               {
                  m_currentAuthentication.setSPNEGO(SPNEGO_CRED);
               }
               else
               {
                  m_currentAuthentication.setSPNEGO(SPNEGO_NONE);
                  nProtocol = m_currentAuthentication.parseAuthProtocol();
                  m_authenticator.dispose();
                  m_authenticator = null;
               }

               m_nBasicCount = 0;
               m_sToken = null;
            }
         }
      }

      if (nProtocol == AUTH_BASIC)
      {
         if (m_nBasicCount < 0)
         {
            m_currentAuthentication.copyFromSaved();
         }

         if (m_nBasicCount++ == MAX_BASIC_ATTEMPTS || !retrievePassword())
         {
            m_authHeader = null;

            throw new LoginException();
         }

         StringBuffer buf = new StringBuffer(32);

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Attempting basic authentication for user \"" + m_currentAuthentication.getUser() + "\"");
         }

         if (m_currentAuthentication.getUser() != null)
         {
            buf.append(m_currentAuthentication.getUser());
         }

         buf.append(':');

         if (m_currentAuthentication.getPassword() != null)
         {
            buf.append(m_currentAuthentication.getPassword());
         }

         byte[] token = buf.toString().getBytes("UTF-8");

         for (int i = 0; i < buf.length(); ++i)
         {
            buf.setCharAt(i, ' ');
         }

         m_currentAuthentication.setUser(null);

         resetAuth();
         setAuthToken(AUTH_BASIC, token);
         Arrays.fill(token, (byte)0);

         return false;
      }

      throw new LoginException();
   }
View Full Code Here

Examples of org.apache.jetspeed.services.security.LoginException

        throws LoginException
    {

        if (username.equals(this.anonymousUser))
        {
            throw new LoginException("Anonymous user cannot login");
        }

        JetspeedUser user = null;

        username = JetspeedSecurity.convertUserName(username);
        password = JetspeedSecurity.convertPassword(password);
      
        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(username));
            password = JetspeedSecurity.encryptPassword(password);
        }                           
        catch (UnknownUserException e)
        {
            logger.warn("Unknown user attempted access: " + username, e);
            throw new FailedLoginException(e.toString());
        }
        catch (JetspeedSecurityException e)
        {
            logger.warn("User denied authentication: " + username, e);
            throw new LoginException(e.toString());
        }

        if(!user.getPassword().equals(password))
        {
            logger.error("Invalid password for user: " + username);
            throw new FailedLoginException("Credential authentication failure");
       

        // Check for password expiration
        if (this.expirationPeriod > 0)
        {
            Date passwordLastChangedDate = user.getPasswordChanged();
            Date passwordExpireDate = null;
            if (passwordLastChangedDate != null) {
                GregorianCalendar gcal = (GregorianCalendar) GregorianCalendar.getInstance();
                gcal.setTime(passwordLastChangedDate);
                gcal.add(GregorianCalendar.DATE, this.expirationPeriod);
                passwordExpireDate = gcal.getTime();
                if (logger.isDebugEnabled())
                {
                    logger.debug("TurbineAuthentication: password last changed = " + passwordLastChangedDate.toString() +
                              ", password expires = " + passwordExpireDate.toString());
                }
            }

            if (passwordExpireDate == null || (new Date().getTime() > passwordExpireDate.getTime())) {
                throw new CredentialExpiredException("Password expired");
            }

        }

        // Mark the user as being logged in.
        user.setHasLoggedIn(new Boolean(true));

        // Set the last_login date in the database.
        try
        {
            user.updateLastLogin();
            putUserIntoContext(user);
            if (cachingEnable)
            {
                JetspeedSecurityCache.load(username);
            }
        }
        catch (Exception e)
        {
            logger.error( "Failed to update last login ", e);
            putUserIntoContext(JetspeedSecurity.getAnonymousUser());
            throw new LoginException("Failed to update last login ", e);
        }

        return user;
       
    }
View Full Code Here

Examples of org.apache.sling.api.resource.LoginException

            }

            @Override
            public ResourceResolver clone(Map<String, Object> authenticationInfo)
                    throws LoginException {
                throw new LoginException("MockResourceResolver can't be cloned - excepted for this test!");
            }

            public void refresh() {
                // nothing to do
            }
View Full Code Here

Examples of org.apache.sling.api.resource.LoginException

        // this should yield guest access or no access at all. For now
        // no access is granted if there is no service user defined for
        // the bundle.
        final String userName = this.serviceUserMapper.getServiceUserID(this.usingBundle, subServiceName);
        if (userName == null) {
            throw new LoginException("Cannot derive user name for bundle "
                + this.usingBundle + " and sub service " + subServiceName);
        }

        // ensure proper user name and service bundle
        authenticationInfo.put(ResourceResolverFactory.USER, userName);
View Full Code Here

Examples of org.apache.sling.api.resource.LoginException

                        final SlingRepository repo = (SlingRepository) bc.getService(repositoryReference);
                        if (repo == null) {
                            log.warn(
                                "getResourceProviderInternal: Cannot login service because cannot get SlingRepository on behalf of bundle {} ({})",
                                bc.getBundle().getSymbolicName(), bc.getBundle().getBundleId());
                            throw new LoginException(); // TODO: correct ??
                        }

                        try {
                            session = repo.loginService(subServiceName, workspace);
                            holder.setRepositoryReference(bc, repositoryReference);
View Full Code Here

Examples of org.apache.sling.api.resource.LoginException

     * @param re The repository exception.
     * @return The login exception.
     */
    private LoginException getLoginException(final RepositoryException re) {
        if ( re instanceof javax.jcr.LoginException ) {
            return new LoginException(re.getMessage(), re.getCause());
        }
        return new LoginException("Unable to login " + re.getMessage(), re);
    }
View Full Code Here

Examples of org.apache.stanbol.commons.security.auth.LoginException

        if (authenticationService.authenticateUser(userName, password)) {
          subject.getPrincipals().remove(UserUtil.ANONYMOUS);
          subject.getPrincipals().add(new PrincipalImpl(userName));
          return true;
        } else {
          throw new LoginException(LoginException.PASSWORD_NOT_MATCHING);
        }
      } catch (NoSuchAgent ex) {
        throw new LoginException(LoginException.USER_NOT_EXISTING);
      }
    } else {
      return false;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.