在Spring Security的官方文檔上面只給出了關(guān)于security ACL的hsql腳本,但是在使用MySQL數(shù)據(jù)庫(kù)時(shí)spring沒(méi)有明確給出數(shù)據(jù)庫(kù)創(chuàng)建腳本和配置說(shuō)明,以下是自己在使用MySQL數(shù)據(jù)庫(kù)時(shí)使用到的sql腳本和配置。
sql腳本如下
CREATE TABLE `acl_class` (
`ID` bigint(20) NOT NULL auto_increment,
`CLASS` varchar(100) NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UNIQUE_UK_2` (`CLASS`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE `acl_entry` (
`ID` bigint(20) NOT NULL auto_increment,
`ACL_OBJECT_IDENTITY` bigint(20) NOT NULL,
`ACE_ORDER` int(11) NOT NULL,
`SID` bigint(20) NOT NULL,
`MASK` int(11) NOT NULL,
`GRANTING` tinyint(1) NOT NULL,
`AUDIT_SUCCESS` tinyint(1) NOT NULL,
`AUDIT_FAILURE` tinyint(1) NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UNIQUE_UK_4` (`ACL_OBJECT_IDENTITY`,`ACE_ORDER`),
KEY `SID` (`SID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE `acl_object_identity` (
`ID` bigint(20) NOT NULL auto_increment,
`OBJECT_ID_CLASS` bigint(20) NOT NULL,
`OBJECT_ID_IDENTITY` bigint(20) NOT NULL,
`PARENT_OBJECT` bigint(20) default NULL,
`OWNER_SID` bigint(20) default NULL,
`ENTRIES_INHERITING` tinyint(1) NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UNIQUE_UK_3` (`OBJECT_ID_CLASS`,`OBJECT_ID_IDENTITY`),
KEY `OWNER_SID` (`OWNER_SID`),
KEY `PARENT_OBJECT` (`PARENT_OBJECT`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE `acl_sid` (
`ID` bigint(20) NOT NULL auto_increment,
`PRINCIPAL` tinyint(1) NOT NULL,
`SID` varchar(100) NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UNIQUE_UK_1` (`PRINCIPAL`,`SID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
spring配置片段如下
<beans:bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService">
<beans:constructor-arg ref="dataSource" />
<beans:constructor-arg ref="lookupStrategy" />
<beans:constructor-arg ref="aclCache" />
<beans:property name="classIdentityQuery" value="SELECT @@IDENTITY"/>
<beans:property name="sidIdentityQuery" value="SELECT @@IDENTITY"/>
</beans:bean> 本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|