Package ecks.services

Examples of ecks.services.SrvAuth


    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        String args[] = arguments.split(" ");
        String tU = args[0].toLowerCase();
        if (args.length == 1) {
            if (util.sanitize(tU)) {
                if (temp.getUsers().containsKey(tU)) {
                    if ((temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().ordinal() > (temp.getUsers().get(tU).getAccess().ordinal())) // we can only delete people lower than us
                    {
                        for (String e : temp.getUsers().get(tU).WhereAccess.keySet()) {
                            if (((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().get(tU) == SrvChannel_channel.ChanAccess.C_OWNER) {   // we have a problem, this person owns the channel
                                boolean promoted = false;
                                int threshold = SrvChannel_channel.ChanAccess.C_OWNER.ordinal();
                                while (!promoted) {
                                    threshold--;
                                    if (threshold < SrvChannel_channel.ChanAccess.C_PEON.ordinal()) {   // no suitable replacement found.
                                        // remove channel
                                        ((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().remove(e); // drop the channel
                                        Generic.srvPart(who, e, "Channel Unregistered (owner unregistered, no other users).");
                                        Logging.info("SRVCHAN", "Channel " + e + " unregistered by virtue of having no users left.");
                                        promoted = true;
                                        break;
                                    }
                                    for (Map.Entry<String, SrvChannel_channel.ChanAccess> z : (((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().entrySet())) {
                                        // iterate looking for replacement
                                        if (z.getValue().ordinal() >= threshold) {
                                            ((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().remove(Generic.Users.get(user).authhandle);
                                            ((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().put(Generic.Users.get(user).authhandle, SrvChannel_channel.ChanAccess.C_OWNER);
                                            promoted = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            ((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().remove(tU); // remove access from each channel
                        }

                        temp.getUsers().remove(tU); // drop the account
                        Generic.curProtocol.outMODE(who, Generic.Users.get(tU), "-r", "");
                        // Generic.Users.get(tU).authhandle = null; // user is no longer authed
                        Generic.curProtocol.outPRVMSG(who, replyto, "User account removed.");
                    } else
                        Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 User has equal/higher access than you!");
View Full Code Here


    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        String args[] = arguments.split(" ");
        if (args.length == 3) {
            if (Generic.Users.get(user).authhandle == null) {
                String u = args[0].toLowerCase();
                if (util.sanitize(u)) {
                    if (!temp.getUsers().containsKey(u)) {
                        String pw = args[1];
                        if (util.sanitize(pw)) {
                            pw = util.hash(pw);
                            String e = args[2];
                            if (util.checkemail(e)) {
                                if (!(temp.getUsers().size() == 0)) {
                                    temp.getUsers().put(u, new SrvAuth_user(u, pw, e, CommandDesc.access_levels.A_PENDING));
                                    Generic.Users.get(user).authhandle = u.trim().toLowerCase(); // user is now authed
                                    Generic.curProtocol.srvSetAuthed(who, user, ((long) -1)); // new users don't have svsids
                                    String tCookie = util.makeCookie();
                                    temp.getUsers().get(u).setMeta("cookie", tCookie);
                                    temp.getUsers().get(u).setMeta("_ts_registered", util.getTS());
                                    temp.getUsers().get(u).setMeta("_ts_last", util.getTS());
                                    util.SendRegMail(e, tCookie);
                                    Generic.curProtocol.outPRVMSG(who, replyto, "\u0002" + Generic.Users.get(user).uid + ":\u0002 Registration Succeeded!");
                                } else { // first registration is an SRA
                                    temp.getUsers().put(u, new SrvAuth_user(u, pw, e, CommandDesc.access_levels.A_SRA));
                                    Generic.Users.get(user).authhandle = u.trim().toLowerCase(); // user is now authed
                                    temp.getUsers().get(u).setMeta("_ts_registered", util.getTS());
                                    temp.getUsers().get(u).setMeta("_ts_last", util.getTS());
                                    Generic.curProtocol.outPRVMSG(who, replyto, "\u0002" + Generic.Users.get(user).uid + ":\u0002 Registration Succeeded! You are now an SRA!");
                                }
                            } else
                                Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 Invalid Email Address");
                        } else
View Full Code Here

    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        String args[] = arguments.split(" ");
        String tU = args[0].toLowerCase();
        CommandDesc.access_levels tA;
        try {
            tA = CommandDesc.access_levels.valueOf(args[1]);
        } catch (IllegalArgumentException e) {
            Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 Invalid Access Level");
            return;
        }
        if (args.length == 2) {
            if (util.sanitize(tU)) {
                if (temp.getUsers().containsKey(tU)) {
                    if ((temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().ordinal() > (temp.getUsers().get(tU).getAccess().ordinal() + 1)) { // we can only promote who are below us by two
                        if ((temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().ordinal() > (tA.ordinal())) {
                            temp.getUsers().get(tU).update(tA); // update the account
                            Generic.curProtocol.outPRVMSG(who, replyto, "User account promoted to " + tA + ".");
                        } else
                        if ((temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().equals(CommandDesc.access_levels.A_SRA)) { // if we're an SRA, we can do whatever we damn well please.
                            temp.getUsers().get(tU).update(tA); // update the account
                            Generic.curProtocol.outPRVMSG(who, replyto, "User account promoted to " + tA + ".");
                            Logging.info("SRVAUTH", "Account " + tU + " promoted by " + user + " to " + tA + ".");
                        } else
                            Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 Cannot promote users to your access level.");
                    } else
View Full Code Here

    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        String uTemp = Generic.Users.get(user).authhandle;
        String args[] = arguments.split(" ");

        if (args.length != 2) {
            Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Usage:\u0002 changepass <old> <new>");
            return;
        }

        if (temp.checkAccess(uTemp).ordinal() >= CommandDesc.access_levels.A_HELPER.ordinal())  // we're a helper
        {
            // changepass username newpassword
            if (temp.getUsers().containsKey(args[0])) {
                temp.getUsers().get(args[0]).cngpass(args[1]);
                Generic.curProtocol.outPRVMSG(who, replyto, "Password Changed!");
                Logging.warn("SRVAUTH", user + " changed password for username: " + args[0]);
            } else Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 No such username exists!");
        } else { // we're not a helper. vette old password
            // changepass oldpass newpass
            if (temp.chkpass(args[0], user)) {
                temp.getUsers().get(uTemp).cngpass(args[1]);
                Generic.curProtocol.outPRVMSG(who, replyto, "Password Changed!");
            } else Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 Old password incorrect!");
        }
    }
View Full Code Here

        Logging.info("RPC", "Got checkUserAuth Request!");
        Logging.verbose("RPC", "Request was for user: " + username);
        if (!Configuration.getSvc().containsKey(Configuration.authservice))
            return 0;

        SrvAuth auth = (SrvAuth)Configuration.getSvc().get(Configuration.authservice);

        if (auth.getUsers().containsKey(username.toLowerCase()) && auth.chkpass(password, username.toLowerCase()))
            return 1;

        return 0;
    }
View Full Code Here

        Logging.info("RPC", "Got getUserAccess Request!");
        Logging.verbose("RPC", "Request was for user: " + username);
        if (!Configuration.getSvc().containsKey(Configuration.authservice))
            return 0;
       
        SrvAuth auth = (SrvAuth)Configuration.getSvc().get(Configuration.authservice);

        if (!auth.getUsers().containsKey(username.toLowerCase()))
            return 0;

        SrvAuth_user u = auth.getUsers().get(username.toLowerCase());
        return u.getAccess().ordinal();
    }
View Full Code Here

    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        String uTemp = Generic.Users.get(user).authhandle;
        if (arguments.length() > 1) {
            if (uTemp != null) {
                if (((temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess() == Desc.Required_Access) || (temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().ordinal() >= CommandDesc.access_levels.A_HELPER.ordinal()) {
                    if (temp.getUsers().containsKey(uTemp)) {
                        if (util.sanitize(arguments)) {
                            if (temp.getUsers().get(uTemp).getAllMeta().containsKey("cookie") || (temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().ordinal() >= CommandDesc.access_levels.A_HELPER.ordinal()) {
                                if (temp.getUsers().get(uTemp).getMeta("cookie").equals(arguments)) {
                                    temp.getUsers().get(uTemp).update(CommandDesc.access_levels.A_AUTHED);
                                    temp.getUsers().get(uTemp).rmMeta("cookie");
                                    Generic.curProtocol.outPRVMSG(who, replyto, "\u0002" + Generic.Users.get(user).uid + ":\u0002 Your account has been confirmed!");
                                } else
                                if (temp.getUsers().get(uTemp).getAccess().ordinal() >= CommandDesc.access_levels.A_HELPER.ordinal()) {
                                    // is a helper and is confirming account for user
                                    if (temp.getUsers().containsKey(arguments.toLowerCase())) {
                                        temp.getUsers().get(arguments.toLowerCase()).update(CommandDesc.access_levels.A_AUTHED);
                                        temp.getUsers().get(arguments.toLowerCase()).rmMeta("cookie");
                                        Generic.curProtocol.outPRVMSG(who, arguments.toLowerCase(), "\u0002" + Generic.Users.get(arguments.toLowerCase()).uid + ":\u0002 The account has been confirmed!");
                                        Logging.warn("SRVAUTH", "Username " + arguments + " had email confirmed by " + user + ".");
                                    } else
                                        Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 That user doesn't exist!");
                                } else
View Full Code Here

    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        String[] args = arguments.split(" ");

        Logging.verbose("SRVREAUTH", "Attempting reauth!");
        if (!replyto.equals("service")) {
            Generic.curProtocol.outPRVMSG(who, user, "\u0002Error:\u0002 This command is for internal use by services only!");
View Full Code Here

    public CommandDesc getDesc() {
        return Desc;
    }

    public void handle_command(Service who, String user, String replyto, String arguments) {
        SrvAuth temp = ((SrvAuth) who);
        if (arguments.split(" ").length == 2) {
            if (Generic.Users.get(user).authhandle == null) {
                String uname = arguments.split(" ")[0].toLowerCase();
                if (temp.getUsers().containsKey(uname)) { // if the username exists
                    if (temp.chkpass(arguments.split(" ")[1], uname)) { // password matches
                        Generic.Users.get(user).authhandle = uname;
                        ((SrvAuth) who).getUsers().get(uname).setMeta("_ts_last", util.getTS()); // update last seen metadata
                        try {
                            Generic.curProtocol.srvSetAuthed(who, Generic.Users.get(user).uid, Long.parseLong(temp.getUsers().get(uname).getMeta("svsid")));
                        } catch (NoSuchElementException nsee) {
                            temp.getUsers().get(uname).setMeta("svsid", "-1");
                            Generic.curProtocol.srvSetAuthed(who, Generic.Users.get(user).uid, (long) -1);
                        }
                        Generic.curProtocol.outNOTICE(who, replyto, "\u0002" + Generic.Users.get(user).uid + ":\u0002 Welcome back!");
                        if (Configuration.getSvc().containsKey(Configuration.chanservice))
                            Configuration.getSvc().get(Configuration.chanservice).handle(user, user, "syncall"); // up them in all of their channels
View Full Code Here

TOP

Related Classes of ecks.services.SrvAuth

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.