acegi 拾遗

acegi 拾遗
   protected ConfigAttributeDefinition lookupAttributes(MethodInvocation mi) {
      //construct secureObjectName
      String secureObjectName=mi.getMethod().getDeclaringClass().getName() +"."+ mi.getMethod().getName();
      SecureObject secureObject=securityManager.getSecureObject(secureObjectName);
      if(secureObject==null)//if secure object not exist in database
         return null;
      //retrieving roles associated with this secure object
      List secureObjectRoles=(List)securityManager.getSecureObjectRoles(secureObject);
      //creating ConfigAttributeDefinition
      if(!secureObjectRoles.isEmpty()){
         ConfigAttributeEditor configAttrEditor=new ConfigAttributeEditor();
         StringBuffer rolesStr=new StringBuffer();
         for(int i=0;i<secureObjectRoles.size();i++){
            SecureObjectRole sor=(SecureObjectRole)secureObjectRoles.get(i);
            rolesStr.append(sor.getRole().getRoleName()).append(",");
         }
         configAttrEditor.setAsText( rolesStr.toString().substring(0,rolesStr.length()-1) );
         ConfigAttributeDefinition configAttrDef=(ConfigAttributeDefinition)configAttrEditor.getValue();
         return configAttrDef;
      }
      return null;
      
   }

你可能感兴趣的:(acegi 拾遗)