Package org.jrest4guice.security

Examples of org.jrest4guice.security.UserRole


     
      //获取模板
      Template template = this.engine.getTemplate(url);
      //往上下文中填入数据
      this.context.put("ctxPath", this.request.getContextPath());
      UserRole userPrincipal = this.securityContext.getUserPrincipal();
      this.context.put(SecurityContext.CURRENT_USER_ROlE, userPrincipal);
      this.context.put(SecurityContext.USER_IS_LOGIN, userPrincipal!=null);
      this.context.put("ctx", result);
      this.context.put("xctx",session.getAttribute(HtmlResponseWriter.OPTION_KEY));
     
View Full Code Here


      List innerElements) throws Exception {
    if (param != null){
     
      Object useRoleObj = context.getVariable(SecurityContext.CURRENT_USER_ROlE);
      if(useRoleObj != null){
        UserRole ur = (UserRole)useRoleObj;
        String roles[] = {param.toString()};
        if(param instanceof List){
          roles = (String[])((List)param).toArray(new String[]{});
        }
       
        boolean hasRole = false;
        List<Role> uRoles = ur.getRoles();
        top: for (String role : roles) {
          for (Role r : uRoles) {
            if (role.equalsIgnoreCase(r.getName())) {
              hasRole = true;
              break top;
View Full Code Here

  @Get
  @Path("auth")
  public boolean authUser(String userName, String userPassword) {
    boolean result = this.domain.authUser(userName, userPassword);
    if (result) {
      UserRole userRole = new UserRole();
      User user = new User();
      List<Role> roles = this.listUserRoles(userName);
      userRole.setUser(user);
      userRole.setRoles(roles);
     
      //缓存当前用户的权限信息
      this.securityContext.storeUserPrincipal(userName, userRole);
    }
    return result;
View Full Code Here

  private SecurityContext securityContext;
 
  @Get
  public List<Role> listUserPrincipal(){
    System.out.println("==listUserPrincipal==");
    final UserRole userPrincipal = this.securityContext.getUserPrincipal();
    if(userPrincipal != null){
      for(Role role:userPrincipal.getRoles()){
        System.out.println(role.getName());
      }
     
      return userPrincipal.getRoles();
    }
   
    return null;
  }
View Full Code Here

TOP

Related Classes of org.jrest4guice.security.UserRole

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.