Package net.datacrow.core.objects.helpers

Examples of net.datacrow.core.objects.helpers.User


     * Creates a new user instance.
     * @see User
     */
    @Override
    public DcObject createItem() {
        return new User();
    }
View Full Code Here


            stmt = connection.createStatement();
            rs = stmt.executeQuery(sql);
           
            List<DcObject> users = WorkFlow.getInstance().convert(rs, new int[] {User._ID, User._A_LOGINNAME, User._B_ENABLED, User._C_NAME, User._L_ADMIN});

            User user;
            if (users.size() == 1) {
                user = (User) users.get(0);
                sql = "select * from permission where user = '" + user.getID() + "'";
                rs = stmt.executeQuery(sql);

                List<DcObject> permissions = WorkFlow.getInstance().convert(rs, new int[] {Permission._ID,
                                                                                           Permission._A_PLUGIN,
                                                                                           Permission._B_FIELD,
                                                                                           Permission._C_MODULE,
                                                                                           Permission._D_VIEW,
                                                                                           Permission._E_EDIT,
                                                                                           Permission._F_USER});
                for (DcObject permission : permissions)
                    user.addChild(permission);
               
                stmt.close();
            } else {
                stmt.close();
                connection.close();
                throw new SecurityException(DcResources.getText("msgUserOrPasswordIncorrect"));
            }
           
            if (!(Boolean) user.getValue(User._B_ENABLED))
                throw new SecurityException(DcResources.getText("msgLoginNotAllowed"));
           
            SecuredUser su = new SecuredUser(user, password);
            this.users.put(user.getID(), su);
           
            // web users hold their own reference of the logged in user
            if (!web)
                this.user = (User) users.get(0);
           
View Full Code Here

     */
    private void createDefaultUser() {
        // default system administrator
        Connection connection = DatabaseManager.getConnection("dc_admin", "UK*soccer*96");
        if (connection == null) {
            User user = new User();
            user.setValue(User._A_LOGINNAME, "dc_admin");
            user.setValue(User._B_ENABLED, Boolean.TRUE);
            user.setValue(User._L_ADMIN, Boolean.TRUE);
            DatabaseManager.createUser(user, "UK*soccer*96");
        } else {
            try {
                connection.close();
            } catch (SQLException se) {
                logger.error(se, se);
            }
        }
       
        User user = new User();
        user.setIDs();
        user.setValue(User._A_LOGINNAME, "sa");
        user.setValue(User._B_ENABLED, Boolean.TRUE);
        user.setValue(User._L_ADMIN, Boolean.TRUE);
        user.setValue(User._C_NAME, "Administrator");
        user.setValue(User._D_DESCRIPTION, "The default users. Has all rights.");
       
        for (Permission permission : getDefaultPermissions())
            user.addChild(permission);
       
        try {
            user.setIDs();
            user.saveNew(false);
        } catch (Exception e) {
            logger.error(e, e);
        }
    } 
View Full Code Here

TOP

Related Classes of net.datacrow.core.objects.helpers.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.