Package org.jmanage.core.auth

Examples of org.jmanage.core.auth.User


        throws Exception {
       
       /* get old password from user */
       char [] oldPassword = getOldPassword() ;
       UserManager userMgr = UserManager.getInstance() ;
       User user = userMgr.verifyUsernamePassword(AuthConstants.USER_ADMIN,oldPassword);
        if(user == null) {
            System.out.println("\nInvalid password") ;
            return ;
        }
         /* get new password from user */
        char[] newPassword = getPassword();
        if(newPassword == null){
            return;
        }

          /* Get list of configured applications */
        Crypto.init(oldPassword) ;
        Config config = ConfigReader.getInstance().read() ;
        if(config == null) {
            System.out.println("\nError in reading application passwords") ;
            return ;
        }

        /* Write new key to file */
      EncryptedKey encryptedKey = new EncryptedKey(newPassword);
      KeyManager.writeKey(encryptedKey);
      /* Change admin password */
      UserManager.getInstance().deleteUser(AuthConstants.USER_ADMIN);
      List roles = new ArrayList(1); // TODO: Shouldn't this be zero ? -rk
      UserManager.getInstance().addUser(new User(AuthConstants.USER_ADMIN,
      Crypto.hash(newPassword), roles, User.STATUS_ACTIVE, 0));
      Crypto.init(newPassword);
      ConfigWriter.getInstance().write(config);
      System.out.println("New key has been written to key file successfully..");
    }
View Full Code Here


        throws Exception {

        final UserManager userManager = UserManager.getInstance();
        final char[] oldPassword =
                PasswordField.getPassword("Enter Old password:");
        final User admin = userManager.verifyUsernamePassword(AuthConstants.USER_ADMIN,
                oldPassword);
        if(admin == null){
            System.out.println("Invalid password.");
            return;
        }

        final char[] newPassword = getNewPassword();
        if(newPassword == null){
            return;
        }

        /* update the password for admin */
        admin.setPassword(Crypto.hash(newPassword));
        userManager.updateUser(admin);

        /* re-encrypt the key */
        EncryptedKey encryptedKey = KeyManager.readKey(oldPassword);
        encryptedKey.setPassword(newPassword);
View Full Code Here

    private static void authenticate(ServiceContextImpl context,
                                     String className,
                                     String methodName){

        User user = context.getUser();
        if(user == null){
            /* only the login method in AuthService is allowed without
                authentication */
            if(!className.equals(AuthService.class.getName())
                    || !methodName.equals("login")){

                throw new RuntimeException("Service method called without " +
                        "User credentials");
            }
            return;
        }

        /* User must have username and password specified */
        assert user.getUsername() != null;
        assert user.getPassword() != null;

        /* authenticate with the server */
        AuthService authService = ServiceFactory.getAuthService();
        try {
            authService.login(context, user.getUsername(), user._getPlaintextPassword());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

                                                   String password,
                                                   String applicationName,
                                                   String mbeanName){
        ServiceContextImpl context = new ServiceContextImpl();
        /* set user */
        User user = new User(username,
                null, null, null, 0);
        user.setPlaintextPassword(password);
        context.setUser(user);
        /* set application name */
        context.setApplicationName(applicationName);
        /* set mbean name */
        context.setMBeanName(mbeanName);
View Full Code Here

    private static int _port = Integer.parseInt(JManageProperties.getStopPort());
    private static String _key;

    public static void main(String[] args) throws Exception{
        UserManager userManager = UserManager.getInstance();
        User user = null;
        char[] password = null;
        int invalidAttempts = 0;

        if(args.length == 1){
            password = args[0].toCharArray();
View Full Code Here

        if (System.getSecurityManager() == null) {
           System.setSecurityManager(new RMISecurityManager());
        }
   
        UserManager userManager = UserManager.getInstance();
        User user = null;
        char[] password = null;
        int invalidAttempts = 0;

        if(args.length == 1){
            password = args[0].toCharArray();
View Full Code Here

        System.out.println("Password:" + configData.getPassword());
    }

    private static ServiceContext getServiceContext(){
        ServiceContextImpl context = new ServiceContextImpl();
        User user = new User("admin", null, null, null, 0);
        context.setUser(user);
        return context;
    }
View Full Code Here

                                 ActionForm actionForm,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
            throws Exception {
        AccessController.checkAccess(context.getServiceContext(), ACL_ADD_USERS);
        User user = buildUser(actionForm);
        UserManager.getInstance().addUser(user);
        UserActivityLogger.getInstance().logActivity(
                context.getUser().getUsername(), "Added user "+user.getName());
        return mapping.findForward(Forwards.SUCCESS);
    }
View Full Code Here

        List<Role> roles = new ArrayList<Role>(1);
        String[] rolesString = userForm.getRole();
        for(int ctr=0; ctr < rolesString.length; ctr++){
          roles.add(new Role(rolesString[ctr]));
        }
        User user = new User(userForm.getUsername(), Crypto.hash(userForm.getPassword()),
                roles, userForm.getStatus(), 0);
        return user;
    }
View Full Code Here

                                 ActionForm actionForm,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
            throws Exception {
        AccessController.checkAccess(context.getServiceContext(), ACL_EDIT_USERS);
        User user = buildUser(actionForm);
        UserManager.getInstance().updateUser(user);
        UserActivityLogger.getInstance().logActivity(
                context.getUser().getUsername(),
                "Edited user "+user.getName());
        return mapping.findForward(Forwards.SUCCESS);
    }
View Full Code Here

TOP

Related Classes of org.jmanage.core.auth.User

Copyright © 2018 www.massapicom. 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.