initial it
parent
da9210aa5a
commit
db7a8d0ec2
|
@ -0,0 +1,3 @@
|
|||
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
|
||||
#Thu Nov 07 15:05:54 CST 2013
|
||||
logback-ext-parent-0.1.2-SNAPSHOT.pom>=
|
|
@ -0,0 +1,414 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2012 Ceki Gulcu, Les Hazlewood, et. al.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>7</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
|
||||
<name>Logback Extensions</name>
|
||||
<url>https://github.com/qos-ch/logback-extensions/wiki</url>
|
||||
<description>
|
||||
Logback Extensions provides community-driven and supported extensions to the Logback logging framework.
|
||||
</description>
|
||||
<inceptionYear>2012</inceptionYear>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/qos-ch/logback-extensions.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:qos-ch/logback-extensions.git</developerConnection>
|
||||
<url>https://github.com/qos-ch/logback-extensions</url>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/qos-ch/logback-extensions/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>lhazlewood</id>
|
||||
<name>Les Hazlewood</name>
|
||||
<email>les@hazlewood.com</email>
|
||||
<url>http://www.leshazlewood.com</url>
|
||||
<timezone>-8</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>belaso</id>
|
||||
<name>Christian Trutz</name>
|
||||
<email>christian.trutz@belaso.de</email>
|
||||
<url>http://www.belaso.de</url>
|
||||
<timezone>+2</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>tony19</id>
|
||||
<name>Tony Trinh</name>
|
||||
<email>tony19@gmail.com</email>
|
||||
<url>http://tony19.github.com</url>
|
||||
<timezone>-5</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<modules>
|
||||
<!--<module>loggly</module>-->
|
||||
<module>spring</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<!-- Compile Dependencies: -->
|
||||
<logback.version>1.0.9</logback.version>
|
||||
<jackson.version>1.9.5</jackson.version>
|
||||
<spring.version>3.1.1.RELEASE</spring.version>
|
||||
<mongo-java-driver.version>2.7.3</mongo-java-driver.version>
|
||||
|
||||
<!-- Test Dependencies: -->
|
||||
<easymock.version>3.1</easymock.version>
|
||||
<groovy.version>1.8.6</groovy.version>
|
||||
<jmockit.version>0.999.15</jmockit.version>
|
||||
<junit.version>4.8.2</junit.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Test Dependencies for _all_ children modules: -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>${groovy.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>${easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- Pool of dependencies available to any sub-module, but not included automatically.
|
||||
They must be explicitly referenced in the children POMs, but _don't_ include
|
||||
version numbers in the child POMs. Define them here only to guarantee version
|
||||
compatibility across children modules! -->
|
||||
|
||||
<!-- Logback Extensions sub-modules dependency .jars (alphabetized based on artifactId for easy scanning please!): -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-access</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback.extensions</groupId>
|
||||
<artifactId>logback-ext-jackson</artifactId>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback.extensions</groupId>
|
||||
<artifactId>logback-ext-json-classic</artifactId>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback.extensions</groupId>
|
||||
<artifactId>logback-ext-json-core</artifactId>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 3rd party dependencies: -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>${mongo-java-driver.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- For unit tests: -->
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>gmaven-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<configuration>
|
||||
<providerSelection>1.7</providerSelection>
|
||||
<source>src/main/groovy</source>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.gmaven.runtime</groupId>
|
||||
<artifactId>gmaven-runtime-1.7</artifactId>
|
||||
<version>1.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>${groovy.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>gmaven-plugin</artifactId>
|
||||
<versionRange>[1.0.0,)</versionRange>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<!-- Allow tests to be written in Groovy: -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>gmaven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!--<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin> -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<configuration>
|
||||
<preparationGoals>clean install</preparationGoals>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<!-- <goals>deploy site-deploy</goals> -->
|
||||
<goals>deploy</goals>
|
||||
<arguments>-Prelease</arguments>
|
||||
<mavenExecutorId>forked-path</mavenExecutorId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-api-docs</id>
|
||||
<goals>
|
||||
<!--suppress MavenModelInspection -->
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<inherited>true</inherited>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<inherited>true</inherited>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>release-sign-artifacts</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>performRelease</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-parent</artifactId>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
</metadata>
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata modelVersion="1.1.0">
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-parent</artifactId>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<localCopy>true</localCopy>
|
||||
</snapshot>
|
||||
<lastUpdated>20131107070554</lastUpdated>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>0.1.2-SNAPSHOT</value>
|
||||
<updated>20131107070554</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-parent</artifactId>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
</versions>
|
||||
<lastUpdated>20131107070554</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,4 @@
|
|||
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
|
||||
#Thu Nov 07 12:01:52 CST 2013
|
||||
logback-ext-spring-0.1.2-SNAPSHOT.jar>=
|
||||
logback-ext-spring-0.1.2-SNAPSHOT.pom>=
|
|
@ -0,0 +1,51 @@
|
|||
<!--
|
||||
~ Copyright 2012 Ceki Gulcu, Les Hazlewood, et. al.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-parent</artifactId>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>logback-ext-spring</artifactId>
|
||||
<name>Logback Extensions :: Spring</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata modelVersion="1.1.0">
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-spring</artifactId>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<localCopy>true</localCopy>
|
||||
</snapshot>
|
||||
<lastUpdated>20131107040152</lastUpdated>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>jar</extension>
|
||||
<value>0.1.2-SNAPSHOT</value>
|
||||
<updated>20131107040152</updated>
|
||||
</snapshotVersion>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>0.1.2-SNAPSHOT</value>
|
||||
<updated>20131107040152</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-spring</artifactId>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
</versions>
|
||||
<lastUpdated>20131107040152</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,20 @@
|
|||
-- Initial database pre data
|
||||
-- admin, password is honyee2013
|
||||
insert into user_(id,guid,create_time,email,password,phone,username,default_user)
|
||||
values
|
||||
(21,'29f6004fb1b0466f9572b02bf2ac1be8',now(),'admin@honyee.cc','69f71fbb5b41bd481d5d3b28a02a0b7e','028-65536867','admin',true);
|
||||
|
||||
|
||||
-- initial oauth client details test data
|
||||
truncate oauth_client_details;
|
||||
insert into oauth_client_details
|
||||
(client_id, resource_ids, client_secret, scope, authorized_grant_types,
|
||||
web_server_redirect_uri,authorities, access_token_validity,
|
||||
refresh_token_validity, additional_information, create_time, archived, trusted)
|
||||
values
|
||||
('unity-client','unity-resource', 'unity', 'read,write','password,authorization_code,refresh_token,implicit',
|
||||
null,'ROLE_UNITY',null,
|
||||
null,null, now(), 0, 0),
|
||||
('mobile-client','mobile-resource', 'mobile', 'read,write','password,authorization_code,refresh_token,implicit',
|
||||
null,'ROLE_MOBILE',null,
|
||||
null,null, now(), 0, 0);
|
|
@ -0,0 +1,29 @@
|
|||
-- ###############
|
||||
-- create database , if need create, cancel the comment
|
||||
-- ###############
|
||||
-- create database if not exists jiuzhai default character set utf8;
|
||||
-- use jiuzhai set default character = utf8;
|
||||
|
||||
-- ###############
|
||||
-- grant privileges to jiuzhai/jiuzhai
|
||||
-- ###############
|
||||
-- GRANT ALL PRIVILEGES ON jiuzhai.* TO jiuzhai@localhost IDENTIFIED BY "jiuzhai";
|
||||
|
||||
-- ###############
|
||||
-- Domain: User
|
||||
-- ###############
|
||||
Drop table if exists user_;
|
||||
CREATE TABLE `user_` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`guid` varchar(255) not null unique,
|
||||
`create_time` datetime ,
|
||||
`archived` tinyint(1) default '0',
|
||||
`email` varchar(255),
|
||||
`password` varchar(255) not null,
|
||||
`phone` varchar(255),
|
||||
`username` varchar(255) not null unique,
|
||||
`default_user` tinyint(1) default '0',
|
||||
`last_login_time` datetime ,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
--
|
||||
-- Oauth sql -- MYSQL
|
||||
--
|
||||
|
||||
Drop table if exists oauth_client_details;
|
||||
create table oauth_client_details (
|
||||
client_id VARCHAR(256) PRIMARY KEY,
|
||||
resource_ids VARCHAR(256),
|
||||
client_secret VARCHAR(256),
|
||||
scope VARCHAR(256),
|
||||
authorized_grant_types VARCHAR(256),
|
||||
web_server_redirect_uri VARCHAR(256),
|
||||
authorities VARCHAR(256),
|
||||
access_token_validity INTEGER,
|
||||
refresh_token_validity INTEGER,
|
||||
additional_information VARCHAR(4096),
|
||||
create_time datetime,
|
||||
archived tinyint(1) default '0',
|
||||
trusted tinyint(1) default '0'
|
||||
);
|
||||
|
||||
Drop table if exists oauth_client_token;
|
||||
create table oauth_client_token (
|
||||
token_id VARCHAR(256),
|
||||
token BLOB,
|
||||
authentication_id VARCHAR(256),
|
||||
user_name VARCHAR(256),
|
||||
client_id VARCHAR(256)
|
||||
);
|
||||
|
||||
Drop table if exists oauth_access_token;
|
||||
create table oauth_access_token (
|
||||
token_id VARCHAR(256),
|
||||
token BLOB,
|
||||
authentication_id VARCHAR(256),
|
||||
user_name VARCHAR(256),
|
||||
client_id VARCHAR(256),
|
||||
authentication BLOB,
|
||||
refresh_token VARCHAR(256)
|
||||
);
|
||||
|
||||
Drop table if exists oauth_refresh_token;
|
||||
create table oauth_refresh_token (
|
||||
token_id VARCHAR(256),
|
||||
token BLOB,
|
||||
authentication BLOB
|
||||
);
|
||||
|
||||
Drop table if exists oauth_code;
|
||||
create table oauth_code (
|
||||
code VARCHAR(256), authentication BLOB
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
-------------------IN 'TEMPLATES'-------------
|
||||
Class:
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package ${PACKAGE_NAME};
|
||||
|
||||
#parse("File Header.java")
|
||||
public class ${NAME} {
|
||||
}
|
||||
|
||||
|
||||
|
||||
Interface:
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package ${PACKAGE_NAME};
|
||||
|
||||
#parse("File Header.java")
|
||||
|
||||
public interface ${NAME} {
|
||||
}
|
||||
|
||||
|
||||
Enum:
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package ${PACKAGE_NAME};
|
||||
|
||||
#parse("File Header.java")
|
||||
|
||||
public enum ${NAME} {
|
||||
}
|
||||
|
||||
|
||||
AnnotationType:
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package ${PACKAGE_NAME};
|
||||
|
||||
#parse("File Header.java")
|
||||
|
||||
public @interface ${NAME} {
|
||||
}
|
||||
|
||||
------------------IN 'CODE'-------------
|
||||
Implemented, New & Overridden method body:
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
|
||||
Catch Statement Body
|
||||
${EXCEPTION}.printStackTrace();
|
||||
|
||||
|
||||
|
||||
-----------------IN 'INCLUDES'--------------------
|
||||
ActionScript File Header , File Header: please replace the author.
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
|
||||
-----------------IN 'Java EE'--------------------
|
||||
Web -> Jsp files -> Jsp File.jsp
|
||||
Change the comment content as follow, change the author to self name.
|
||||
|
||||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
方式1:基于浏览器
|
||||
http://localhost:8080/oauth/authorize?client_id=unity-client&redirect_uri=http%3a%2f%2flocalhost%3a8080%2funity%2fdashboard.htm&response_type=code&scope=read
|
||||
|
||||
方式2:基于客户端
|
||||
http://localhost:8080/oauth/token?client_id=unity-client&client_secret=unity&grant_type=password&scope=read,write&username=admin&password=honyee2013
|
||||
|
||||
|
||||
|
||||
{"access_token":"3420d0e0-ed77-45e1-8370-2b55af0a62e8","token_type":"bearer","refresh_token":"b36f4978-a172-4aa8-af89-60f58abe3ba1","expires_in":43199,"scope":"read write"}
|
|
@ -0,0 +1,99 @@
|
|||
|
||||
|
||||
|
||||
以下是我们项目的一些规范,请大家自觉遵守。
|
||||
|
||||
|
||||
>> 1.开发使用软件及版本信息
|
||||
|
||||
* JDK 1.7.0_40
|
||||
* Maven 3.1.0
|
||||
* IDEA 11.1.3
|
||||
* Tomcat 6.0.33
|
||||
* MySQL 5.5
|
||||
* TortoiseSVN 1.7.7
|
||||
* Git 1.7.10
|
||||
|
||||
|
||||
(更多开发软件及版本号在第一次使用到时再指定)
|
||||
[务必使用相同的软件版本]
|
||||
|
||||
|
||||
|
||||
|
||||
>> 2.常用配置与要求
|
||||
|
||||
电脑配置
|
||||
* 中英文切换快捷键〈Ctrl+Shift+Home〉
|
||||
* IDEA所有快捷键不能任意更换
|
||||
|
||||
数据库开发
|
||||
*表(table)与字段(column)全小写,以下画线分隔,如user; user_detail; color_def
|
||||
*所有SQL脚本必须手写,不能使用工具导出生成
|
||||
*任何字段,除了明确要求外,不要添加任何约束。如非空约束,长度限制
|
||||
*开发数据库名:ipo;测试数据库名:ipo_test
|
||||
|
||||
Hibernate配置
|
||||
*映射文件禁止使用many-to-many,用one-to-many 替换
|
||||
*映射文件统一放置在infrastructure模块的persistence.hibernate.mapping目录
|
||||
*按Domain的属性进行映射,即在映射文件中使用<hibernate-mapping default-access="field">
|
||||
|
||||
|
||||
IDEA配置
|
||||
*代码自动缩进(快捷键Ctrl+Alt+L)
|
||||
*具体参见intellij_templates.txt
|
||||
|
||||
SVN使用要求
|
||||
*每次提交前先更新
|
||||
*提交代码时必须写注释(Comment),内容是关于提交或更改的功能的描述
|
||||
*代码必须确保在本地编译通过;尽量在完成一个功能,测试通过,并在review后提交
|
||||
|
||||
|
||||
>> 3.项目配置与要求
|
||||
|
||||
*浏览器支持:IE7-9 与 Safari
|
||||
*DTO不能传入到Domain中
|
||||
*所有Service方法的参数与返回值必须是基础数据类型与DTO,不能是Domain
|
||||
*service层不做任何业务处理
|
||||
*方法或构造器的参数尽量控制到4过以下
|
||||
|
||||
*方法名与属性名必须有意义,不能乱命名方法名。JSP文件与包(package)命名要求全小写,如:companyform.jsp;com.achievo.ipo ;
|
||||
类名,方法名,属性名遵守驼峰命名规则,如:CompanyController
|
||||
*对于业务方法,Domain方法与数据库操作必须写单元测试(使用TestNG)
|
||||
*Service类配置在application.xml文件中;Repository类配置在infrastructure.xml文件中;Controller配置在ipo-servlet.xml文件中
|
||||
*项目事务添加到service中(com.achievo.ipo.service包及其子包);Service方法中以load开头的方法只有只读事务,其他方法支持写事务
|
||||
*URL设置要求
|
||||
1).所有URL设置按模块划分目录,如Company模块的顶层目录为/company。所有Company的URL都在该目录下,如Company添加URL为:/company/add;
|
||||
编辑Company的URL为:/company/edit;删除的URL为:/company/delete;Overview的URL为:/company/overview 。
|
||||
其他的URL按其功能命名,如导出为:/company/export。 若有参数的URL如:/company/edit?guid=1223-soed-d等。
|
||||
2). 配置URL时分模块且结构清晰.
|
||||
3). 页面上的URL使用相对路径或完整路径(包括contextPath)
|
||||
4). URL的配置尽量简单清晰,一看就明白其功能
|
||||
|
||||
*对于获取Spring容器中的实例时,可使用BeanProvider.getBean(Class clazz)获取。在Domain中获取Repository的方法如下:
|
||||
|
||||
private transient BacklogRepository backlogRepository = BeanProvider.getBean(BacklogRepository.class);
|
||||
|
||||
使用时如下:
|
||||
public void saveOrUpdate() {
|
||||
getRepository().saveOrUpdate(this);
|
||||
}
|
||||
|
||||
*前台使用JQUERY及相关插件
|
||||
*
|
||||
*任何新建的Repository必须继承Repository接口;Hibernate实现类必须继承AbstractRepository抽象类(该基类)。一个示例如下:
|
||||
|
||||
public interface DoctorQualificationRepository extends Repository {
|
||||
//codes
|
||||
}
|
||||
|
||||
public class DoctorQualificationRepositoryHibernate extends AbstractRepository implements DoctorQualificationRepository {
|
||||
//codes
|
||||
}
|
||||
|
||||
|
||||
|
||||
4.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,443 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>honyee.cc</groupId>
|
||||
<artifactId>spring-oauth-server</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>spring-oauth-server</name>
|
||||
<packaging>war</packaging>
|
||||
<description>Spring Oauth Server</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>3.1.1.RELEASE</spring.version>
|
||||
<spring.security.version>3.1.0.RELEASE</spring.security.version>
|
||||
<aspectj.version>1.6.10</aspectj.version>
|
||||
<mybatis.version>3.2.1</mybatis.version>
|
||||
|
||||
<!--jdbc execute sql config-->
|
||||
<jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
|
||||
<jdbc.url>jdbc:mysql://ec2-23-21-211-172.compute-1.amazonaws.com:3306/jiuzhai_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8</jdbc.url>
|
||||
<jdbc.user>honyee</jdbc.user>
|
||||
<jdbc.pass>honyee</jdbc.pass>
|
||||
<!--if do not use execute sql, change the value to true-->
|
||||
<jdbc.execute.skip>false</jdbc.execute.skip>
|
||||
<test.skip>false</test.skip>
|
||||
</properties>
|
||||
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>https://honyee.ci.cloudbees.com/</url>
|
||||
</ciManagement>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>shengzhao</name>
|
||||
<email>shengzhao@honyee.cc</email>
|
||||
</developer>
|
||||
<!--more developer-->
|
||||
</developers>
|
||||
|
||||
|
||||
<build>
|
||||
<finalName>spring-oauth-server</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<encoding>utf-8</encoding>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Implementation-BuildNumber>
|
||||
${project.version}
|
||||
</Implementation-BuildNumber>
|
||||
<Specification-Vendor>
|
||||
honyee.cc
|
||||
</Specification-Vendor>
|
||||
<Implementation-Vendor>
|
||||
honyee.cc
|
||||
</Implementation-Vendor>
|
||||
<Implementation-Title>
|
||||
${project.name}
|
||||
</Implementation-Title>
|
||||
<Implementation-Version>
|
||||
${project.version}
|
||||
</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.codehaus.mojo</groupId>-->
|
||||
<!--<artifactId>sql-maven-plugin</artifactId>-->
|
||||
<!--<version>1.4</version>-->
|
||||
<!--<dependencies>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>mysql</groupId>-->
|
||||
<!--<artifactId>mysql-connector-java</artifactId>-->
|
||||
<!--<version>5.1.6</version>-->
|
||||
<!--</dependency>-->
|
||||
<!--</dependencies>-->
|
||||
|
||||
<!--<configuration>-->
|
||||
<!--<driver>${jdbc.driver}</driver>-->
|
||||
<!--<url>${jdbc.url}</url>-->
|
||||
<!--<username>${jdbc.user}</username>-->
|
||||
<!--<password>${jdbc.pass}</password>-->
|
||||
<!--<skip>${jdbc.execute.skip}</skip>-->
|
||||
<!--</configuration>-->
|
||||
|
||||
<!--<executions>-->
|
||||
<!--<execution>-->
|
||||
<!--<id>init db</id>-->
|
||||
<!--<phase>initialize</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>execute</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<url>${jdbc.url}</url>-->
|
||||
<!--<autocommit>true</autocommit>-->
|
||||
<!--<srcFiles>-->
|
||||
<!--<srcFile>others/database/initial_db.ddl</srcFile>-->
|
||||
<!--<!–<srcFile>others/database/ddl/init-data.sql</srcFile>–>-->
|
||||
<!--</srcFiles>-->
|
||||
<!--<onError>continue</onError>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
<!--</executions>-->
|
||||
<!--</plugin>-->
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<skip>${test.skip}</skip>
|
||||
<forkMode>none</forkMode>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jdbc.url</name>
|
||||
<value>${jdbc.url}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jdbc.username</name>
|
||||
<value>${jdbc.user}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jdbc.password</name>
|
||||
<value>${jdbc.pass}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<!--exclude file list-->
|
||||
<exclude>database.properties</exclude>
|
||||
<exclude>mail.properties</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- provided dependency -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<version>2.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--public compile dependencies-->
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache-web</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>opensymphony</groupId>
|
||||
<artifactId>sitemesh</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-dbcp</groupId>
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<!--spring-->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-expression</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<!--spring security-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<version>${spring.security.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
<version>${spring.security.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-taglibs</artifactId>
|
||||
<version>${spring.security.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-acl</artifactId>
|
||||
<version>${spring.security.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
<version>${spring.security.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<version>${spring.security.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security.oauth</groupId>
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
<version>1.0.5.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>cglib</groupId>-->
|
||||
<!--<artifactId>cglib</artifactId>-->
|
||||
<!--<version>2.2.2</version>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr-runtime</artifactId>
|
||||
<version>3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>stringtemplate</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.logback-extensions</groupId>
|
||||
<artifactId>logback-ext-spring</artifactId>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--mybatis-->
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>${mybatis.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>taglibs</groupId>
|
||||
<artifactId>standard</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>displaytag</groupId>
|
||||
<artifactId>displaytag</artifactId>
|
||||
<version>1.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl104-over-slf4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--public test dependencies-->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>3.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>6.1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>basedir</id>
|
||||
<url>file://${project.basedir}/lib/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain;
|
||||
|
||||
import cc.honyee.infrastructure.DateUtils;
|
||||
import cc.honyee.domain.shared.GuidGenerator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class AbstractDomain implements Serializable {
|
||||
|
||||
/**
|
||||
* Database id
|
||||
*/
|
||||
protected int id;
|
||||
|
||||
protected boolean archived;
|
||||
/**
|
||||
* Domain business guid.
|
||||
*/
|
||||
protected String guid = GuidGenerator.generate();
|
||||
|
||||
/**
|
||||
* The domain create time.
|
||||
*/
|
||||
protected Date createTime = DateUtils.now();
|
||||
|
||||
public AbstractDomain() {
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void id(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean archived() {
|
||||
return archived;
|
||||
}
|
||||
|
||||
public AbstractDomain archived(boolean archived) {
|
||||
this.archived = archived;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String guid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void guid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public Date createTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public boolean isNewly() {
|
||||
return id == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof AbstractDomain)) {
|
||||
return false;
|
||||
}
|
||||
AbstractDomain that = (AbstractDomain) o;
|
||||
return guid.equals(that.guid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return guid.hashCode();
|
||||
}
|
||||
|
||||
//For subclass override it
|
||||
public void saveOrUpdate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("{id=").append(id);
|
||||
sb.append(", archived=").append(archived);
|
||||
sb.append(", guid='").append(guid).append('\'');
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.dto;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class AbstractDto implements Serializable {
|
||||
|
||||
protected String guid;
|
||||
|
||||
protected AbstractDto() {
|
||||
}
|
||||
|
||||
protected AbstractDto(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public boolean isNewly() {
|
||||
return StringUtils.isEmpty(guid);
|
||||
}
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.dto.user;
|
||||
|
||||
import cc.honyee.domain.dto.AbstractDto;
|
||||
import cc.honyee.domain.user.User;
|
||||
import cc.honyee.infrastructure.DateUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class UserDto extends AbstractDto {
|
||||
|
||||
protected String username;
|
||||
protected String createDate;
|
||||
|
||||
protected String phone;
|
||||
protected String email;
|
||||
protected boolean defaultUser;
|
||||
|
||||
|
||||
public UserDto() {
|
||||
}
|
||||
|
||||
public UserDto(User user) {
|
||||
super(user.guid());
|
||||
this.username = user.username();
|
||||
this.createDate = DateUtils.toDateText(user.createTime());
|
||||
|
||||
this.phone = user.phone();
|
||||
this.email = user.email();
|
||||
this.defaultUser = user.defaultUser();
|
||||
}
|
||||
|
||||
public boolean isDefaultUser() {
|
||||
return defaultUser;
|
||||
}
|
||||
|
||||
public void setDefaultUser(boolean defaultUser) {
|
||||
this.defaultUser = defaultUser;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(String createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public static List<UserDto> toDtos(List<User> users) {
|
||||
List<UserDto> dtoList = new ArrayList<>(users.size());
|
||||
for (User user : users) {
|
||||
dtoList.add(new UserDto(user));
|
||||
}
|
||||
return dtoList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.dto.user;
|
||||
|
||||
import cc.honyee.domain.user.User;
|
||||
import cc.honyee.infrastructure.PasswordHandler;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class UserFormDto extends UserDto {
|
||||
|
||||
private String password;
|
||||
private String rePassword;
|
||||
|
||||
private String existUsername;
|
||||
|
||||
public UserFormDto() {
|
||||
}
|
||||
|
||||
public UserFormDto(User user) {
|
||||
super(user);
|
||||
this.existUsername = user.username();
|
||||
}
|
||||
|
||||
public UserFormDto(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewly() {
|
||||
return super.isNewly() || "create".equalsIgnoreCase(guid);
|
||||
}
|
||||
|
||||
public User toDomain() {
|
||||
String encryptPass = PasswordHandler.encryptPassword(password);
|
||||
return new User(username, encryptPass, phone, email);
|
||||
}
|
||||
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRePassword() {
|
||||
return rePassword;
|
||||
}
|
||||
|
||||
public void setRePassword(String rePassword) {
|
||||
this.rePassword = rePassword;
|
||||
}
|
||||
|
||||
public String getExistUsername() {
|
||||
return existUsername;
|
||||
}
|
||||
|
||||
public void setExistUsername(String existUsername) {
|
||||
this.existUsername = existUsername;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.oauth;
|
||||
|
||||
import org.springframework.security.oauth2.provider.JdbcClientDetailsService;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* Add <i>archived = 0</i> condition
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class CustomJdbcClientDetailsService extends JdbcClientDetailsService {
|
||||
|
||||
private static final String SELECT_CLIENT_DETAILS_SQL = "select client_id, client_secret, resource_ids, scope, authorized_grant_types, " +
|
||||
"web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information " +
|
||||
"from oauth_client_details where client_id = ? and archived = 0 ";
|
||||
|
||||
|
||||
public CustomJdbcClientDetailsService(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
setSelectClientDetailsSql(SELECT_CLIENT_DETAILS_SQL);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.oauth;
|
||||
|
||||
import cc.honyee.infrastructure.DateUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class OauthClientDetails implements Serializable {
|
||||
|
||||
|
||||
private Date createTime = DateUtils.now();
|
||||
private boolean archived = false;
|
||||
|
||||
private String clientId;
|
||||
private String resourceIds;
|
||||
|
||||
private String clientSecret;
|
||||
/**
|
||||
* Available values: read,write
|
||||
*/
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* grant types include
|
||||
* "authorization_code", "password", "assertion", and "refresh_token".
|
||||
* Default value is "authorization_code,refresh_token".
|
||||
*/
|
||||
private String authorizedGrantTypes = "authorization_code,refresh_token";
|
||||
|
||||
/**
|
||||
* The re-direct URI(s) established during registration (optional, comma separated).
|
||||
*/
|
||||
private String webServerRedirectUri;
|
||||
|
||||
/**
|
||||
* Authorities that are granted to the client (comma-separated). Distinct from the authorities
|
||||
* granted to the user on behalf of whom the client is acting.
|
||||
* <p/>
|
||||
* For example: ROLE_USER
|
||||
*/
|
||||
private String authorities;
|
||||
|
||||
/**
|
||||
* The access token validity period in seconds (optional).
|
||||
* If unspecified a global default will be applied by the token services.
|
||||
*/
|
||||
private Integer accessTokenValidity;
|
||||
|
||||
/**
|
||||
* The refresh token validity period in seconds (optional).
|
||||
* If unspecified a global default will be applied by the token services.
|
||||
*/
|
||||
private Integer refreshTokenValidity;
|
||||
|
||||
// optional
|
||||
private String additionalInformation;
|
||||
|
||||
/**
|
||||
* The client is trusted or not. If it is trust, will skip approve step
|
||||
* default false.
|
||||
*/
|
||||
private boolean trusted = false;
|
||||
|
||||
public OauthClientDetails() {
|
||||
}
|
||||
|
||||
|
||||
public boolean trusted() {
|
||||
return trusted;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.oauth;
|
||||
|
||||
import cc.honyee.domain.shared.Repository;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public interface OauthRepository extends Repository {
|
||||
|
||||
OauthClientDetails findOauthClientDetails(String clientId);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class BeanProvider {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
|
||||
public static void initialize(ApplicationContext applicationContext) {
|
||||
BeanProvider.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bean by clazz.
|
||||
*
|
||||
* @param clazz Class
|
||||
* @param <T> class type
|
||||
* @return Bean instance
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return applicationContext.getBean(clazz);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String beanId) {
|
||||
return (T) applicationContext.getBean(beanId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class GuidGenerator {
|
||||
|
||||
public static String generate() {
|
||||
return UUID.randomUUID().toString().replaceAll("-", "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
public interface Repository {
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.paginated;
|
||||
|
||||
import cc.honyee.domain.shared.security.SecurityUtils;
|
||||
import org.displaytag.pagination.PaginatedList;
|
||||
import org.displaytag.properties.SortOrderEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class DefaultPaginated<T> implements Paginated<T>, PaginatedList {
|
||||
|
||||
public static final int DEFAULT_PER_PAGE_SIZE = 20;
|
||||
|
||||
protected List<T> list = new ArrayList<T>();
|
||||
protected int perPageSize;
|
||||
protected int totalSize = 0;
|
||||
protected int pageNumber = 1;
|
||||
|
||||
protected String sortName;
|
||||
protected PaginatedSort sort;
|
||||
|
||||
protected String sortCriterion;
|
||||
private SortOrderEnum sortOrderEnum;
|
||||
private String searchId;
|
||||
|
||||
|
||||
public DefaultPaginated() {
|
||||
this(DEFAULT_PER_PAGE_SIZE);
|
||||
}
|
||||
|
||||
public DefaultPaginated(int perPageSize) {
|
||||
this.perPageSize = perPageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String, Object> defaultQueryMap() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("user", SecurityUtils.currentUser());
|
||||
map.put("perPageSize", getPerPageSize());
|
||||
map.put("startIndex", getStartIndex());
|
||||
return map;
|
||||
}
|
||||
|
||||
public int getTotalPages() {
|
||||
if (totalSize % perPageSize == 0) {
|
||||
return (totalSize / perPageSize);
|
||||
} else {
|
||||
return (totalSize / perPageSize) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectsPerPage() {
|
||||
return perPageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFullListSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSortCriterion() {
|
||||
return sortCriterion;
|
||||
}
|
||||
|
||||
public void setSortCriterion(String sortCriterion) {
|
||||
this.sortCriterion = sortCriterion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrderEnum getSortDirection() {
|
||||
return sortOrderEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchId() {
|
||||
return searchId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPerPageSize() {
|
||||
return perPageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSortName() {
|
||||
return sortName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginatedSort getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return (getPageNumber() - 1) * getPerPageSize();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <K extends Paginated> K load(PaginatedLoader<T> paginatedLoader) {
|
||||
if (this.totalSize == 0) {
|
||||
this.totalSize = paginatedLoader.loadTotalSize();
|
||||
}
|
||||
this.list = paginatedLoader.loadList();
|
||||
afterLoad();
|
||||
return (K) this;
|
||||
}
|
||||
|
||||
public void afterLoad() {
|
||||
// Callback after load data.
|
||||
}
|
||||
|
||||
public void setPerPageSize(int perPageSize) {
|
||||
this.perPageSize = perPageSize;
|
||||
}
|
||||
|
||||
public void setTotalSize(int totalSize) {
|
||||
this.totalSize = totalSize;
|
||||
}
|
||||
|
||||
public void setPageNumber(int pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public void setSortName(String sortName) {
|
||||
this.sortName = sortName;
|
||||
}
|
||||
|
||||
public void setSort(PaginatedSort sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public boolean isHasNext() {
|
||||
return (getStartIndex() + this.perPageSize < totalSize);
|
||||
}
|
||||
|
||||
public boolean isHasPrevious() {
|
||||
return getStartIndex() != 0;
|
||||
}
|
||||
|
||||
public void setSortOrderEnum(SortOrderEnum sortOrderEnum) {
|
||||
this.sortOrderEnum = sortOrderEnum;
|
||||
}
|
||||
|
||||
public void setSearchId(String searchId) {
|
||||
this.searchId = searchId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.paginated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
public interface Paginated<T> {
|
||||
|
||||
List<T> getList();
|
||||
|
||||
int getPageNumber();
|
||||
|
||||
int getPerPageSize();
|
||||
|
||||
int getTotalSize();
|
||||
|
||||
String getSortName();
|
||||
|
||||
PaginatedSort getSort();
|
||||
|
||||
int getTotalPages();
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.paginated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
public interface PaginatedLoader<T> {
|
||||
|
||||
List<T> loadList();
|
||||
|
||||
int loadTotalSize();
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.paginated;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public enum PaginatedSort {
|
||||
ASC("asc"),
|
||||
DESC("desc");
|
||||
|
||||
private String label;
|
||||
|
||||
PaginatedSort(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.security;
|
||||
|
||||
import cc.honyee.infrastructure.DateUtils;
|
||||
import cc.honyee.domain.user.User;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class HonyeeUserDetails implements UserDetails {
|
||||
|
||||
protected static final String ROLE_PREFIX = "ROLE_";
|
||||
protected static final GrantedAuthority DEFAULT_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + "USER");
|
||||
protected static final GrantedAuthority ADMIN_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + "ADMIN");
|
||||
|
||||
protected User user;
|
||||
|
||||
|
||||
public HonyeeUserDetails() {
|
||||
}
|
||||
|
||||
public HonyeeUserDetails(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
// if (user.defaultUser()) {
|
||||
// return Arrays.asList(ADMIN_USER_ROLE, DEFAULT_USER_ROLE);
|
||||
// }
|
||||
return Arrays.asList(DEFAULT_USER_ROLE, new SimpleGrantedAuthority(ROLE_PREFIX + "UNITY"), new SimpleGrantedAuthority(ROLE_PREFIX + "MOBILE"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return user.password();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user.username();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public User user() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getLastLoginTime() {
|
||||
if (user != null && user.lastLoginTime() != null) {
|
||||
return DateUtils.toDateText(user.lastLoginTime(), DateUtils.DEFAULT_DATE_TIME_FORMAT);
|
||||
}
|
||||
return "---";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("{user=").append(user);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.security;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
public interface SecurityHolder {
|
||||
|
||||
HonyeeUserDetails userDetails();
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.shared.security;
|
||||
|
||||
import cc.honyee.domain.user.User;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
|
||||
private static SecurityHolder securityHolder;
|
||||
|
||||
public void setSecurityHolder(SecurityHolder securityHolder) {
|
||||
SecurityUtils.securityHolder = securityHolder;
|
||||
}
|
||||
|
||||
public static User currentUser() {
|
||||
HonyeeUserDetails userDetails = securityHolder.userDetails();
|
||||
return (userDetails != null ? userDetails.user() : null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.user;
|
||||
|
||||
import cc.honyee.domain.AbstractDomain;
|
||||
import cc.honyee.domain.shared.BeanProvider;
|
||||
import cc.honyee.infrastructure.PasswordHandler;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class User extends AbstractDomain {
|
||||
|
||||
private transient UserRepository userRepository = BeanProvider.getBean(UserRepository.class);
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private String phone;
|
||||
private String email;
|
||||
//Default user is initial when create database, do not delete
|
||||
private boolean defaultUser = false;
|
||||
|
||||
private Date lastLoginTime;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String username, String password, String phone, String email) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.phone = phone;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public boolean defaultUser() {
|
||||
return defaultUser;
|
||||
}
|
||||
|
||||
public String username() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String password() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String phone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public String email() {
|
||||
return email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("{username='").append(username).append('\'');
|
||||
sb.append(", phone='").append(phone).append('\'');
|
||||
sb.append(", id='").append(id).append('\'');
|
||||
sb.append(", guid='").append(guid).append('\'');
|
||||
sb.append(", defaultUser='").append(defaultUser).append('\'');
|
||||
sb.append(", email='").append(email).append('\'');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public User email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public User phone(String phone) {
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (isNewly()) {
|
||||
userRepository.saveUser(this);
|
||||
} else {
|
||||
userRepository.updateUser(this);
|
||||
}
|
||||
}
|
||||
|
||||
public User username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String resetPassword() {
|
||||
String newOriginalPass = PasswordHandler.randomPassword();
|
||||
this.password = PasswordHandler.encryptPassword(newOriginalPass);
|
||||
this.saveOrUpdate();
|
||||
return newOriginalPass;
|
||||
}
|
||||
|
||||
|
||||
public Date lastLoginTime() {
|
||||
return lastLoginTime;
|
||||
}
|
||||
|
||||
public void lastLoginTime(Date lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.domain.user;
|
||||
|
||||
import cc.honyee.domain.shared.Repository;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
public interface UserRepository extends Repository {
|
||||
|
||||
User findByGuid(String guid);
|
||||
|
||||
void saveUser(User user);
|
||||
|
||||
void updateUser(User user);
|
||||
|
||||
User findByUsername(String username);
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class DateUtils {
|
||||
|
||||
/**
|
||||
* Default time format : yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* Time format : yyyy-MM-dd HH:mm
|
||||
*/
|
||||
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";
|
||||
public static final String TIME_FORMAT = "HH:mm";
|
||||
|
||||
/**
|
||||
* Default date format
|
||||
*/
|
||||
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||
/**
|
||||
* Default month format
|
||||
*/
|
||||
public static final String MONTH_FORMAT = "yyyy-MM";
|
||||
/**
|
||||
* Default day format
|
||||
*/
|
||||
public static final String DAY_FORMAT = "dd";
|
||||
|
||||
public static final long DAY_MILLISECONDS = (1000l * 60 * 60 * 24);
|
||||
|
||||
//Date pattern, demo: 2013-09-11
|
||||
public static final String DATE_PATTERN = "^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}$";
|
||||
|
||||
|
||||
public static boolean isDate(String dateAsText) {
|
||||
return StringUtils.isNotEmpty(dateAsText) && dateAsText.matches(DATE_PATTERN);
|
||||
}
|
||||
|
||||
public static Date now() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public static String toDateText(Date date) {
|
||||
return toDateText(date, DATE_FORMAT);
|
||||
}
|
||||
|
||||
public static String toDateText(Date date, String pattern) {
|
||||
if (date == null || pattern == null) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
public static Date getDate(String dateText) {
|
||||
return getDate(dateText, DATE_FORMAT);
|
||||
}
|
||||
|
||||
|
||||
public static Date getDate(String dateText, String pattern) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
|
||||
try {
|
||||
return dateFormat.parse(dateText);
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalStateException("Parse date from [" + dateText + "," + pattern + "] failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String toDateTime(Date date) {
|
||||
return toDateText(date, DATE_TIME_FORMAT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return current year.
|
||||
*
|
||||
* @return Current year
|
||||
*/
|
||||
public static int currentYear() {
|
||||
return calendar().get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
public static Calendar calendar() {
|
||||
return Calendar.getInstance();
|
||||
}
|
||||
|
||||
public static boolean isToday(Date date) {
|
||||
if (date == null) {
|
||||
return false;
|
||||
}
|
||||
String dateAsText = toDateText(date);
|
||||
String todayAsText = toDateText(now());
|
||||
return dateAsText.equals(todayAsText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tow dates period as days,
|
||||
* return -1 if the start or end is null
|
||||
*
|
||||
* @param start Start date
|
||||
* @param end End date
|
||||
* @return Period as days or -1
|
||||
*/
|
||||
public static long periodAsDays(Date start, Date end) {
|
||||
if (start == null || end == null) {
|
||||
return -1;
|
||||
}
|
||||
start = org.apache.commons.lang.time.DateUtils.truncate(start, Calendar.DAY_OF_MONTH);
|
||||
end = org.apache.commons.lang.time.DateUtils.truncate(end, Calendar.DAY_OF_MONTH);
|
||||
|
||||
long periodAsMilliSeconds = end.getTime() - start.getTime();
|
||||
return (periodAsMilliSeconds / (DAY_MILLISECONDS));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class DimensionalCodeHelper {
|
||||
|
||||
|
||||
//Default size: 200 * 200
|
||||
public static byte[] encode(String content) {
|
||||
return encode(content, 200, 200);
|
||||
}
|
||||
|
||||
|
||||
public static byte[] encode(String content, int width, int height) {
|
||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
|
||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||
BitMatrix matrix;
|
||||
try {
|
||||
matrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
} catch (WriterException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try {
|
||||
MatrixToImageWriter.writeToStream(matrix, "png", os);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return os.toByteArray();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class MatchUtils {
|
||||
|
||||
/**
|
||||
* BigDecimal regex.
|
||||
*/
|
||||
public static final String BIG_DECIMAL_REGEX = "^(\\d+)||(\\d+\\.\\d+)$";
|
||||
|
||||
/**
|
||||
* Positive Number regex.
|
||||
*/
|
||||
public static final String POSITIVE_NUMBER_REGEX = "^\\d+$";
|
||||
|
||||
/**
|
||||
* Email regex.
|
||||
*/
|
||||
public static final String EMAIL_REGEX = ".+@.+\\.[a-z]+";
|
||||
|
||||
public static boolean isBigDecimal(String text) {
|
||||
return StringUtils.isNotEmpty(text) && text.matches(BIG_DECIMAL_REGEX);
|
||||
}
|
||||
|
||||
public static boolean isEmail(String email) {
|
||||
return StringUtils.isNotEmpty(email) && email.matches(EMAIL_REGEX);
|
||||
}
|
||||
|
||||
public static boolean isPositiveNumber(String numberText) {
|
||||
return StringUtils.isNotEmpty(numberText) && numberText.matches(POSITIVE_NUMBER_REGEX);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import cc.honyee.domain.shared.GuidGenerator;
|
||||
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class PasswordHandler {
|
||||
|
||||
|
||||
/**
|
||||
* Encrypt factor, use it for reversible password
|
||||
*/
|
||||
private static final int ENCRYPT_FACTOR = 7;
|
||||
|
||||
/**
|
||||
* Return a random password from {@link java.util.UUID},
|
||||
* the length is 8.
|
||||
*
|
||||
* @return Random password
|
||||
*/
|
||||
public static String randomPassword() {
|
||||
String uuid = GuidGenerator.generate();
|
||||
return uuid.substring(0, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt password ,if original password is empty,
|
||||
* will call {@link #randomPassword()} get a random original password.
|
||||
*
|
||||
* @param originalPassword Original password
|
||||
* @return Encrypted password
|
||||
*/
|
||||
public static String encryptPassword(String originalPassword) {
|
||||
Md5PasswordEncoder md5PasswordEncoder = new Md5PasswordEncoder();
|
||||
return md5PasswordEncoder.encodePassword(originalPassword, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the reversible password
|
||||
*
|
||||
* @param originalPassword originalPassword
|
||||
* @return encrypted password
|
||||
*/
|
||||
public static String encryptReversiblePassword(String originalPassword) {
|
||||
if (!StringUtils.hasText(originalPassword)) {
|
||||
return originalPassword;
|
||||
}
|
||||
byte[] bytes = originalPassword.getBytes();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
byte b = bytes[i];
|
||||
bytes[i] = (byte) (b ^ ENCRYPT_FACTOR);
|
||||
}
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt the encrypted password.
|
||||
*
|
||||
* @param encryptedPassword encryptedPassword
|
||||
* @return decrypted password
|
||||
*/
|
||||
public static String decryptReversiblePassword(String encryptedPassword) {
|
||||
return encryptReversiblePassword(encryptedPassword);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure.mybatis;
|
||||
|
||||
import cc.honyee.domain.oauth.OauthRepository;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public interface OauthRepositoryMyBatis extends OauthRepository {
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure.mybatis;
|
||||
|
||||
import cc.honyee.domain.user.UserRepository;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public interface UserRepositoryMyBatis extends UserRepository {
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.service;
|
||||
|
||||
import cc.honyee.domain.oauth.OauthClientDetails;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
|
||||
public interface OauthService {
|
||||
|
||||
OauthClientDetails loadOauthClientDetails(String clientId);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.service;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public interface UserService extends UserDetailsService {
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.service.impl;
|
||||
|
||||
import cc.honyee.domain.oauth.OauthClientDetails;
|
||||
import cc.honyee.domain.oauth.OauthRepository;
|
||||
import cc.honyee.service.OauthService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Service("oauthService")
|
||||
public class OauthServiceImpl implements OauthService {
|
||||
|
||||
@Autowired
|
||||
private OauthRepository oauthRepository;
|
||||
|
||||
@Override
|
||||
public OauthClientDetails loadOauthClientDetails(String clientId) {
|
||||
return oauthRepository.findOauthClientDetails(clientId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.service.impl;
|
||||
|
||||
import cc.honyee.domain.shared.security.HonyeeUserDetails;
|
||||
import cc.honyee.domain.user.User;
|
||||
import cc.honyee.domain.user.UserRepository;
|
||||
import cc.honyee.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.oauth2.provider.BaseClientDetails;
|
||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Service("userService")
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
User user = userRepository.findByUsername(username);
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("Not found any user for username[" + username + "]");
|
||||
}
|
||||
|
||||
return new HonyeeUserDetails(user);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.web.context;
|
||||
|
||||
import cc.honyee.domain.shared.BeanProvider;
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class BeanContextLoaderListener extends ContextLoaderListener {
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
super.contextInitialized(event);
|
||||
WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
|
||||
BeanProvider.initialize(applicationContext);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.web.context;
|
||||
|
||||
import cc.honyee.domain.shared.security.HonyeeUserDetails;
|
||||
import cc.honyee.domain.shared.security.SecurityHolder;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class SpringSecurityHolder implements SecurityHolder {
|
||||
|
||||
@Override
|
||||
public HonyeeUserDetails userDetails() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
}
|
||||
Object principal = authentication.getPrincipal();
|
||||
if (principal instanceof HonyeeUserDetails) {
|
||||
return (HonyeeUserDetails) principal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.web.controller;
|
||||
|
||||
import cc.honyee.service.UserService;
|
||||
import cc.honyee.web.validator.UserFormDtoValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/user/")
|
||||
public class UserController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserFormDtoValidator validator;
|
||||
|
||||
@RequestMapping("overview.htm")
|
||||
public String overview(Model model) {
|
||||
|
||||
return "user_overview";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.web.controller.mobile;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/m/")
|
||||
public class MobileController {
|
||||
|
||||
|
||||
@RequestMapping("dashboard.htm")
|
||||
public String dashboard() {
|
||||
return "mobile/dashboard";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.web.controller.unity;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/unity/")
|
||||
public class UnityController {
|
||||
|
||||
|
||||
@RequestMapping("dashboard.htm")
|
||||
public String dashboard() {
|
||||
return "unity/dashboard";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cc.honyee.web.oauth;
|
||||
|
||||
import cc.honyee.domain.oauth.OauthClientDetails;
|
||||
import cc.honyee.service.OauthService;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.oauth2.provider.AuthorizationRequest;
|
||||
import org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class OauthUserApprovalHandler extends TokenServicesUserApprovalHandler {
|
||||
|
||||
private OauthService oauthService;
|
||||
|
||||
public OauthUserApprovalHandler() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allows automatic approval for a white list of clients in the implicit grant case.
|
||||
*
|
||||
* @param authorizationRequest The authorization request.
|
||||
* @param userAuthentication the current user authentication
|
||||
* @return Whether the specified request has been approved by the current user.
|
||||
*/
|
||||
public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
|
||||
if (super.isApproved(authorizationRequest, userAuthentication)) {
|
||||
return true;
|
||||
}
|
||||
if (!userAuthentication.isAuthenticated()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OauthClientDetails clientDetails = oauthService.loadOauthClientDetails(authorizationRequest.getClientId());
|
||||
return (clientDetails != null && clientDetails.trusted());
|
||||
|
||||
}
|
||||
|
||||
public void setOauthService(OauthService oauthService) {
|
||||
this.oauthService = oauthService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.web.validator;
|
||||
|
||||
import cc.honyee.domain.dto.user.UserFormDto;
|
||||
import cc.honyee.infrastructure.MatchUtils;
|
||||
import cc.honyee.service.UserService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Component
|
||||
public class UserFormDtoValidator implements Validator {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return UserFormDto.class.equals(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
UserFormDto userFormDto = (UserFormDto) target;
|
||||
validateUsername(userFormDto, errors);
|
||||
validateEmail(userFormDto, errors);
|
||||
|
||||
if (userFormDto.isNewly()) {
|
||||
validatePassword(userFormDto, errors);
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePassword(UserFormDto userFormDto, Errors errors) {
|
||||
String password = userFormDto.getPassword();
|
||||
if (password.length() < 6) {
|
||||
errors.rejectValue("password", null, "用户密码至少6位");
|
||||
return;
|
||||
}
|
||||
if (!password.equals(userFormDto.getRePassword())) {
|
||||
errors.rejectValue("rePassword", null, "两次输入的密码不相同");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void validateEmail(UserFormDto userFormDto, Errors errors) {
|
||||
String email = userFormDto.getEmail();
|
||||
if (!MatchUtils.isEmail(email)) {
|
||||
errors.rejectValue("email", null, "邮件地址格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateUsername(UserFormDto userFormDto, Errors errors) {
|
||||
String username = userFormDto.getUsername();
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
errors.rejectValue("username", null, "用户名不能为空");
|
||||
return;
|
||||
}
|
||||
if (!username.equals(userFormDto.getExistUsername())) {
|
||||
// boolean exist = userService.loadExistUsername(username);
|
||||
// if (exist) {
|
||||
// errors.rejectValue("username", null, "该用户名已经存在");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="cc.honyee.infrastructure.mybatis.OauthRepositoryMyBatis">
|
||||
|
||||
<resultMap type="OauthClientDetails" id="oauthClientDetailsMap">
|
||||
<id property="clientId" column="client_id"/>
|
||||
|
||||
<result property="resourceIds" column="resource_ids"/>
|
||||
<result property="clientSecret" column="client_secret"/>
|
||||
<result property="scope" column="scope"/>
|
||||
|
||||
<result property="authorizedGrantTypes" column="authorized_grant_types"/>
|
||||
<result property="webServerRedirectUri" column="web_server_redirect_uri"/>
|
||||
<result property="authorities" column="authorities"/>
|
||||
|
||||
<result property="accessTokenValidity" column="access_token_validity"/>
|
||||
<result property="refreshTokenValidity" column="refresh_token_validity"/>
|
||||
<result property="additionalInformation" column="additional_information"/>
|
||||
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="archived" column="archived"/>
|
||||
<result property="trusted" column="trusted"/>
|
||||
|
||||
</resultMap>
|
||||
|
||||
<select id="findOauthClientDetails" parameterType="String" resultMap="oauthClientDetailsMap">
|
||||
select * from oauth_client_details
|
||||
where client_id = #{clientId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="cc.honyee.infrastructure.mybatis.UserRepositoryMyBatis">
|
||||
|
||||
<resultMap type="User" id="userMap">
|
||||
<id property="id" column="id"/>
|
||||
<result property="guid" column="guid"/>
|
||||
<result property="archived" column="archived"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
|
||||
<result property="email" column="email"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="defaultUser" column="default_user"/>
|
||||
|
||||
<result property="password" column="password"/>
|
||||
<result property="username" column="username"/>
|
||||
<result property="lastLoginTime" column="last_login_time"/>
|
||||
|
||||
<!--<discriminator column="type_" javaType="String">-->
|
||||
<!--<case value="Developer"-->
|
||||
<!--resultMap="com.andaily.infrastructure.mybatis.user.DeveloperRepositoryMyBatis.developerMap"/>-->
|
||||
<!--</discriminator>-->
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="findByGuid" parameterType="String" resultMap="userMap">
|
||||
select * from user_ where guid = #{guid}
|
||||
</select>
|
||||
|
||||
<select id="findUserById" parameterType="Integer" resultMap="userMap">
|
||||
select * from user_ where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByUsername" parameterType="String" resultMap="userMap">
|
||||
select * from user_
|
||||
where username = #{username}
|
||||
and archived = 0
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="saveUser" parameterType="User" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into user_(guid,archived,create_time,email,password,username,phone, last_login_time)
|
||||
values
|
||||
(#{guid},#{archived},#{createTime},#{email},#{password},#{username}, #{phone}, #{lastLoginTime})
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="User" flushCache="true">
|
||||
update user_ set
|
||||
username = #{username},
|
||||
password = #{password},
|
||||
phone = #{phone},
|
||||
email = #{email}
|
||||
where guid = #{guid}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,8 @@
|
|||
#JDBC configuration information
|
||||
jdbc.driverClassName=com.mysql.jdbc.Driver
|
||||
############
|
||||
# localhost
|
||||
############
|
||||
jdbc.url=jdbc:mysql://localhost:3306/oauth2?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8
|
||||
jdbc.username=honyee
|
||||
jdbc.password=honyee
|
|
@ -0,0 +1,111 @@
|
|||
basic.empty.showtable=true
|
||||
basic.show.header=true
|
||||
|
||||
# page | list
|
||||
sort.amount=page
|
||||
|
||||
export.amount=list
|
||||
export.decorated=true
|
||||
|
||||
paging.banner.group_size=5
|
||||
paging.banner.placement=bottom
|
||||
|
||||
|
||||
css.tr.even=even
|
||||
css.tr.odd=odd
|
||||
css.th.sorted=sorted
|
||||
css.th.ascending=order1
|
||||
css.th.descending=order2
|
||||
css.table=
|
||||
css.th.sortable=sortable
|
||||
|
||||
# factory classes for extensions
|
||||
factory.requestHelper=org.displaytag.util.DefaultRequestHelperFactory
|
||||
|
||||
# factory class for decorators
|
||||
factory.decorator=org.displaytag.decorator.DefaultDecoratorFactory
|
||||
|
||||
# locale provider (Jstl provider by default)
|
||||
locale.provider=org.displaytag.localization.I18nJstlAdapter
|
||||
|
||||
# locale.resolver (nothing by default, simply use locale from request)
|
||||
#locale.resolver=
|
||||
|
||||
export.types=csv excel xml pdf
|
||||
|
||||
export.csv.class=org.displaytag.export.CsvView
|
||||
export.excel.class=org.displaytag.export.ExcelView
|
||||
export.xml.class=org.displaytag.export.XmlView
|
||||
export.pdf.class=org.displaytag.export.PdfView
|
||||
|
||||
export.csv=true
|
||||
export.csv.label=<span class="export csv">CSV </span>
|
||||
export.csv.include_header=false
|
||||
export.csv.filename=
|
||||
|
||||
export.excel=true
|
||||
export.excel.label=<span class="export excel">Excel </span>
|
||||
export.excel.include_header=true
|
||||
export.excel.filename=
|
||||
|
||||
export.xml=true
|
||||
export.xml.label=<span class="export xml">XML </span>
|
||||
export.xml.filename=
|
||||
|
||||
export.pdf=false
|
||||
export.pdf.label=<span class="export pdf">PDF </span>
|
||||
export.pdf.include_header=true
|
||||
export.pdf.filename=
|
||||
|
||||
export.rtf=false
|
||||
export.rtf.label=<span class="export rtf">RTF </span>
|
||||
export.rtf.include_header=true
|
||||
export.rtf.filename=
|
||||
|
||||
# messages
|
||||
|
||||
basic.msg.empty_list=
|
||||
basic.msg.empty_list_row=<tr class="empty"><td colspan="{0}"> </td></tr>
|
||||
error.msg.invalid_page=invalid page
|
||||
|
||||
export.banner=<div class="exportlinks">\u5bfc\u51fa\u9009\u9879: {0}</div>
|
||||
export.banner.sepchar= |
|
||||
|
||||
paging.banner.item_name=\u6761
|
||||
paging.banner.items_name=\u6761
|
||||
|
||||
paging.banner.no_items_found=
|
||||
paging.banner.one_item_found=
|
||||
paging.banner.all_items_found=
|
||||
paging.banner.some_items_found=
|
||||
|
||||
#paging.banner.full=<span class="pagelinks">[<a href="{1}">\u9996\u9875</a>/<a href="{2}">\u4e0a\u9875</a>] {0} [<a href="{3}">\u4e0b\u9875</a>/<a href="{4}">\u672b\u9875</a>]</span>
|
||||
#paging.banner.first=<span class="pagelinks">[\u9996\u9875/\u4e0a\u9875] {0} [<a href="{3}">\u4e0b\u9875</a>/<a href="{4}">\u672b\u9875</a>]</span>
|
||||
#paging.banner.last=<span class="pagelinks">[<a href="{1}">\u9996\u9875</a>/<a href="{2}">\u4e0a\u9875</a>] {0} [\u4e0b\u9875/\u672b\u9875]</span>
|
||||
#paging.banner.onepage=<span class="pagelinks">{0}</span>
|
||||
paging.banner.full=<div class="pager clearfix text-center"><ul><li><a href="{1}">«\u4e0a\u9875</a></li>{0}<li><a href="{4}">\u4e0b\u9875»</a></li></ul></div>
|
||||
paging.banner.first=<div class="pager clearfix text-center"><ul><li><a href="javascript:void(0);">«\u4e0a\u9875</a></li>{0}<li><a href="{4}">\u4e0b\u9875»</a></li></ul></div>
|
||||
paging.banner.last=<div class="pager clearfix text-center"><ul><li><a href="{1}">«\u4e0a\u9875</a></li>{0}<li><a href="javascript:void(0);">\u4e0b\u9875»</a></li></ul></div>
|
||||
paging.banner.onepage=<div class="pager clearfix text-center"><ul><li><a href="javascript:void(0);">«\u4e0a\u9875</a></li>{0}<li><a href="javascript:void(0);">\u4e0b\u9875»</a></li></ul></div>
|
||||
|
||||
|
||||
#paging.banner.page.selected=<strong>{0}</strong>
|
||||
#paging.banner.page.link=<a href="{1}">{0}</a>
|
||||
#paging.banner.page.separator=
|
||||
paging.banner.page.selected=<li class="active"><a href="javascript:void(0);">{0}</a></li>
|
||||
paging.banner.page.link=<li><a href="{1}">{0}</a></li>
|
||||
paging.banner.page.separator=
|
||||
|
||||
|
||||
# external sort and pagination
|
||||
pagination.sort.param=sort
|
||||
pagination.sortdirection.param=dir
|
||||
pagination.pagenumber.param=pageNumber
|
||||
pagination.searchid.param=searchid
|
||||
pagination.sort.asc.value=asc
|
||||
pagination.sort.desc.value=desc
|
||||
pagination.sort.skippagenumber=true
|
||||
|
||||
# unused
|
||||
save.excel.banner=<a href="{0}" rel="external">\u4fdd\u5b58 ({1} \u5b57\u8282)</a>
|
||||
save.excel.filename=export.xls
|
|
@ -0,0 +1,14 @@
|
|||
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
|
||||
|
||||
############################################################
|
||||
# Handler specific properties.
|
||||
# Describes specific configuration info for Handlers.
|
||||
# The configuration for Tomcat server
|
||||
############################################################
|
||||
|
||||
org.apache.juli.FileHandler.level = FINE
|
||||
org.apache.juli.FileHandler.directory = ${catalina.base}/logs
|
||||
org.apache.juli.FileHandler.prefix = error-debug.
|
||||
|
||||
java.util.logging.ConsoleHandler.level = FINE
|
||||
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
|
@ -0,0 +1,22 @@
|
|||
#Email configure
|
||||
#mail host name
|
||||
host.name=smtp.exmail.qq.com
|
||||
#mail send port,default 25
|
||||
mail.smtp.port=25
|
||||
#mail use username
|
||||
mail.username=no-reply@honyee.cc
|
||||
#mail use password
|
||||
mail.password=honyee@2013
|
||||
#default mail address
|
||||
default.mail.address=no-reply@honyee.cc
|
||||
# auth
|
||||
mail.smtp.auth=true
|
||||
# true is use new thread send mail, default false
|
||||
#If develop in production, change it to true
|
||||
mail.send.use.thread=false
|
||||
|
||||
|
||||
#Develop configuration
|
||||
#If develop in production, change it to false
|
||||
mail.develop.environment=true
|
||||
mail.develop.address=shengzhao@honyee.cc
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
|
||||
<configuration>
|
||||
<settings>
|
||||
<setting name="lazyLoadingEnabled" value="false"/>
|
||||
<setting name="useGeneratedKeys" value="true"/>
|
||||
</settings>
|
||||
<typeAliases>
|
||||
<typeAlias alias="User" type="cc.honyee.domain.user.User"/>
|
||||
<typeAlias alias="OauthClientDetails" type="cc.honyee.domain.oauth.OauthClientDetails"/>
|
||||
|
||||
</typeAliases>
|
||||
|
||||
<mappers>
|
||||
<mapper resource="cc/honyee/infrastructure/mybatis/UserMapper.xml"/>
|
||||
<mapper resource="cc/honyee/infrastructure/mybatis/OauthMapper.xml"/>
|
||||
|
||||
</mappers>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
|
||||
<!--annotation configuration -->
|
||||
<context:annotation-config/>
|
||||
<context:component-scan base-package="cc.honyee.service"/>
|
||||
|
||||
<!-- property configuration -->
|
||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>classpath:database.properties</value>
|
||||
<value>classpath:mail.properties</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!--dataSource-->
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
<property name="driverClassName" value="${jdbc.driverClassName}"/>
|
||||
<property name="url" value="${jdbc.url}"/>
|
||||
<property name="username" value="${jdbc.username}"/>
|
||||
<property name="password" value="${jdbc.password}"/>
|
||||
|
||||
<property name="validationQuery" value="SELECT 1"/>
|
||||
<property name="testOnReturn" value="false"/>
|
||||
<property name="testOnBorrow" value="true"/>
|
||||
<!--Based on 1000 connected user -->
|
||||
<property name="maxActive" value="200"/>
|
||||
<property name="maxIdle" value="50"/>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven transaction-manager="transactionManager"/>
|
||||
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
|
||||
<constructor-arg index="0" ref="sqlSessionFactory"/>
|
||||
<constructor-arg index="1" value="BATCH"/>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="configLocation" value="classpath:mybatis.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||||
<property name="basePackage" value="cc.honyee.infrastructure.mybatis"/>
|
||||
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
|
||||
<!--Mail configuration-->
|
||||
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="host" value="${host.name}"/>
|
||||
<property name="port" value="${mail.smtp.port}"/>
|
||||
<property name="username" value="${mail.username}"/>
|
||||
<property name="password" value="${mail.password}"/>
|
||||
<property name="defaultEncoding" value="UTF-8"/>
|
||||
<property name="javaMailProperties">
|
||||
<props>
|
||||
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,181 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/security"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:oauth2="http://www.springframework.org/schema/security/oauth2"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||
|
||||
<!--<debug/>-->
|
||||
|
||||
<!--static url pattern-->
|
||||
<!--<http pattern="/resources/**" security="none"/>-->
|
||||
|
||||
|
||||
<!--
|
||||
Oauth server start.............
|
||||
https://github.com/spring-projects/spring-security-oauth/blob/master/docs/oauth2.md
|
||||
-->
|
||||
|
||||
<mvc:annotation-driven/>
|
||||
<mvc:default-servlet-handler/>
|
||||
|
||||
<http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="oauth2AuthenticationManager"
|
||||
entry-point-ref="oauth2AuthenticationEntryPoint">
|
||||
<intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY"/>
|
||||
<anonymous enabled="false"/>
|
||||
<http-basic entry-point-ref="oauth2AuthenticationEntryPoint"/>
|
||||
|
||||
<custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER"/>
|
||||
<access-denied-handler ref="oauth2AccessDeniedHandler"/>
|
||||
</http>
|
||||
|
||||
<!--unity http configuration-->
|
||||
<http pattern="/unity/**" create-session="never" entry-point-ref="oauth2AuthenticationEntryPoint"
|
||||
access-decision-manager-ref="oauth2AccessDecisionManager">
|
||||
<anonymous enabled="false"/>
|
||||
|
||||
<intercept-url pattern="/unity/**" access="ROLE_UNITY,SCOPE_READ"/>
|
||||
|
||||
<custom-filter ref="unityResourceServer" before="PRE_AUTH_FILTER"/>
|
||||
<access-denied-handler ref="oauth2AccessDeniedHandler"/>
|
||||
</http>
|
||||
|
||||
<!--mobile http configuration-->
|
||||
<http pattern="/m/**" create-session="never" entry-point-ref="oauth2AuthenticationEntryPoint"
|
||||
access-decision-manager-ref="oauth2AccessDecisionManager">
|
||||
<anonymous enabled="false"/>
|
||||
|
||||
<intercept-url pattern="/m/**" access="ROLE_MOBILE,SCOPE_READ"/>
|
||||
|
||||
<custom-filter ref="mobileResourceServer" before="PRE_AUTH_FILTER"/>
|
||||
<access-denied-handler ref="oauth2AccessDeniedHandler"/>
|
||||
</http>
|
||||
|
||||
<beans:bean id="clientCredentialsTokenEndpointFilter"
|
||||
class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter">
|
||||
<beans:property name="authenticationManager" ref="oauth2AuthenticationManager"/>
|
||||
</beans:bean>
|
||||
|
||||
<!--unity resource server filter-->
|
||||
<oauth2:resource-server id="unityResourceServer" resource-id="unity-resource" token-services-ref="tokenServices"/>
|
||||
|
||||
<!--mobile resource server filter-->
|
||||
<oauth2:resource-server id="mobileResourceServer" resource-id="mobile-resource" token-services-ref="tokenServices"/>
|
||||
|
||||
<!--Config ClientDetailsService-->
|
||||
<!--<oauth2:client-details-service id="clientDetailsService">-->
|
||||
|
||||
<!--<!–unity client–>-->
|
||||
<!--<oauth2:client client-id="unity-client" resource-ids="unity-resource"-->
|
||||
<!--authorized-grant-types="password,authorization_code,refresh_token,implicit"-->
|
||||
<!--secret="unity" authorities="ROLE_UNITY" scope="read,write"/>-->
|
||||
|
||||
<!--<!–mobile client–>-->
|
||||
<!--<oauth2:client client-id="mobile-client" resource-ids="mobile-resource"-->
|
||||
<!--authorized-grant-types="password,authorization_code,refresh_token,implicit"-->
|
||||
<!--secret="mobile" authorities="ROLE_MOBILE" scope="read,write"/>-->
|
||||
|
||||
<!--</oauth2:client-details-service>-->
|
||||
|
||||
<beans:bean id="clientDetailsService" class="cc.honyee.domain.oauth.CustomJdbcClientDetailsService">
|
||||
<beans:constructor-arg index="0" ref="dataSource"/>
|
||||
</beans:bean>
|
||||
|
||||
|
||||
<!--Config token services-->
|
||||
<!--<beans:bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore"/>-->
|
||||
<beans:bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.JdbcTokenStore">
|
||||
<beans:constructor-arg index="0" ref="dataSource"/>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
|
||||
<beans:property name="tokenStore" ref="tokenStore"/>
|
||||
<beans:property name="supportRefreshToken" value="true"/>
|
||||
</beans:bean>
|
||||
|
||||
<!--<global-method-security pre-post-annotations="enabled" proxy-target-class="true">-->
|
||||
<!--<expression-handler ref="oauth2ExpressionHandler"/>-->
|
||||
<!--</global-method-security>-->
|
||||
|
||||
<oauth2:expression-handler id="oauth2ExpressionHandler"/>
|
||||
<oauth2:web-expression-handler id="oauth2WebExpressionHandler"/>
|
||||
|
||||
<beans:bean id="oauthUserApprovalHandler" class="cc.honyee.web.oauth.OauthUserApprovalHandler">
|
||||
<beans:property name="tokenServices" ref="tokenServices"/>
|
||||
<beans:property name="oauthService" ref="oauthService"/>
|
||||
</beans:bean>
|
||||
|
||||
<oauth2:authorization-server client-details-service-ref="clientDetailsService" token-services-ref="tokenServices"
|
||||
user-approval-handler-ref="oauthUserApprovalHandler"
|
||||
user-approval-page="oauth_approval"
|
||||
error-page="oauth_error">
|
||||
<oauth2:authorization-code/>
|
||||
<oauth2:implicit/>
|
||||
<oauth2:refresh-token/>
|
||||
<oauth2:client-credentials/>
|
||||
<oauth2:password/>
|
||||
</oauth2:authorization-server>
|
||||
|
||||
|
||||
<beans:bean id="oauth2AuthenticationEntryPoint"
|
||||
class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"/>
|
||||
|
||||
|
||||
<beans:bean id="oauth2ClientDetailsUserService"
|
||||
class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService">
|
||||
<beans:constructor-arg ref="clientDetailsService"/>
|
||||
</beans:bean>
|
||||
|
||||
<authentication-manager id="oauth2AuthenticationManager">
|
||||
<authentication-provider user-service-ref="oauth2ClientDetailsUserService"/>
|
||||
</authentication-manager>
|
||||
|
||||
<beans:bean id="oauth2AccessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
|
||||
<beans:constructor-arg>
|
||||
<beans:list>
|
||||
<beans:bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter"/>
|
||||
<beans:bean class="org.springframework.security.access.vote.RoleVoter"/>
|
||||
<beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter"/>
|
||||
</beans:list>
|
||||
</beans:constructor-arg>
|
||||
</beans:bean>
|
||||
|
||||
|
||||
<beans:bean id="oauth2AccessDeniedHandler"
|
||||
class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler"/>
|
||||
|
||||
|
||||
<http access-denied-page="/login.jsp?authorization_error=2" disable-url-rewriting="true"
|
||||
authentication-manager-ref="authenticationManager">
|
||||
<intercept-url pattern="/oauth/**" access="ROLE_USER,ROLE_UNITY,ROLE_MOBILE"/>
|
||||
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
|
||||
|
||||
<form-login authentication-failure-url="/login.jsp?authentication_error=1" default-target-url="/index.jsp"
|
||||
login-page="/login.jsp" login-processing-url="/login.do"/>
|
||||
<logout logout-success-url="/index.jsp" logout-url="/logout.do"/>
|
||||
<anonymous/>
|
||||
</http>
|
||||
|
||||
|
||||
<authentication-manager alias="authenticationManager">
|
||||
<authentication-provider user-service-ref="userService">
|
||||
<password-encoder hash="md5"/>
|
||||
</authentication-provider>
|
||||
</authentication-manager>
|
||||
|
||||
|
||||
<!--
|
||||
Oauth server end.............
|
||||
-->
|
||||
|
||||
<!--security holder-->
|
||||
<beans:bean id="springSecurityHolder" class="cc.honyee.web.context.SpringSecurityHolder"/>
|
||||
|
||||
<beans:bean id="securityHolderFactory" class="cc.honyee.domain.shared.security.SecurityUtils">
|
||||
<beans:property name="securityHolder" ref="springSecurityHolder"/>
|
||||
</beans:bean>
|
||||
|
||||
</beans:beans>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
|
||||
|
||||
<!--aop-->
|
||||
<aop:config>
|
||||
<aop:advisor advice-ref="applicationAdvisor" pointcut="execution(* cc.honyee.service.*.*(..))"/>
|
||||
</aop:config>
|
||||
|
||||
<!--advisor-->
|
||||
<tx:advice id="applicationAdvisor" transaction-manager="transactionManager">
|
||||
<tx:attributes>
|
||||
<tx:method name="*" propagation="REQUIRED"/>
|
||||
<tx:method name="load*" propagation="SUPPORTS" read-only="true"/>
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,21 @@
|
|||
<p><strong>职位描述:</strong></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>岗位职责:</strong></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>联系方式:</strong></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<decorators defaultdir="/WEB-INF/jsp/decorators">
|
||||
|
||||
<!--main decorator-->
|
||||
<decorator name="main" page="main.jsp">
|
||||
<pattern>/*</pattern>
|
||||
</decorator>
|
||||
|
||||
|
||||
<!--<excludes>-->
|
||||
<!--<pattern>/index.jsp*</pattern>-->
|
||||
<!--</excludes>-->
|
||||
|
||||
</decorators>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||
|
||||
|
||||
<!--<import resource="security.xml"/>-->
|
||||
|
||||
<!--annotation configuration -->
|
||||
<context:annotation-config/>
|
||||
<context:component-scan base-package="cc.honyee.web"/>
|
||||
|
||||
<!--static resource-->
|
||||
<mvc:resources mapping="/index.jsp*" location="/index.jsp"/>
|
||||
|
||||
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
|
||||
<property name="order" value="2"/>
|
||||
</bean>
|
||||
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
|
||||
<property name="prefix" value="/WEB-INF/jsp/"/>
|
||||
<property name="suffix" value=".jsp"/>
|
||||
</bean>
|
||||
|
||||
<!-- fileUpload Support -->
|
||||
<bean id="webMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||||
<property name="defaultEncoding" value="UTF-8"/>
|
||||
<property name="maxUploadSize" value="-1"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,41 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<c:set var="contextPath" value="${pageContext.request.contextPath}" scope="application"/>
|
||||
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="keywords" content="honyee.cc"/>
|
||||
<meta name="description" content="honyee.cc"/>
|
||||
<meta name="author" content="honyee.cc"/>
|
||||
|
||||
<title><decorator:title default=""/> - Oauth</title>
|
||||
<decorator:head/>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<decorator:body/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Mobile dashboard</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Hi Mobile.</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Oauth Approval</title>
|
||||
</head>
|
||||
<body><h1>OAuth Approval</h1>
|
||||
|
||||
<p>Do you authorize '${authorizationRequest.clientId}' to access your protected resources?</p>
|
||||
|
||||
<form id='confirmationForm' name='confirmationForm' action='${pageContext.request.contextPath}/oauth/authorize'
|
||||
method='post'>
|
||||
<input name='user_oauth_approval' value='true' type='hidden'/>
|
||||
<label> <input name='authorize' value='Authorize' type='submit'></label>
|
||||
</form>
|
||||
<form id='denialForm' name='denialForm' action='${pageContext.request.contextPath}/oauth/authorize' method='post'>
|
||||
<input name='user_oauth_approval' value='false' type='hidden'/>
|
||||
<label><input name='deny' value='Deny' type='submit'></label>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Oauth Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Illegal action.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Unity dashboard</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Hi Unity.</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>User Overview</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>User Overview</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration>
|
||||
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} %level %class:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--<appender name="AccessLogin" class="ch.qos.logback.core.FileAppender">-->
|
||||
<!--<file>../logs/access_login.log</file>-->
|
||||
<!--<append>true</append>-->
|
||||
<!--<encoder>-->
|
||||
<!--<pattern>%d{yyyy-MM-dd HH:mm:ss} %level %class:%line - %msg%n</pattern>-->
|
||||
<!--</encoder>-->
|
||||
<!--</appender>-->
|
||||
|
||||
<!--<logger name="com.honyee.jiuzhai.web.context.JiuzhaiAuthenticationSuccessHandler" level="DEBUG" additivity="false">-->
|
||||
<!--<appender-ref ref="AccessLogin"/>-->
|
||||
<!--</logger>-->
|
||||
|
||||
<!--springframework package level: WARN-->
|
||||
<logger name="org.springframework" level="WARN"/>
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="Console"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<display-name>spring-oauth</display-name>
|
||||
|
||||
<distributable/>
|
||||
<context-param>
|
||||
<param-name>webAppRootKey</param-name>
|
||||
<param-value>spring-oauth-server</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--Encoding filter-->
|
||||
<filter>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>encoding</param-name>
|
||||
<param-value>UTF-8</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>forceEncoding</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!--GzipFilter -->
|
||||
<filter>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<filter-class>
|
||||
net.sf.ehcache.constructs.web.filter.GzipFilter
|
||||
</filter-class>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.css</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.png</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.gif</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.html</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.htm</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.js</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>gzipFilter</filter-name>
|
||||
<url-pattern>*.json</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
|
||||
<filter>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!-- sitemesh filter-->
|
||||
<filter>
|
||||
<filter-name>sitemesh</filter-name>
|
||||
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>sitemesh</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<mime-mapping>
|
||||
<extension>ico</extension>
|
||||
<mime-type>image/vnd.microsoft.icon</mime-type>
|
||||
</mime-mapping>
|
||||
|
||||
<!--contextConfigLocation -->
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>classpath:spring/*.xml</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>logbackConfigLocation</param-name>
|
||||
<param-value>/WEB-INF/logback.xml</param-value>
|
||||
</context-param>
|
||||
<listener>
|
||||
<listener-class>ch.qos.logback.ext.spring.web.LogbackConfigListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Spring context listener -->
|
||||
<listener>
|
||||
<listener-class>cc.honyee.web.context.BeanContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!--hy mvc-->
|
||||
<servlet>
|
||||
<servlet-name>hy</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>2</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>hy</servlet-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!--<error-page>-->
|
||||
<!--<error-code>404</error-code>-->
|
||||
<!--<location>/index.jsp</location>-->
|
||||
<!--</error-page>-->
|
||||
|
||||
<session-config>
|
||||
<session-timeout>30</session-timeout>
|
||||
</session-config>
|
||||
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1,38 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Home</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>spring-oauth is work!</h3>
|
||||
<a href="${contextPath}/logout.do">Logout</a>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="${contextPath}/user/overview.htm">User</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="${contextPath}/unity/dashboard.htm">Unity</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="${contextPath}/m/dashboard.htm">Mobile</a>
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<%--
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
--%>
|
||||
<%--
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Unity login</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Unity login</h3>
|
||||
|
||||
<form action="${contextPath}/login.do" method="post">
|
||||
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="j_username" value="admin"/>
|
||||
<br/>
|
||||
<br/>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" name="j_password" id="password" value="honyee2013"/>
|
||||
<br/>
|
||||
<input type="submit" value="Login"/>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee;
|
||||
|
||||
import cc.honyee.domain.shared.BeanProvider;
|
||||
import cc.honyee.domain.shared.security.HonyeeUserDetails;
|
||||
import cc.honyee.domain.shared.security.SecurityUtils;
|
||||
import cc.honyee.web.context.SpringSecurityHolder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@ContextConfiguration(locations = {"classpath:testApplicationContext.xml"})
|
||||
public abstract class ContextTest extends AbstractTransactionalTestNGSpringContextTests {
|
||||
|
||||
@BeforeTransaction
|
||||
public void beforeTest() {
|
||||
BeanProvider.initialize(applicationContext);
|
||||
SecurityUtils securityUtils = new SecurityUtils();
|
||||
securityUtils.setSecurityHolder(new SpringSecurityHolder() {
|
||||
@Override
|
||||
public HonyeeUserDetails userDetails() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import cc.honyee.ContextTest;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public abstract class AbstractRepositoryTest extends ContextTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSessionTemplate;
|
||||
|
||||
|
||||
public SqlSessionTemplate sqlSessionTemplate() {
|
||||
return sqlSessionTemplate;
|
||||
}
|
||||
|
||||
public JdbcTemplate jdbcTemplate() {
|
||||
return jdbcTemplate;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class DateUtilsTest {
|
||||
|
||||
@Test
|
||||
public void isToday() throws Exception {
|
||||
boolean today = DateUtils.isToday(DateUtils.now());
|
||||
assertTrue(today);
|
||||
|
||||
today = DateUtils.isToday(DateUtils.getDate("2013-03-09"));
|
||||
assertFalse(today);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isDate() throws Exception {
|
||||
boolean isDate = DateUtils.isDate(null);
|
||||
assertFalse(isDate);
|
||||
|
||||
isDate = DateUtils.isDate("2013-09-11");
|
||||
assertTrue(isDate);
|
||||
|
||||
isDate = DateUtils.isDate("20130911");
|
||||
assertFalse(isDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* OOps! what happened, waiting................
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void periodAsDays() {
|
||||
Date start = DateUtils.now();
|
||||
Date end = DateUtils.now();
|
||||
|
||||
long days = DateUtils.periodAsDays(start, end);
|
||||
System.out.println("Period: " + days);
|
||||
assertEquals(days, 0);
|
||||
|
||||
start = DateUtils.getDate("2013-03-01 12:23:23", DateUtils.DEFAULT_DATE_TIME_FORMAT);
|
||||
end = DateUtils.getDate("2013-03-11 16:00:11", DateUtils.DEFAULT_DATE_TIME_FORMAT);
|
||||
System.out.println("Start [" + DateUtils.toDateTime(start) + "], End [" + DateUtils.toDateTime(end) + "]");
|
||||
|
||||
days = DateUtils.periodAsDays(start, end);
|
||||
System.out.println("Period: " + days);
|
||||
assertEquals(days, 10);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import com.google.zxing.*;
|
||||
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
import com.google.zxing.qrcode.QRCodeReader;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class DimensionalCodeHelperTest {
|
||||
|
||||
@Test
|
||||
public void encode() throws Exception {
|
||||
|
||||
File file = file();
|
||||
|
||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
|
||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||
BitMatrix encode = qrCodeWriter.encode("http://honyee.biz 宏义", BarcodeFormat.QR_CODE, 200, 200, hints);
|
||||
|
||||
assertNotNull(encode);
|
||||
MatrixToImageWriter.writeToFile(encode, "png", file);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decode() throws Exception {
|
||||
|
||||
File file = file();
|
||||
|
||||
QRCodeReader qrCodeReader = new QRCodeReader();
|
||||
|
||||
Map<DecodeHintType, Object> hints = new HashMap<>();
|
||||
hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
|
||||
|
||||
LuminanceSource source = new BufferedImageLuminanceSource(ImageIO.read(file));
|
||||
Binarizer binarizer = new HybridBinarizer(source);
|
||||
BinaryBitmap image = new BinaryBitmap(binarizer);
|
||||
|
||||
Result result = qrCodeReader.decode(image, hints);
|
||||
String text = result.getText();
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
private File file() throws IOException, URISyntaxException {
|
||||
Resource resource = new ClassPathResource("dim-code.png");
|
||||
return resource.getFile();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import cc.honyee.domain.shared.GuidGenerator;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class GuidTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void guid() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
String generate = GuidGenerator.generate();
|
||||
System.out.println(generate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class MD5Test {
|
||||
|
||||
|
||||
@Test
|
||||
public void encode() {
|
||||
Md5PasswordEncoder encoder = new Md5PasswordEncoder();
|
||||
String encode = encoder.encodePassword("honyee2013", null);
|
||||
System.out.println(encode);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class MatchUtilsTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void isEmail() {
|
||||
|
||||
boolean result = MatchUtils.isEmail("addd");
|
||||
assertFalse(result);
|
||||
|
||||
result = MatchUtils.isEmail("addd@honyee.cc");
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure.mybatis;
|
||||
|
||||
import cc.honyee.domain.oauth.OauthClientDetails;
|
||||
import cc.honyee.domain.oauth.OauthRepository;
|
||||
import cc.honyee.infrastructure.AbstractRepositoryTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class OauthRepositoryMyBatisTest extends AbstractRepositoryTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private OauthRepository oauthRepositoryMyBatis;
|
||||
|
||||
|
||||
@Test
|
||||
public void findOauthClientDetails() {
|
||||
OauthClientDetails oauthClientDetails = oauthRepositoryMyBatis.findOauthClientDetails("unity-client");
|
||||
assertNull(oauthClientDetails);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
||||
* www.honyee.biz
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
||||
* You shall not disclose such Confidential Information and shall use
|
||||
* it only in accordance with the terms of the license agreement you
|
||||
* entered into with Honyee Industry Group Co., Ltd.
|
||||
*/
|
||||
package cc.honyee.infrastructure.mybatis;
|
||||
|
||||
import cc.honyee.domain.user.User;
|
||||
import cc.honyee.domain.user.UserRepository;
|
||||
import cc.honyee.infrastructure.AbstractRepositoryTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.AssertJUnit.*;
|
||||
|
||||
/**
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
public class UserRepositoryMyBatisTest extends AbstractRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
|
||||
@Test
|
||||
public void findByGuid() {
|
||||
User user = userRepository.findByGuid("oood");
|
||||
assertNull(user);
|
||||
|
||||
user = new User("user", "123", "123", "ewo@honyee.cc");
|
||||
userRepository.saveUser(user);
|
||||
|
||||
user = userRepository.findByGuid(user.guid());
|
||||
assertNotNull(user);
|
||||
assertNotNull(user.email());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void updateUser() {
|
||||
User user = new User("user", "123", "123", "ewo@honyee.cc");
|
||||
userRepository.saveUser(user);
|
||||
|
||||
user = userRepository.findByGuid(user.guid());
|
||||
assertNotNull(user);
|
||||
assertNotNull(user.email());
|
||||
|
||||
String newEmail = "test@honyee.cc";
|
||||
user.email(newEmail).phone("12344444");
|
||||
userRepository.updateUser(user);
|
||||
|
||||
user = userRepository.findByGuid(user.guid());
|
||||
assertNotNull(user);
|
||||
assertEquals(user.email(), newEmail);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void findByUsername() {
|
||||
String username = "user";
|
||||
User user = new User(username, "123", "123", "ewo@honyee.cc");
|
||||
userRepository.saveUser(user);
|
||||
|
||||
User result = userRepository.findByUsername(username);
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#JDBC configuration information
|
||||
jdbc.driverClassName=com.mysql.jdbc.Driver
|
||||
############
|
||||
# localhost
|
||||
############
|
||||
jdbc.url=jdbc:mysql://localhost:3306/oauth2_test?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8
|
||||
jdbc.username=honyee
|
||||
jdbc.password=honyee
|
Binary file not shown.
After Width: | Height: | Size: 345 B |
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
|
||||
|
||||
<!-- property configuration -->
|
||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>classpath:database.properties</value>
|
||||
<!--<value>classpath:mail.properties</value>-->
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="${jdbc.driverClassName}"/>
|
||||
<property name="url" value="${jdbc.url}"/>
|
||||
<property name="username" value="${jdbc.username}"/>
|
||||
<property name="password" value="${jdbc.password}"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="configLocation" value="classpath:mybatis.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
|
||||
<constructor-arg index="0" ref="sqlSessionFactory"/>
|
||||
<constructor-arg index="1" value="BATCH"/>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||||
<property name="basePackage" value="cc.honyee.infrastructure.mybatis"/>
|
||||
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
|
||||
</bean>
|
||||
|
||||
<!--Mail configuration-->
|
||||
<!--<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">-->
|
||||
<!--<property name="host" value="${host.name}"/>-->
|
||||
<!--<property name="port" value="${mail.smtp.port}"/>-->
|
||||
<!--<property name="username" value="${mail.username}"/>-->
|
||||
<!--<property name="password" value="${mail.password}"/>-->
|
||||
|
||||
<!--<property name="defaultEncoding" value="UTF-8"/>-->
|
||||
<!--<property name="javaMailProperties">-->
|
||||
<!--<props>-->
|
||||
<!--<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>-->
|
||||
<!--</props>-->
|
||||
<!--</property>-->
|
||||
<!--</bean>-->
|
||||
|
||||
|
||||
</beans>
|
Loading…
Reference in New Issue