diff --git a/Java.gitignore b/Java.gitignore index 0f182a0349c4925c57f4ffbd5802b536a3e2588b..1f78fda3921459610bd010cd0bfe77c417179198 100644 --- a/Java.gitignore +++ b/Java.gitignore @@ -4,3 +4,4 @@ *.jar *.war *.ear +*.iml diff --git a/authz-jdbc/authz-jdbc.iml b/authz-jdbc/authz-jdbc.iml new file mode 100644 index 0000000000000000000000000000000000000000..7fe4f0bd3d7494ef1f90d394a3bd25b854cfcdaa --- /dev/null +++ b/authz-jdbc/authz-jdbc.iml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/authz-jdbc/pom.xml b/authz-jdbc/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ccbbe05b40acb257008654547357717a42d73b14 --- /dev/null +++ b/authz-jdbc/pom.xml @@ -0,0 +1,240 @@ + + + 4.0.0 + + com.monkeyk + authz-jdbc + 0.3 + + ${project.artifactId} + war + oltu and shiro [AUTHZ] + + + UTF-8 + + 3.2.2.RELEASE + 1.6.12 + + 5.1.35 + 1.0.2 + 1.2.3 + 2.5.4 + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/oauth2_shiro_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8 + andaily + andaily + + + false + + + + + authz + + + + maven-compiler-plugin + 3.2 + + 1.7 + 1.7 + UTF-8 + + + + + maven-war-plugin + 2.6 + + */classes/authz.properties + */classes/authz.properties + + false + + ${project.version} + monkeyk.com + monkeyk.com + ${project.name} + ${project.version} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + maven-surefire-plugin + 2.4 + + ${test.skip} + none + + **/*Test.java + + + + jdbc.url + ${jdbc.url} + + + jdbc.username + ${jdbc.user} + + + jdbc.password + ${jdbc.pass} + + + + + + + + + src/main/resources + + **/* + + + + + + + + + + src/test/resources + + **/* + + + + + + + + + com.monkeyk + authz + 0.3 + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + + + commons-dbcp + commons-dbcp + 1.4 + + + + + + mysql + mysql-connector-java + ${mysql.version} + compile + + + + + javax.servlet + jstl + 1.1.2 + + + taglibs + standard + 1.1.2 + compile + + + + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml.jackson.version} + + + + + + org.springframework + spring-test + ${spring.version} + test + + + org.testng + testng + 6.1.1 + test + + + junit + junit + + + + + + + \ No newline at end of file diff --git a/authz/src/main/java/com/monkeyk/os/domain/users/PasswordHandler.java b/authz-jdbc/src/main/java/com/monkeyk/os/domain/users/PasswordHandler.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/domain/users/PasswordHandler.java rename to authz-jdbc/src/main/java/com/monkeyk/os/domain/users/PasswordHandler.java diff --git a/authz/src/main/java/com/monkeyk/os/domain/users/UsersAuthzRepository.java b/authz-jdbc/src/main/java/com/monkeyk/os/domain/users/UsersAuthzRepository.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/domain/users/UsersAuthzRepository.java rename to authz-jdbc/src/main/java/com/monkeyk/os/domain/users/UsersAuthzRepository.java diff --git a/authz/src/main/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepository.java b/authz-jdbc/src/main/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepository.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepository.java rename to authz-jdbc/src/main/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepository.java diff --git a/authz/src/main/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepository.java b/authz-jdbc/src/main/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepository.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepository.java rename to authz-jdbc/src/main/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepository.java diff --git a/authz/src/main/java/com/monkeyk/os/service/ClientDetailsService.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/ClientDetailsService.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/ClientDetailsService.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/ClientDetailsService.java diff --git a/authz/src/main/java/com/monkeyk/os/service/UserService.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/UserService.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/UserService.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/UserService.java diff --git a/authz/src/main/java/com/monkeyk/os/service/business/ClientDetailsFormSaver.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/business/ClientDetailsFormSaver.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/business/ClientDetailsFormSaver.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/business/ClientDetailsFormSaver.java diff --git a/authz/src/main/java/com/monkeyk/os/service/business/UsersFormDtoLoader.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/business/UsersFormDtoLoader.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/business/UsersFormDtoLoader.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/business/UsersFormDtoLoader.java diff --git a/authz/src/main/java/com/monkeyk/os/service/business/UsersFormSaver.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/business/UsersFormSaver.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/business/UsersFormSaver.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/business/UsersFormSaver.java diff --git a/authz/src/main/java/com/monkeyk/os/service/dto/ClientDetailsFormDto.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/dto/ClientDetailsFormDto.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/dto/ClientDetailsFormDto.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/dto/ClientDetailsFormDto.java diff --git a/authz/src/main/java/com/monkeyk/os/service/dto/ClientDetailsListDto.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/dto/ClientDetailsListDto.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/dto/ClientDetailsListDto.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/dto/ClientDetailsListDto.java diff --git a/authz/src/main/java/com/monkeyk/os/service/dto/RolesDto.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/dto/RolesDto.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/dto/RolesDto.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/dto/RolesDto.java diff --git a/authz/src/main/java/com/monkeyk/os/service/dto/UsersDto.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/dto/UsersDto.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/dto/UsersDto.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/dto/UsersDto.java diff --git a/authz/src/main/java/com/monkeyk/os/service/dto/UsersFormDto.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/dto/UsersFormDto.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/dto/UsersFormDto.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/dto/UsersFormDto.java diff --git a/authz/src/main/java/com/monkeyk/os/service/dto/UsersOverviewDto.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/dto/UsersOverviewDto.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/dto/UsersOverviewDto.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/dto/UsersOverviewDto.java diff --git a/authz/src/main/java/com/monkeyk/os/service/impl/ClientDetailsServiceImpl.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/impl/ClientDetailsServiceImpl.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/impl/ClientDetailsServiceImpl.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/impl/ClientDetailsServiceImpl.java diff --git a/authz/src/main/java/com/monkeyk/os/service/impl/Readme.txt b/authz-jdbc/src/main/java/com/monkeyk/os/service/impl/Readme.txt similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/impl/Readme.txt rename to authz-jdbc/src/main/java/com/monkeyk/os/service/impl/Readme.txt diff --git a/authz/src/main/java/com/monkeyk/os/service/impl/UserServiceImpl.java b/authz-jdbc/src/main/java/com/monkeyk/os/service/impl/UserServiceImpl.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/service/impl/UserServiceImpl.java rename to authz-jdbc/src/main/java/com/monkeyk/os/service/impl/UserServiceImpl.java diff --git a/authz/src/main/java/com/monkeyk/os/web/controller/ClientDetailsController.java b/authz-jdbc/src/main/java/com/monkeyk/os/web/controller/ClientDetailsController.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/web/controller/ClientDetailsController.java rename to authz-jdbc/src/main/java/com/monkeyk/os/web/controller/ClientDetailsController.java diff --git a/authz/src/main/java/com/monkeyk/os/web/controller/ClientDetailsFormDtoValidator.java b/authz-jdbc/src/main/java/com/monkeyk/os/web/controller/ClientDetailsFormDtoValidator.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/web/controller/ClientDetailsFormDtoValidator.java rename to authz-jdbc/src/main/java/com/monkeyk/os/web/controller/ClientDetailsFormDtoValidator.java diff --git a/authz/src/main/java/com/monkeyk/os/web/controller/OauthAuthorizeController.java b/authz-jdbc/src/main/java/com/monkeyk/os/web/controller/OauthAuthorizeController.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/web/controller/OauthAuthorizeController.java rename to authz-jdbc/src/main/java/com/monkeyk/os/web/controller/OauthAuthorizeController.java diff --git a/authz/src/main/java/com/monkeyk/os/web/controller/ShiroController.java b/authz-jdbc/src/main/java/com/monkeyk/os/web/controller/ShiroController.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/web/controller/ShiroController.java rename to authz-jdbc/src/main/java/com/monkeyk/os/web/controller/ShiroController.java diff --git a/authz/src/main/java/com/monkeyk/os/web/controller/UsersController.java b/authz-jdbc/src/main/java/com/monkeyk/os/web/controller/UsersController.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/web/controller/UsersController.java rename to authz-jdbc/src/main/java/com/monkeyk/os/web/controller/UsersController.java diff --git a/authz/src/main/java/com/monkeyk/os/web/controller/UsersFormDtoValidator.java b/authz-jdbc/src/main/java/com/monkeyk/os/web/controller/UsersFormDtoValidator.java similarity index 100% rename from authz/src/main/java/com/monkeyk/os/web/controller/UsersFormDtoValidator.java rename to authz-jdbc/src/main/java/com/monkeyk/os/web/controller/UsersFormDtoValidator.java diff --git a/authz-jdbc/src/main/resources/authz.properties b/authz-jdbc/src/main/resources/authz.properties new file mode 100644 index 0000000000000000000000000000000000000000..cd713f164d872a899d2daa01f71ce54879f366fd --- /dev/null +++ b/authz-jdbc/src/main/resources/authz.properties @@ -0,0 +1,15 @@ + +# Êý¾Ý¿âÁ¬½ÓÅäÖà +##JDBC configuration information +#jdbc.driverClassName=com.mysql.jdbc.Driver +############# +## localhost +############# +#jdbc.url=jdbc:mysql://localhost:3306/oauth2_shiro?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8 +#jdbc.username=andaily +#jdbc.password=andaily + +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://10.100.249.142:3306/oauth2_shiro?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true +jdbc.username=root +jdbc.password=wuhan \ No newline at end of file diff --git a/authz/src/main/resources/logging.properties b/authz-jdbc/src/main/resources/logging.properties similarity index 100% rename from authz/src/main/resources/logging.properties rename to authz-jdbc/src/main/resources/logging.properties diff --git a/authz-jdbc/src/main/resources/rebel.xml b/authz-jdbc/src/main/resources/rebel.xml new file mode 100644 index 0000000000000000000000000000000000000000..4ca5e5a6b99a4991c096b11fbd69cabec91b6a8f --- /dev/null +++ b/authz-jdbc/src/main/resources/rebel.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/authz/src/main/resources/spring/authz-context.xml b/authz-jdbc/src/main/resources/spring/authz-context.xml similarity index 100% rename from authz/src/main/resources/spring/authz-context.xml rename to authz-jdbc/src/main/resources/spring/authz-context.xml diff --git a/authz/src/main/resources/spring/authz-security.xml b/authz-jdbc/src/main/resources/spring/authz-security.xml similarity index 100% rename from authz/src/main/resources/spring/authz-security.xml rename to authz-jdbc/src/main/resources/spring/authz-security.xml diff --git a/authz/src/main/webapp/WEB-INF/decorators.xml b/authz-jdbc/src/main/webapp/WEB-INF/decorators.xml similarity index 100% rename from authz/src/main/webapp/WEB-INF/decorators.xml rename to authz-jdbc/src/main/webapp/WEB-INF/decorators.xml diff --git a/authz/src/main/webapp/WEB-INF/jsp/comm-header.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/comm-header.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/comm-header.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/comm-header.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/decorators/main.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/decorators/main.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/decorators/main.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/decorators/main.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/index.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/index.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/login.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/login.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/login.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/login.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/oauth/client_details.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/client_details.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/oauth/client_details.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/client_details.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/oauth/client_details_plus.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/client_details_plus.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/oauth/client_details_plus.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/client_details_plus.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/oauth/oauth_approval.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/oauth_approval.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/oauth/oauth_approval.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/oauth_approval.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/oauth/oauth_login.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/oauth_login.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/oauth/oauth_login.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/oauth_login.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/oauth/test_client.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/test_client.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/oauth/test_client.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/oauth/test_client.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/unauthorized.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/unauthorized.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/unauthorized.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/unauthorized.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/users/user_plus.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/users/user_plus.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/users/user_plus.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/users/user_plus.jsp diff --git a/authz/src/main/webapp/WEB-INF/jsp/users/users_overview.jsp b/authz-jdbc/src/main/webapp/WEB-INF/jsp/users/users_overview.jsp similarity index 100% rename from authz/src/main/webapp/WEB-INF/jsp/users/users_overview.jsp rename to authz-jdbc/src/main/webapp/WEB-INF/jsp/users/users_overview.jsp diff --git a/authz/src/main/webapp/WEB-INF/log4j.xml b/authz-jdbc/src/main/webapp/WEB-INF/log4j.xml similarity index 100% rename from authz/src/main/webapp/WEB-INF/log4j.xml rename to authz-jdbc/src/main/webapp/WEB-INF/log4j.xml diff --git a/authz/src/main/webapp/WEB-INF/mkk-servlet.xml b/authz-jdbc/src/main/webapp/WEB-INF/mkk-servlet.xml similarity index 100% rename from authz/src/main/webapp/WEB-INF/mkk-servlet.xml rename to authz-jdbc/src/main/webapp/WEB-INF/mkk-servlet.xml diff --git a/authz-jdbc/src/main/webapp/WEB-INF/web.xml b/authz-jdbc/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..a0b58fd42a98ab23ed9561a991b01bdc629feab1 --- /dev/null +++ b/authz-jdbc/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/authz/src/main/webapp/favicon.ico b/authz-jdbc/src/main/webapp/favicon.ico similarity index 100% rename from authz/src/main/webapp/favicon.ico rename to authz-jdbc/src/main/webapp/favicon.ico diff --git a/authz/src/main/webapp/loading.jsp b/authz-jdbc/src/main/webapp/loading.jsp similarity index 100% rename from authz/src/main/webapp/loading.jsp rename to authz-jdbc/src/main/webapp/loading.jsp diff --git a/authz/src/main/webapp/resources/OS_API-0.2.html b/authz-jdbc/src/main/webapp/resources/OS_API-0.2.html similarity index 100% rename from authz/src/main/webapp/resources/OS_API-0.2.html rename to authz-jdbc/src/main/webapp/resources/OS_API-0.2.html diff --git a/authz/src/main/webapp/resources/OS_API-0.3.html b/authz-jdbc/src/main/webapp/resources/OS_API-0.3.html similarity index 100% rename from authz/src/main/webapp/resources/OS_API-0.3.html rename to authz-jdbc/src/main/webapp/resources/OS_API-0.3.html diff --git a/authz/src/main/webapp/resources/angular.min.js b/authz-jdbc/src/main/webapp/resources/angular.min.js similarity index 100% rename from authz/src/main/webapp/resources/angular.min.js rename to authz-jdbc/src/main/webapp/resources/angular.min.js diff --git a/authz/src/main/webapp/resources/bootstrap.min.css b/authz-jdbc/src/main/webapp/resources/bootstrap.min.css similarity index 100% rename from authz/src/main/webapp/resources/bootstrap.min.css rename to authz-jdbc/src/main/webapp/resources/bootstrap.min.css diff --git a/authz/src/main/webapp/resources/oauth_test.html b/authz-jdbc/src/main/webapp/resources/oauth_test.html similarity index 100% rename from authz/src/main/webapp/resources/oauth_test.html rename to authz-jdbc/src/main/webapp/resources/oauth_test.html diff --git a/authz/src/main/webapp/resources/readme.txt b/authz-jdbc/src/main/webapp/resources/readme.txt similarity index 100% rename from authz/src/main/webapp/resources/readme.txt rename to authz-jdbc/src/main/webapp/resources/readme.txt diff --git a/authz/pom.xml b/authz/pom.xml index 2403de257fe4eb3048a6a94c7ccc8d846e4a22c9..d0cb4dfe8138cb0eb6a3ef223e672e3ecce26f92 100644 --- a/authz/pom.xml +++ b/authz/pom.xml @@ -9,7 +9,7 @@ 0.3 ${project.artifactId} - war + jar oltu and shiro [AUTHZ] @@ -22,15 +22,6 @@ 1.0.2 1.2.3 2.5.4 - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/oauth2_shiro_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8 - andaily - andaily - - - false @@ -48,89 +39,6 @@ - - maven-war-plugin - 2.6 - - */classes/authz.properties - */classes/authz.properties - - false - - ${project.version} - monkeyk.com - monkeyk.com - ${project.name} - ${project.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - maven-surefire-plugin - 2.4 - - ${test.skip} - none - - **/*Test.java - - - - jdbc.url - ${jdbc.url} - - - jdbc.username - ${jdbc.user} - - - jdbc.password - ${jdbc.pass} - - - - @@ -202,12 +110,6 @@ compile - - commons-dbcp - commons-dbcp - 1.4 - - commons-io commons-io @@ -264,15 +166,6 @@ ${spring.version} - - - mysql - mysql-connector-java - ${mysql.version} - compile - - - log4j diff --git a/authz/src/main/webapp/WEB-INF/web.xml b/authz/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 3c11874861031e17ac0f841b2c9a085f2d428ad8..0000000000000000000000000000000000000000 --- a/authz/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - oauth2-shiro - - - - - - - webAppRootKey - oauth2-shiro - - - - - encodingFilter - com.monkeyk.os.web.context.MkkCharacterEncodingFilter - - encoding - UTF-8 - - - forceEncoding - true - - - - encodingFilter - /* - - - - - gzipFilter - - net.sf.ehcache.constructs.web.filter.GzipFilter - - - - gzipFilter - *.css - - - gzipFilter - *.png - - - gzipFilter - *.gif - - - gzipFilter - *.html - - - gzipFilter - *.js - - - - - - shiroFilter - org.springframework.web.filter.DelegatingFilterProxy - - targetFilterLifecycle - true - - - - - shiroFilter - /* - - - - - - sitemesh - com.opensymphony.sitemesh.webapp.SiteMeshFilter - - - sitemesh - /* - - - - ico - image/vnd.microsoft.icon - - - - - contextConfigLocation - classpath:spring/*.xml - - - - - log4jConfigLocation - /WEB-INF/log4j.xml - - - org.springframework.web.util.Log4jConfigListener - - - - - - com.monkeyk.os.web.context.BeanContextLoaderListener - - - - - mkk - org.springframework.web.servlet.DispatcherServlet - 2 - - - mkk - / - - - - - - - - - - - 30 - - - - - loading.jsp - - - - \ No newline at end of file diff --git a/authz/src/test/java/com/monkeyk/os/domain/users/PasswordHandlerTest.java b/authz/src/test/java/com/monkeyk/os/domain/users/PasswordHandlerTest.java deleted file mode 100644 index eeb19507c7e2b598362919e86672f24a8dc779a6..0000000000000000000000000000000000000000 --- a/authz/src/test/java/com/monkeyk/os/domain/users/PasswordHandlerTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.monkeyk.os.domain.users; - -import org.testng.annotations.Test; - -import static org.testng.Assert.*; - -/* - * @author Shengzhao Li - */ -public class PasswordHandlerTest { - - @Test - public void testMd5() throws Exception { - - - final String admin = PasswordHandler.md5("admin"); - assertNotNull(admin); - assertEquals(admin, "21232f297a57a5a743894a0e4a801fc3"); - - - final String test = PasswordHandler.md5("test"); - assertNotNull(test); - assertEquals(test, "098f6bcd4621d373cade4e832627b4f6"); - } -} \ No newline at end of file diff --git a/authz/src/test/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepositoryTest.java b/authz/src/test/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepositoryTest.java deleted file mode 100644 index 5d32145e0da142994bca8c47fe372d5b338b1f8d..0000000000000000000000000000000000000000 --- a/authz/src/test/java/com/monkeyk/os/infrastructure/jdbc/OauthJdbcRepositoryTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.monkeyk.os.infrastructure.jdbc; - -import com.monkeyk.os.ContextTest; -import com.monkeyk.os.domain.oauth.AccessToken; -import com.monkeyk.os.domain.oauth.ClientDetails; -import com.monkeyk.os.domain.oauth.OauthCode; -import com.monkeyk.os.domain.shared.GuidGenerator; -import org.apache.oltu.oauth2.as.issuer.MD5Generator; -import org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.testng.Assert.*; - -/** - * 15-6-13 - * - * @author Shengzhao Li - */ -public class OauthJdbcRepositoryTest extends ContextTest { - - @Autowired - private OauthJdbcRepository oauthJdbcRepository; - - @Test - public void testFindClientDetails() throws Exception { - String clientId = "oaoedd"; - final ClientDetails clientDetails = oauthJdbcRepository.findClientDetails(clientId); - assertNull(clientDetails); - - ClientDetails clientDetails1 = new ClientDetails(); - clientDetails1.setClientId(clientId); - clientDetails1.setClientSecret("Ole397dde2"); - - final int i = oauthJdbcRepository.saveClientDetails(clientDetails1); - assertEquals(i, 1); - - final ClientDetails clientDetails2 = oauthJdbcRepository.findClientDetails(clientId); - assertNotNull(clientDetails2); - assertNotNull(clientDetails2.getClientId()); - - } - - - @Test - public void findAccessTokenByRefreshToken() throws Exception { - String clientId = "oaoedd"; - String refreshToken = GuidGenerator.generate(); - - final AccessToken accessToken = oauthJdbcRepository.findAccessTokenByRefreshToken(refreshToken, clientId); - assertNull(accessToken); - - } - - - @Test - public void findClientDetailsListByClientId() throws Exception { - String clientId = "oaoedd"; - final List list = oauthJdbcRepository.findClientDetailsListByClientId(clientId); - assertTrue(list.isEmpty()); - - } - - - @Test - public void saveOauthCode() throws Exception { - - final OAuthIssuerImpl oAuthIssuer = new OAuthIssuerImpl(new MD5Generator()); - OauthCode oauthCode = new OauthCode() - .username("test") - .code(oAuthIssuer.authorizationCode()) - .clientId("client+id"); - oauthJdbcRepository.saveOauthCode(oauthCode); - - - final OauthCode oauthCode1 = oauthJdbcRepository.findOauthCode(oauthCode.code(), oauthCode.clientId()); - assertNotNull(oauthCode1); - assertNotNull(oauthCode1.code()); - assertNotNull(oauthCode1.username()); - System.out.println(oauthCode1.code()); - - final OauthCode oauthCode2 = oauthJdbcRepository.findOauthCodeByUsernameClientId(oauthCode.username(), oauthCode.clientId()); - assertNotNull(oauthCode2); - - - final int i = oauthJdbcRepository.deleteOauthCode(oauthCode); - assertEquals(i, 1); - - final OauthCode oauthCode3 = oauthJdbcRepository.findOauthCodeByUsernameClientId("add", "ddood"); - assertNull(oauthCode3); - } - - - @Test - public void findAccessToken() { - - final AccessToken accessToken = oauthJdbcRepository.findAccessToken("client_id", "username", "authid"); - assertNull(accessToken); - - } - - - @Test - public void deleteAccessToken() { - AccessToken accessToken = new AccessToken() - .username("user") - .authenticationId("auted") - .clientId("client"); - oauthJdbcRepository.deleteAccessToken(accessToken); - } - - @Test - public void saveAccessToken() { - AccessToken accessToken = new AccessToken() - .username("user") - .authenticationId("auted") - .clientId("client"); - final int i = oauthJdbcRepository.saveAccessToken(accessToken); - assertEquals(i, 1); - } - -} diff --git a/authz/src/test/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepositoryTest.java b/authz/src/test/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepositoryTest.java deleted file mode 100644 index 04b6406bd8c204df2365b842b1d99e78d3b43143..0000000000000000000000000000000000000000 --- a/authz/src/test/java/com/monkeyk/os/infrastructure/jdbc/UsersJdbcAuthzRepositoryTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2015 MONKEYK Information Technology Co. Ltd - * www.monkeyk.com - * All rights reserved. - * - * This software is the confidential and proprietary information of - * MONKEYK Information Technology 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 MONKEYK Information Technology Co. Ltd. - */ -package com.monkeyk.os.infrastructure.jdbc; - -import com.monkeyk.os.ContextTest; -import com.monkeyk.os.domain.shared.GuidGenerator; -import com.monkeyk.os.domain.users.Roles; -import com.monkeyk.os.domain.users.Users; -import org.springframework.beans.factory.annotation.Autowired; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.testng.Assert.*; - -/* - * @author Shengzhao Li - */ -public class UsersJdbcAuthzRepositoryTest extends ContextTest { - - - @Autowired - private UsersJdbcAuthzRepository usersJdbcRepository; - - @Test - public void testFindUsersByUsername() throws Exception { - - List list = usersJdbcRepository.findUsersByUsername("user"); - assertNotNull(list); - assertTrue(list.isEmpty()); - - list = usersJdbcRepository.findUsersByUsername(""); - assertNotNull(list); - assertTrue(list.isEmpty()); - - list = usersJdbcRepository.findUsersByUsername(null); - assertNotNull(list); - assertTrue(list.isEmpty()); - } - - - @Test - public void findUsersRolesList() throws Exception { - - final List list = usersJdbcRepository.findUsersRolesList(GuidGenerator.generate()); - assertNotNull(list); - assertTrue(list.isEmpty()); - } - - - @Test - public void findByUsername() throws Exception { - - final Users users = usersJdbcRepository.findByUsername("lise"); - assertNull(users); - } - - @Test - public void saveUsers() throws Exception { - - final Users users = new Users().username("test").password("paeddsf").guid(GuidGenerator.generate()); - final int id = usersJdbcRepository.saveUsers(users); - - assertTrue(id > 0); - - } - - - @Test - public void findAvailableRolesList() throws Exception { - - final List list = usersJdbcRepository.findAvailableRolesList(); - assertNotNull(list); - assertTrue(list.isEmpty()); - } - - - @Test - public void insertUserRoles() throws Exception { - - usersJdbcRepository.insertUserRoles(23, 434); - } - - @Test - public void findRolesByGuid() throws Exception { - - final Roles roles = usersJdbcRepository.findRolesByGuid(GuidGenerator.generate()); - assertNull(roles); - - } - - @Test - public void findPermissionsByRoles() throws Exception { - - final List list = usersJdbcRepository.findPermissionsByRoles(GuidGenerator.generate()); - assertNotNull(list); - assertTrue(list.isEmpty()); - } - - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index a7c1c15f1f3479e935fbf2564ef3434dbf6af0d3..8e4f9071184c3a5e001d7eb35a23d667cc909ee3 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,8 @@ core authz resources + authz-jdbc + resources-jdbc diff --git a/resources-jdbc/pom.xml b/resources-jdbc/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..00b151bd81376762d886a41b732203ea97067bb7 --- /dev/null +++ b/resources-jdbc/pom.xml @@ -0,0 +1,229 @@ + + + 4.0.0 + + com.monkeyk + resources-jdbc + 0.3 + + ${project.artifactId} + war + oltu and shiro [RESOURCES] + + + UTF-8 + + 3.2.2.RELEASE + 1.6.12 + + 5.1.35 + 1.0.2 + 1.2.3 + 2.5.4 + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/oauth2_shiro_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8 + andaily + andaily + + + false + + + + rs + + + + maven-compiler-plugin + 3.2 + + 1.7 + 1.7 + UTF-8 + + + + + maven-war-plugin + 2.6 + + */classes/resources.properties + */classes/resources.properties + + false + + ${project.version} + monkeyk.com + monkeyk.com + ${project.name} + ${project.version} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + maven-surefire-plugin + 2.4 + + ${test.skip} + none + + **/*Test.java + + + + jdbc.url + ${jdbc.url} + + + jdbc.username + ${jdbc.user} + + + jdbc.password + ${jdbc.pass} + + + + + + + + + src/main/resources + + **/* + + + + + + + + + + src/test/resources + + **/* + + + + + + + + com.monkeyk + resources + 0.3 + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + + + commons-dbcp + commons-dbcp + 1.4 + + + + + mysql + mysql-connector-java + ${mysql.version} + compile + + + + + javax.servlet + jstl + 1.1.2 + + + taglibs + standard + 1.1.2 + compile + + + + + org.springframework + spring-test + ${spring.version} + test + + + org.testng + testng + 6.1.1 + test + + + junit + junit + + + + + + + + \ No newline at end of file diff --git a/resources-jdbc/resources-jdbc.iml b/resources-jdbc/resources-jdbc.iml new file mode 100644 index 0000000000000000000000000000000000000000..8374f58d38e515555ddf466c49c3fc84a150fb32 --- /dev/null +++ b/resources-jdbc/resources-jdbc.iml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/src/main/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepository.java b/resources-jdbc/src/main/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepository.java similarity index 100% rename from resources/src/main/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepository.java rename to resources-jdbc/src/main/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepository.java diff --git a/resources/src/main/java/com/monkeyk/os/oauth/shiro/OAuth2JdbcRealm.java b/resources-jdbc/src/main/java/com/monkeyk/os/oauth/shiro/OAuth2JdbcRealm.java similarity index 100% rename from resources/src/main/java/com/monkeyk/os/oauth/shiro/OAuth2JdbcRealm.java rename to resources-jdbc/src/main/java/com/monkeyk/os/oauth/shiro/OAuth2JdbcRealm.java diff --git a/resources/src/main/java/com/monkeyk/os/oauth/shiro/README.txt b/resources-jdbc/src/main/java/com/monkeyk/os/oauth/shiro/README.txt similarity index 100% rename from resources/src/main/java/com/monkeyk/os/oauth/shiro/README.txt rename to resources-jdbc/src/main/java/com/monkeyk/os/oauth/shiro/README.txt diff --git a/resources/src/main/java/com/monkeyk/os/service/dto/SystemTimeDto.java b/resources-jdbc/src/main/java/com/monkeyk/os/service/dto/SystemTimeDto.java similarity index 100% rename from resources/src/main/java/com/monkeyk/os/service/dto/SystemTimeDto.java rename to resources-jdbc/src/main/java/com/monkeyk/os/service/dto/SystemTimeDto.java diff --git a/resources/src/main/java/com/monkeyk/os/service/dto/UsernameDto.java b/resources-jdbc/src/main/java/com/monkeyk/os/service/dto/UsernameDto.java similarity index 100% rename from resources/src/main/java/com/monkeyk/os/service/dto/UsernameDto.java rename to resources-jdbc/src/main/java/com/monkeyk/os/service/dto/UsernameDto.java diff --git a/resources/src/main/java/com/monkeyk/os/service/impl/Readme.txt b/resources-jdbc/src/main/java/com/monkeyk/os/service/impl/Readme.txt similarity index 100% rename from resources/src/main/java/com/monkeyk/os/service/impl/Readme.txt rename to resources-jdbc/src/main/java/com/monkeyk/os/service/impl/Readme.txt diff --git a/resources/src/main/java/com/monkeyk/os/web/controller/MobileResourcesController.java b/resources-jdbc/src/main/java/com/monkeyk/os/web/controller/MobileResourcesController.java similarity index 100% rename from resources/src/main/java/com/monkeyk/os/web/controller/MobileResourcesController.java rename to resources-jdbc/src/main/java/com/monkeyk/os/web/controller/MobileResourcesController.java diff --git a/resources/src/main/java/com/monkeyk/os/web/controller/OauthResourcesController.java b/resources-jdbc/src/main/java/com/monkeyk/os/web/controller/OauthResourcesController.java similarity index 100% rename from resources/src/main/java/com/monkeyk/os/web/controller/OauthResourcesController.java rename to resources-jdbc/src/main/java/com/monkeyk/os/web/controller/OauthResourcesController.java diff --git a/resources/src/main/resources/logging.properties b/resources-jdbc/src/main/resources/logging.properties similarity index 100% rename from resources/src/main/resources/logging.properties rename to resources-jdbc/src/main/resources/logging.properties diff --git a/resources-jdbc/src/main/resources/rebel.xml b/resources-jdbc/src/main/resources/rebel.xml new file mode 100644 index 0000000000000000000000000000000000000000..cbf04b32206a4155172b339e3e848c59462f1198 --- /dev/null +++ b/resources-jdbc/src/main/resources/rebel.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/src/main/resources/resources.properties b/resources-jdbc/src/main/resources/resources.properties similarity index 48% rename from resources/src/main/resources/resources.properties rename to resources-jdbc/src/main/resources/resources.properties index 9280944fb4a5de3f98a3a91293d97a763c210910..4fa62427fc95254cc16c5d64665569894eda4cc1 100644 --- a/resources/src/main/resources/resources.properties +++ b/resources-jdbc/src/main/resources/resources.properties @@ -5,10 +5,7 @@ # #JDBC configuration information jdbc.driverClassName=com.mysql.jdbc.Driver -############ -# MySQL DB -############ -jdbc.url=jdbc:mysql://localhost:3306/oauth2_shiro?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8 -jdbc.username=andaily -jdbc.password=andaily +jdbc.url=jdbc:mysql://10.100.249.142:3306/oauth2_shiro?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true +jdbc.username=root +jdbc.password=wuhan diff --git a/resources/src/main/resources/spring/rs-context.xml b/resources-jdbc/src/main/resources/spring/rs-context.xml similarity index 100% rename from resources/src/main/resources/spring/rs-context.xml rename to resources-jdbc/src/main/resources/spring/rs-context.xml diff --git a/resources/src/main/resources/spring/rs-security.xml b/resources-jdbc/src/main/resources/spring/rs-security.xml similarity index 100% rename from resources/src/main/resources/spring/rs-security.xml rename to resources-jdbc/src/main/resources/spring/rs-security.xml diff --git a/resources/src/main/webapp/WEB-INF/log4j.xml b/resources-jdbc/src/main/webapp/WEB-INF/log4j.xml similarity index 100% rename from resources/src/main/webapp/WEB-INF/log4j.xml rename to resources-jdbc/src/main/webapp/WEB-INF/log4j.xml diff --git a/resources/src/main/webapp/WEB-INF/mkk-servlet.xml b/resources-jdbc/src/main/webapp/WEB-INF/mkk-servlet.xml similarity index 100% rename from resources/src/main/webapp/WEB-INF/mkk-servlet.xml rename to resources-jdbc/src/main/webapp/WEB-INF/mkk-servlet.xml diff --git a/resources/src/main/webapp/WEB-INF/web.xml b/resources-jdbc/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from resources/src/main/webapp/WEB-INF/web.xml rename to resources-jdbc/src/main/webapp/WEB-INF/web.xml diff --git a/resources/src/main/webapp/favicon.ico b/resources-jdbc/src/main/webapp/favicon.ico similarity index 100% rename from resources/src/main/webapp/favicon.ico rename to resources-jdbc/src/main/webapp/favicon.ico diff --git a/resources/src/main/webapp/loading.jsp b/resources-jdbc/src/main/webapp/loading.jsp similarity index 100% rename from resources/src/main/webapp/loading.jsp rename to resources-jdbc/src/main/webapp/loading.jsp diff --git a/resources/src/main/webapp/static/OS_API-0.2.html b/resources-jdbc/src/main/webapp/static/OS_API-0.2.html similarity index 100% rename from resources/src/main/webapp/static/OS_API-0.2.html rename to resources-jdbc/src/main/webapp/static/OS_API-0.2.html diff --git a/resources/src/main/webapp/static/OS_API-0.3.html b/resources-jdbc/src/main/webapp/static/OS_API-0.3.html similarity index 100% rename from resources/src/main/webapp/static/OS_API-0.3.html rename to resources-jdbc/src/main/webapp/static/OS_API-0.3.html diff --git a/resources/src/main/webapp/static/bootstrap.min.css b/resources-jdbc/src/main/webapp/static/bootstrap.min.css similarity index 100% rename from resources/src/main/webapp/static/bootstrap.min.css rename to resources-jdbc/src/main/webapp/static/bootstrap.min.css diff --git a/resources-jdbc/src/test/java/com/monkeyk/os/ContextTest.java b/resources-jdbc/src/test/java/com/monkeyk/os/ContextTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8a6ac84a439f2b7e629232d65e2d52d0d5fd6fce --- /dev/null +++ b/resources-jdbc/src/test/java/com/monkeyk/os/ContextTest.java @@ -0,0 +1,19 @@ +package com.monkeyk.os; + +import com.monkeyk.os.domain.shared.BeanProvider; +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:/spring/*.xml"}, initializers = {TestApplicationContextInitializer.class}) +public abstract class ContextTest extends AbstractTransactionalTestNGSpringContextTests { + + + @BeforeTransaction + public void before() throws Exception { + BeanProvider.initialize(applicationContext); + } +} \ No newline at end of file diff --git a/resources-jdbc/src/test/java/com/monkeyk/os/TestApplicationContextInitializer.java b/resources-jdbc/src/test/java/com/monkeyk/os/TestApplicationContextInitializer.java new file mode 100644 index 0000000000000000000000000000000000000000..e884f289fe55fca2b40c69eb2c45abf2895bbeb8 --- /dev/null +++ b/resources-jdbc/src/test/java/com/monkeyk/os/TestApplicationContextInitializer.java @@ -0,0 +1,23 @@ +package com.monkeyk.os; + +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.core.io.ClassPathResource; + +/** + * @author Shengzhao Li + */ +public class TestApplicationContextInitializer implements ApplicationContextInitializer { + + @Override + public void initialize(AbstractApplicationContext applicationContext) { + PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer(); + //load database.properties + propertyPlaceholderConfigurer.setLocation(new ClassPathResource("test.properties")); + + applicationContext.addBeanFactoryPostProcessor(propertyPlaceholderConfigurer); + + + } +} \ No newline at end of file diff --git a/resources-jdbc/src/test/java/com/monkeyk/os/domain/oauth/AccessTokenTest.java b/resources-jdbc/src/test/java/com/monkeyk/os/domain/oauth/AccessTokenTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0ab92735402de89bf0611647f9cf8c3178d5cd0e --- /dev/null +++ b/resources-jdbc/src/test/java/com/monkeyk/os/domain/oauth/AccessTokenTest.java @@ -0,0 +1,53 @@ +package com.monkeyk.os.domain.oauth; + +import com.monkeyk.os.infrastructure.DateUtils; +import org.testng.annotations.Test; + +import java.net.URLDecoder; +import java.net.URLEncoder; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +/** + * @author Shengzhao Li + */ +public class AccessTokenTest { + + + @Test + public void decode() throws Exception { + + String url = "http://localhost:7777/spring-oauth-client/authorization_code_callback"; + final String decode = URLEncoder.encode(url, "UTF-8"); + System.out.println(decode); + } + + + @Test + public void refreshTokenExpired() { + + + AccessToken token = new AccessToken(); + + token.createTime(DateUtils.getDate("2015-01-01 12:12:12", DateUtils.DEFAULT_DATE_TIME_FORMAT)); + token.tokenExpiredSeconds(10); + + assertTrue(token.refreshTokenExpired()); + + + token.createTime(DateUtils.now()); + token.tokenExpiredSeconds(12); + + assertFalse(token.refreshTokenExpired()); + + + token.createTime(DateUtils.now()); + token.tokenExpiredSeconds(0); + + assertFalse(token.refreshTokenExpired()); + + + } + +} \ No newline at end of file diff --git a/resources/src/test/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepositoryTest.java b/resources-jdbc/src/test/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepositoryTest.java similarity index 100% rename from resources/src/test/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepositoryTest.java rename to resources-jdbc/src/test/java/com/monkeyk/os/infrastructure/jdbc/OAuthRSJdbcRepositoryTest.java diff --git a/resources-jdbc/src/test/java/com/monkeyk/os/web/ShiroTest.java b/resources-jdbc/src/test/java/com/monkeyk/os/web/ShiroTest.java new file mode 100644 index 0000000000000000000000000000000000000000..322f648871e208e290faa6696ef90820ef895981 --- /dev/null +++ b/resources-jdbc/src/test/java/com/monkeyk/os/web/ShiroTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2013 Andaily Information Technology Co. Ltd + * www.andaily.com + * All rights reserved. + * + * This software is the confidential and proprietary information of + * Andaily Information Technology 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 Andaily Information Technology Co. Ltd. + */ +package com.monkeyk.os.web; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.crypto.hash.Md5Hash; +import org.apache.shiro.mgt.DefaultSecurityManager; +import org.apache.shiro.mgt.SecurityManager; +import org.apache.shiro.realm.Realm; +import org.apache.shiro.realm.SimpleAccountRealm; +import org.apache.shiro.subject.Subject; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +/** + * 15-6-10 + * + * @author Shengzhao Li + */ +public class ShiroTest { + + + @Test(enabled = false) + public void login() { + String username = "abc"; + //init SecurityManager + SimpleAccountRealm realm = new SimpleAccountRealm("simple-realm"); + realm.addAccount(username, "abc", "USER"); + + SimpleAccountRealm realm2 = new SimpleAccountRealm("simple-realm2"); + realm2.addAccount(username, "abc", "USER", "ADMIN"); + + List realmList = new ArrayList<>(); + realmList.add(realm); + realmList.add(realm2); + + SecurityManager securityManager = new DefaultSecurityManager(realmList); + SecurityUtils.setSecurityManager(securityManager); + + UsernamePasswordToken token = new UsernamePasswordToken(username, "abcdd"); + + final Subject subject = SecurityUtils.getSubject(); + subject.login(token); + + + final Subject subject1 = SecurityUtils.getSubject(); + assertTrue(subject1.isAuthenticated()); + + assertFalse(subject1.isPermitted("OK")); + assertTrue(subject1.hasRole("USER")); + +// assertTrue(subject1.isPermitted("USER:c,u")); + + + } + + + @Test + public void md5() { + + Md5Hash md5Hash = new Md5Hash("admin"); + System.out.println(md5Hash.toString()); + System.out.println(md5Hash.toHex()); + System.out.println(md5Hash.toBase64()); + + } + +} diff --git a/resources-jdbc/src/test/java/com/monkeyk/os/web/WebUtilsTest.java b/resources-jdbc/src/test/java/com/monkeyk/os/web/WebUtilsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7e38d21dfe64638cdc20a62100d419fc860c93ae --- /dev/null +++ b/resources-jdbc/src/test/java/com/monkeyk/os/web/WebUtilsTest.java @@ -0,0 +1,24 @@ +package com.monkeyk.os.web; + +import org.apache.oltu.oauth2.common.utils.OAuthUtils; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import static org.testng.Assert.assertNotNull; + +public class WebUtilsTest { + + + @Test + public void testDecodeHeader() throws Exception { + + String text = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; + + final String[] strings = OAuthUtils.decodeClientAuthenticationHeader(text); + assertNotNull(strings); + + System.out.println(Arrays.toString(strings)); + } + +} \ No newline at end of file diff --git a/resources-jdbc/src/test/resources/log4j.properties b/resources-jdbc/src/test/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..d1deb90399a5af2f332f609f8defe6d54318e3a9 --- /dev/null +++ b/resources-jdbc/src/test/resources/log4j.properties @@ -0,0 +1,13 @@ +#\u914D\u7F6E\u6839Logger , file, db +log4j.rootLogger=INFO, stdout + +#\u914D\u7F6E\u65E5\u5FD7\u4FE1\u606F\u8F93\u51FA\u76EE\u7684\u5730(appender) +#\u63A7\u5236\u53F0\u8F93\u51FA +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +#\u63A7\u5236\u53F0\u8F93\u51FA\u7684\u9009\u9879(\u53EF\u9009) +#log4j.appender.stdout.Threshold=INFO +#log4j.appender.stdout.ImmediateFlush=true +log4j.appender.stdout.Target=System.out +#\u63A7\u5236\u53F0\u8F93\u51FA\u7684\u683C\u5F0F +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n diff --git a/authz/src/main/resources/authz.properties b/resources-jdbc/src/test/resources/test.properties similarity index 51% rename from authz/src/main/resources/authz.properties rename to resources-jdbc/src/test/resources/test.properties index ed4fc6aa2a539c2e4f504968aa6571228bc8a986..6044cc49aee9c1a479bd09f10f37446a16a9d782 100644 --- a/authz/src/main/resources/authz.properties +++ b/resources-jdbc/src/test/resources/test.properties @@ -1,11 +1,10 @@ - -# Êý¾Ý¿âÁ¬½ÓÅäÖà #JDBC configuration information jdbc.driverClassName=com.mysql.jdbc.Driver ############ # localhost ############ -jdbc.url=jdbc:mysql://localhost:3306/oauth2_shiro?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8 +jdbc.url=jdbc:mysql://localhost:3306/oauth2_shiro_test?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8 jdbc.username=andaily jdbc.password=andaily + diff --git a/resources/pom.xml b/resources/pom.xml index 1da503b1e9cf227c8f59eafa1b718699d7a77cc0..d584b5e06af31a8ac3d6f3ffb235c24b69e00277 100644 --- a/resources/pom.xml +++ b/resources/pom.xml @@ -9,7 +9,7 @@ 0.3 ${project.artifactId} - war + jar oltu and shiro [RESOURCES] @@ -22,15 +22,6 @@ 1.0.2 1.2.3 2.5.4 - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/oauth2_shiro_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8 - andaily - andaily - - - false @@ -47,89 +38,6 @@ - - maven-war-plugin - 2.6 - - */classes/resources.properties - */classes/resources.properties - - false - - ${project.version} - monkeyk.com - monkeyk.com - ${project.name} - ${project.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - maven-surefire-plugin - 2.4 - - ${test.skip} - none - - **/*Test.java - - - - jdbc.url - ${jdbc.url} - - - jdbc.username - ${jdbc.user} - - - jdbc.password - ${jdbc.pass} - - - - @@ -189,12 +97,6 @@ compile - - commons-dbcp - commons-dbcp - 1.4 - - commons-io commons-io @@ -250,15 +152,6 @@ ${spring.version} - - - mysql - mysql-connector-java - ${mysql.version} - compile - - - log4j