Bit-based design strategy and permissions

2010-12-10  来源:本站原创  分类:Tech  人气:80 

May be used: convert to binary Integer.toBinaryString (int i)

First, the theoretical design of the system rights management strategy is based on bitwise processing methods to achieve competence. First, form a list of all privileges, and give an integer value of non-repetition, for example:
Operating authority number --- -
Product Management 0
Department set a
Products / Materials Information 2
Customer Information Management 3
4 Warehouse Management
... ... ... ...
Theoretically, there are N-operation. Thus, if the user A has the following permissions:
Warehouse management authority to set the value of the user A power_value = 2 ^ 4 +2 ^ 1 = 18, into the binary is 10010. Then according to the formula:
Int result = power_value & ((int) Math.pow (base, index)); (Note: Math.pow (2,4) that 2 ^ 4);
To determine whether the relevant authority, if the result = base ^ index is illustrated with the permissions. Here's an example.
If you want to verify whether the user A warehouse management authority, and can be calculated by bitwise.
int result = power_value & ((int) Math.pow (2,4));
Ie: 10010
& 10000
------
10000
The result is result = 10000 = 2 ^ 4; that user A has a warehouse management authority;
If you want to verify whether the user A product / raw material information management rights, then:
int result = power_result & ((int) Math.pow (2,2))
Ie: 10010
& 00100
------
00000
The result is result = 00000! = 2 ^ 2; that user A no products / materials information management rights.

Second, the rights of the access control database design to use at least three strategies to achieve the form of a database table:
Rights resource table (poweraction):
Name field type the name of the field is empty foreign key resource ID Id primary key resources, whether from increased url url Varchar (255) whether the resource name of the Action Varchar (255) whether any resource value Value Int

Table II

User rights table (user_power):
Name field type the name of the field is empty foreign key user ID UserId Varchar (20) whether the foreign key value Power_value Int No permission

相关文章
  • Bit-based design strategy and permissions 2010-12-10

    May be used: convert to binary Integer.toBinaryString (int i) First, the theoretical design of the system rights management strategy is based on bitwise processing methods to achieve competence. First, form a list of all privileges, and give an integ

  • Visitors to learn design patterns 1 - Duck Design (Strategy pattern) 2010-04-02

    The following is included in the figure for the code: package com.lwf.design.learn; public abstract class Duck { Flyable flyable; Quackable quackable; public void swim(){ System.out.println("duck is swim"); } public abstract void display(); publ

  • Design of three permissions 2010-04-01

    Three kinds of rights of review and compare design Authority Design yes important part of many systems, mainly used for control functions and processes of several common authority article design Jiang Fang An (permissions system's name is Zi Ji Qi's)

  • Design a simple permissions 2010-07-01

    The design of competence.

  • java design user role permissions 2010-02-04

    Website Address: http://www.cnblogs.com/a7345678/archive/2008/09/25/1298838.html

  • Strategy design pattern of the grinding mode -4 2011-07-05

    3.3 Context and Strategy of the relationship In strategy mode, usually context specific strategy used to achieve the object, in turn, strategies to achieve the object can also obtain the required context data, context can be achieved when the paramet

  • Design overview of system privileges (Reprinted) 2010-06-20

    http://www.uml.org.cn/zjjs/200807142.asp Design overview of system privileges 2008-07-14 Source: Network Introduction: Permission is often a very complex issue, but can also be expressed as such a simple logical expression: Determine "Who on the What

  • Design overview of system privileges 2010-06-22

    Design overview of system privileges 2008-07-14 Source: Network Introduction: Permission is often a very complex issue, but can also be expressed as such a simple logical expression: Determine "Who on the What (Which) to How the operation" of th

  • Distributed based learning 2011-09-20

    <p> turn: http://www.cnblogs.com/duguguiyu/archive/2009/02/22 The so-called distributed, in here, very narrowly to refer to Google's troika, GFS, Map / Reduce, BigTable as the core framework of distributed storage and computing systems. Usually begi

  • Summary of design 2009-03-23

    Abstract: This article is a summary of the design at the practice and study some of the experiences with the study notes, I hope to share with you if there is inappropriate please correct me. Keyword: Summary of design, structural, OOD Body: At the d

  • About minimize design (implementation as soon as possible) some of the ideas 2009-04-28

    When referred to as early as possible to minimize the design or implementation, the conservative counter-attack the most powerful is "no design no coding" "Designed to minimize the overall design is not" "as soon as possible the d

  • J2EE project data persistence layer design 2009-04-28

    J2EE project data persistence layer design Data Persistence Layer design goal is to provide a high level throughout the project, unity, security, and concurrent data persistence mechanism. Achieve the various data persistence programming job, and for

  • Rights Management to design a 2009-06-25

    Permission application design We are in the development of the system often encounter the need for access control systems, and varying levels of access control have different design. 1. The design of role-based permissions This program is the most co

  • Overview Summary of the design of how to do that - the design of structured methods and object-oriented design methods 2009-07-02

    Overview Summary of the design of how to do that - the design of structured methods and object-oriented design methods At 23:52 on February 12, 2008 Overview Summary of the design of how to do that - the design of structured methods and object-orient

  • Portal, seo strategy 2010-03-28

    Portal is not a small site, small sites that focus on technology was actually not the case, even the small site, it should be policy in the first place. The portal site SEO strategy is more important. Basic strategies: 1, Keyword strategy. This is on

  • The preparation of outline design specification document 2010-03-22

    The preparation of outline design specification document Reprinted from: wader Original Source: http://blog.51ww.com/wader/archive/2005/08/10/1932.51ww Make software to a certain level, and should take into account the design, design for a long time,

  • Optimal Design of Database 2010-02-24

    1 Introduction database optimization is only to avoid disk I / O bottlenecks, reducing CPU utilization and reduce resource competition. This article from the basic table design to expand the design and the angles of the database table to discuss obje

  • Optimal Design of the database (change) 2010-06-12

    This paper discusses the third paradigm based on the basic design of the database table, focusing on the creation of primary keys and indexes of strategies and programs, and then expand the table from the database design and database tables to place

  • Design of database performance tuning 2010-08-02

    This paper discusses the third paradigm based on the basic design of the database table, focusing on the creation of primary keys and indexes of strategies and programs, and then expand the table from the database design and database tables to place

  • [Jia Wen Dramas] kernel read from the java performance analysis and design 2010-08-20

    Transfer from: http://blog.csdn.net/chief1985/archive/2008/03/21/2201392.aspx Introduction java since the emergence of language from the 90's, because of its safety and cross-platform (ie the so-called "Write Once, Run Anywhere") and so on, won