Examples of AuthenticationFailedException


Examples of org.apache.ftpserver.ftplet.AuthenticationFailedException

     * @see UserManager#authenticate(Authentication)
     */
    public User authenticate(final Authentication ftpAuthRequest)
            throws AuthenticationFailedException {
        if (!(ftpAuthRequest instanceof UsernamePasswordAuthentication)) {
            throw new AuthenticationFailedException();
        }
        final UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication) ftpAuthRequest;
        final String principal = upa.getUsername();
        final String credentials = upa.getPassword();
        org.springframework.security.core.Authentication gsAuth = new UsernamePasswordAuthenticationToken(
                principal, credentials);
        try {
            gsAuth = authManager.authenticate(gsAuth);
        } catch (org.springframework.security.core.AuthenticationException authEx) {
            throw new AuthenticationFailedException(authEx);
        }

        try {
            // gather the user
            BaseUser user = getUserByName(principal);
            user.setPassword(credentials);
            // is the user enabled?
            if (!user.getEnabled()) {
                throw new AuthenticationFailedException();
            }

            // scary message for admins if the username/password has not
            // been changed
            if (DEFAULT_USER.equals(user.getName()) && DEFAULT_PASSWORD.equals(credentials)) {
                LOGGER.log(Level.SEVERE, "The default admin/password combination has not been "
                        + "modified, this makes the embedded FTP server an "
                        + "open file host for everybody to use!!!");
            }

            final File dataRoot = dataDir.findOrCreateDataRoot();

            // enable only admins and non anonymous users
            boolean isGSAdmin = false;
            for (GrantedAuthority authority : gsAuth.getAuthorities()) {
                final String userRole = authority.getAuthority();
                if (ADMIN_ROLE.equals(userRole)) {
                    isGSAdmin = true;
                    break;
                }
            }

            final File homeDirectory;
            if (isGSAdmin) {
                homeDirectory = dataRoot;
            } else {
                /*
                 * This resolves the user's home directory to data/incoming/<user name> but does not
                 * create the directory if it does not already exist. That is left to when the user
                 * is authenticated, check the authenticate() method above.
                 */
                homeDirectory = new File(new File(dataRoot, "incoming"), user.getName());
            }
            String normalizedPath = homeDirectory.getAbsolutePath();
            normalizedPath = FilenameUtils.normalize(normalizedPath);
            user.setHomeDirectory(normalizedPath);
            if (!homeDirectory.exists()) {
                LOGGER.fine("Creating FTP home directory for user " + user.getName() + " at "
                        + normalizedPath);
                homeDirectory.mkdirs();
            }

            return user;
        } catch (AuthenticationFailedException e) {
            throw e;
        } catch (Exception e) {
            LOGGER.log(Level.INFO, "FTP authentication failure", e);
            throw new AuthenticationFailedException(e);
        }
    }
View Full Code Here

Examples of org.apache.ftpserver.ftplet.AuthenticationFailedException

     * @see UserManager#authenticate(Authentication)
     */
    public User authenticate(final Authentication ftpAuthRequest)
            throws AuthenticationFailedException {
        if (!(ftpAuthRequest instanceof UsernamePasswordAuthentication)) {
            throw new AuthenticationFailedException();
        }
        final UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication) ftpAuthRequest;
        final String principal = upa.getUsername();
        final String credentials = upa.getPassword();
        org.springframework.security.Authentication gsAuth = new UsernamePasswordAuthenticationToken(
                principal, credentials);
        try {
            gsAuth = authManager.authenticate(gsAuth);
        } catch (org.springframework.security.AuthenticationException authEx) {
            throw new AuthenticationFailedException(authEx);
        }

        try {
            // gather the user
            BaseUser user = getUserByName(principal);
            user.setPassword(credentials);
            // is the user enabled?
            if (!user.getEnabled()) {
                throw new AuthenticationFailedException();
            }

            // scary message for admins if the username/password has not
            // been changed
            if (DEFAULT_USER.equals(user.getName()) && DEFAULT_PASSWORD.equals(credentials)) {
                LOGGER.log(Level.SEVERE, "The default admin/password combination has not been "
                        + "modified, this makes the embedded FTP server an "
                        + "open file host for everybody to use!!!");
            }

            final File dataRoot = dataDir.findOrCreateDataRoot();

            // enable only admins and non anonymous users
            boolean isGSAdmin = false;
            for (GrantedAuthority authority : gsAuth.getAuthorities()) {
                final String userRole = authority.getAuthority();
                if (ADMIN_ROLE.equals(userRole)) {
                    isGSAdmin = true;
                    break;
                }
            }

            final File homeDirectory;
            if (isGSAdmin) {
                homeDirectory = dataRoot;
            } else {
                /*
                 * This resolves the user's home directory to data/incoming/<user name> but does not
                 * create the directory if it does not already exist. That is left to when the user
                 * is authenticated, check the authenticate() method above.
                 */
                homeDirectory = new File(new File(dataRoot, "incoming"), user.getName());
            }
            String normalizedPath = homeDirectory.getAbsolutePath();
            normalizedPath = FilenameUtils.normalize(normalizedPath);
            user.setHomeDirectory(normalizedPath);
            if (!homeDirectory.exists()) {
                LOGGER.fine("Creating FTP home directory for user " + user.getName() + " at "
                        + normalizedPath);
                homeDirectory.mkdirs();
            }

            return user;
        } catch (AuthenticationFailedException e) {
            throw e;
        } catch (Exception e) {
            LOGGER.log(Level.INFO, "FTP authentication failure", e);
            throw new AuthenticationFailedException(e);
        }
    }
