Package org.apache.shiro.authc

Examples of org.apache.shiro.authc.SimpleAccount


            String[] passwordAndRolesArray = StringUtils.split(value);

            String password = passwordAndRolesArray[0];

            SimpleAccount account = getUser(username);
            if (account == null) {
                account = new SimpleAccount(username, password, getName());
                add(account);
            }
            account.setCredentials(password);

            if (passwordAndRolesArray.length > 1) {
                for (int i = 1; i < passwordAndRolesArray.length; i++) {
                    String rolename = passwordAndRolesArray[i];
                    account.addRole(rolename);

                    SimpleRole role = getRole(rolename);
                    if (role != null) {
                        account.addObjectPermissions(role.getPermissions());
                    }
                }
            } else {
                account.setRoles(null);
            }
        }
    }
View Full Code Here


            String[] passwordAndRolesArray = StringUtils.split(value);

            String password = passwordAndRolesArray[0];

            SimpleAccount account = getUser(username);
            if (account == null) {
                account = new SimpleAccount(username, password, getName());
                add(account);
            }
            account.setCredentials(password);

            if (passwordAndRolesArray.length > 1) {
                for (int i = 1; i < passwordAndRolesArray.length; i++) {
                    String rolename = passwordAndRolesArray[i];
                    account.addRole(rolename);

                    SimpleRole role = getRole(rolename);
                    if (role != null) {
                        account.addObjectPermissions(role.getPermissions());
                    }
                }
            } else {
                account.setRoles(null);
            }
        }
    }
View Full Code Here

  protected SimpleAccount getAccount(String username)
  {
    log.info("get account: " + username);

    // just create a dummy. A real app would construct one based on EIS access.
    SimpleAccount account = new SimpleAccount(username, "pass", getName());
    // simulate some roles and permissions:
    account.addRole("user");

    if ("admin".equals(username))
    {
      account.addRole("admin");
    }

    // most applications would assign permissions to Roles instead of users directly because
    // this is much more
    // flexible (it is easier to configure roles and then change role-to-user assignments than
    // it is to maintain
    // permissions for each user).
    // But these next lines assign permissions directly to this trivial account object just for
    // simulation's sake:
    account.addStringPermission("blogEntry:edit"); // this user is allowed to 'edit' _any_
    // blogEntry
    // fine-grained instance level permission:
    account.addStringPermission("printer:print:laserjet2000"); // allowed to 'print' to the
    // 'printer' identified
    // by the id 'laserjet2000'
    account.addStringPermission("view"); // all users have view permission

    return account;
  }
View Full Code Here

  protected SimpleAccount getAccount(String username)
  {
    log.info("get account: " + username);

    // just create a dummy. A real app would construct one based on EIS access.
    SimpleAccount account = new SimpleAccount(username, "pass", getName());
    // simulate some roles and permissions:
    account.addRole("user");

    if ("admin".equals(username))
    {
      account.addRole("admin");
    }

    // most applications would assign permissions to Roles instead of users directly because
    // this is much more
    // flexible (it is easier to configure roles and then change role-to-user assignments than
    // it is to maintain
    // permissions for each user).
    // But these next lines assign permissions directly to this trivial account object just for
    // simulation's sake:
    account.addStringPermission("blogEntry:edit"); // this user is allowed to 'edit' _any_
    // blogEntry
    // fine-grained instance level permission:
    account.addStringPermission("printer:print:laserjet2000"); // allowed to 'print' to the
    // 'printer' identified
    // by the id 'laserjet2000'
    account.addStringPermission("view"); // all users have view permission

    return account;
  }
View Full Code Here

TOP

Related Classes of org.apache.shiro.authc.SimpleAccount

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.