View Full Code Here

Examples of org.ejbca.core.model.authorization.AuthenticationFailedException

      raauthorized = new Boolean[AUTHORIZED_FIELD_LENGTH];
    }

    private void commonInit() throws Exception {
      if ((administrator == null) && (certificates == null)) {
        throw new AuthenticationFailedException("Client certificate required.");
      } else if (certificates != null) {
        administrator = userAdminSession.getAdmin(certificates[0]);       
      } // else we have already defined an administrator, for example in initialize_errorpage

      globaldataconfigurationdatahandler = new GlobalConfigurationDataHandler(administrator, globalConfigurationSession, authorizationSession);       
View Full Code Here

Examples of org.ejbca.core.model.authorization.AuthenticationFailedException

    /* Sets the current user and returns the global configuration */
    public GlobalConfiguration initialize(HttpServletRequest request, String resource) throws Exception{
     
      certificates = (X509Certificate[]) request.getAttribute( "javax.servlet.request.X509Certificate" );
      if(certificates == null || certificates.length == 0) {
        throw new AuthenticationFailedException("Client certificate required.");
      }

     
      String userdn = "";
     
View Full Code Here

Examples of org.ejbca.core.model.authorization.AuthenticationFailedException

        // Check Validity
        try {
            certificate.checkValidity();
        } catch (Exception e) {
          String msg = intres.getLocalizedMessage("authentication.certexpired", CertTools.getNotAfter(certificate).toString());             
            throw new AuthenticationFailedException(msg);
        }
        if (requireAdminCertificateInDatabase) {
            // TODO: Verify Signature on cert? Not really needed since it's one of ou certs in the database.
            // Check if certificate is revoked.
            boolean isRevoked = isRevoked(CertTools.getIssuerDN(certificate),CertTools.getSerialNumber(certificate));
            if (isRevoked) {
                // Certificate revoked or missing in the database
              String msg = intres.getLocalizedMessage("authentication.revokedormissing");             
                throw new AuthenticationFailedException(msg);
            }
        } else {
          // TODO: We should check the certificate for CRL or OCSP tags and verify the certificate status
        }
    }
View Full Code Here

Examples of org.jboss.errai.bus.server.security.auth.AuthenticationFailedException

          .subjectProvided()
          .command(SecurityCommands.FailedAuth)
          .with(SecurityParts.Name, name)
          .noErrorHandling().sendNowWith(bus);

      throw new AuthenticationFailedException();
    }
  }
View Full Code Here

Examples of org.jboss.errai.bus.server.security.auth.AuthenticationFailedException

                    .subjectProvided()
                    .command(SecurityCommands.FailedAuth)
                    .with(SecurityParts.Name, name)
                    .noErrorHandling().sendNowWith(bus);

            throw new AuthenticationFailedException();
        }

    }
View Full Code Here

Examples of org.jboss.errai.bus.server.security.auth.AuthenticationFailedException

                    .subjectProvided()
                    .command(SecurityCommands.FailedAuth)
                    .with(SecurityParts.Name, name)
                    .noErrorHandling().sendNowWith(bus);

            throw new AuthenticationFailedException();
        }
    }
View Full Code Here

Examples of org.jboss.errai.bus.server.security.auth.AuthenticationFailedException

          .subjectProvided()
          .command(SecurityCommands.FailedAuth)
          .with(SecurityParts.Name, name)
          .noErrorHandling().sendNowWith(bus);

      throw new AuthenticationFailedException();
    }
  }
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.