Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bigsys
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bigsys
Commits
b600d774
Commit
b600d774
authored
Aug 15, 2017
by
Paul0523
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构代码
parent
1bf305cd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
12 deletions
+81
-12
bigsys-shiro/pom.xml
bigsys-shiro/pom.xml
+1
-0
bigsys-shiro/src/main/java/com/bigsys/shiro/filter/LoginFilter.java
...ro/src/main/java/com/bigsys/shiro/filter/LoginFilter.java
+23
-0
bigsys-shiro/src/main/java/com/bigsys/shiro/service/UserService.java
...o/src/main/java/com/bigsys/shiro/service/UserService.java
+1
-1
bigsys-shiro/src/main/resources/bigsys-shiro.xml
bigsys-shiro/src/main/resources/bigsys-shiro.xml
+6
-7
bigsys-shiro/src/main/resources/static/login.html
bigsys-shiro/src/main/resources/static/login.html
+2
-2
bigsys-spring/pom.xml
bigsys-spring/pom.xml
+7
-0
bigsys-webdemo/src/main/resources/spring-mvc.xml
bigsys-webdemo/src/main/resources/spring-mvc.xml
+22
-2
bigsys-webdemo/src/main/webapp/WEB-INF/web.xml
bigsys-webdemo/src/main/webapp/WEB-INF/web.xml
+19
-0
No files found.
bigsys-shiro/pom.xml
View file @
b600d774
...
...
@@ -53,5 +53,6 @@
<artifactId>
bigsys-spring
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</project>
bigsys-shiro/src/main/java/com/bigsys/shiro/filter/LoginFilter.java
0 → 100644
View file @
b600d774
package
com
.
bigsys
.
shiro
.
filter
;
import
org.apache.shiro.authc.AuthenticationToken
;
import
org.apache.shiro.authc.UsernamePasswordToken
;
import
org.apache.shiro.web.filter.authc.FormAuthenticationFilter
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
/**
* Created by fangzhipeng on 2017/8/15.
*/
public
class
LoginFilter
extends
FormAuthenticationFilter
{
@Override
protected
AuthenticationToken
createToken
(
ServletRequest
request
,
ServletResponse
response
)
{
HttpServletRequest
req
=
(
HttpServletRequest
)
request
;
String
username
=
req
.
getParameter
(
"username"
);
String
password
=
req
.
getParameter
(
"password"
);
return
new
UsernamePasswordToken
(
username
,
password
);
}
}
bigsys-shiro/src/main/java/com/bigsys/shiro/service/UserService.java
View file @
b600d774
...
...
@@ -15,7 +15,7 @@ public class UserService {
public
User
getByUsername
(
String
username
)
{
User
user
=
new
User
();
user
.
setUsername
(
username
);;
user
.
setPassword
(
"
123456
"
);
user
.
setPassword
(
"
yuanguang2017
"
);
return
user
;
}
}
bigsys-shiro/src/main/resources/bigsys-shiro.xml
View file @
b600d774
...
...
@@ -16,6 +16,9 @@
<bean
id=
"userRealm"
class=
"com.bigsys.shiro.realm.UserRealm"
>
</bean>
<bean
id=
"authc"
class=
"com.bigsys.shiro.filter.LoginFilter"
>
</bean>
<!-- 安全管理器 -->
<bean
id=
"securityManager"
class=
"org.apache.shiro.web.mgt.DefaultWebSecurityManager"
>
<property
name=
"realm"
ref=
"userRealm"
/>
...
...
@@ -23,16 +26,12 @@
<bean
id=
"shiroFilter"
class=
"org.apache.shiro.spring.web.ShiroFilterFactoryBean"
>
<property
name=
"securityManager"
ref=
"securityManager"
/>
<property
name=
"loginUrl"
value=
"/
login
"
/>
<property
name=
"successUrl"
value=
"/
login/loginSuccessFull
"
/>
<property
name=
"unauthorizedUrl"
value=
"/
login/unauthorized
"
/>
<property
name=
"loginUrl"
value=
"/
static/login.html
"
/>
<property
name=
"successUrl"
value=
"/
hello
"
/>
<property
name=
"unauthorizedUrl"
value=
"/
static/login.html
"
/>
<property
name=
"filterChainDefinitions"
>
<value>
/home* = anon
/ = anon
/logout = logout
/role/** = roles[admin]
/permission/** = perms[permssion:look]
/** = authc
</value>
</property>
...
...
bigsys-shiro/src/main/resources/static/login.html
View file @
b600d774
...
...
@@ -5,10 +5,10 @@
<title>
登录页面
</title>
</head>
<body>
<form
action=
"
login.html
"
>
<form
action=
"
"
method=
"post
"
>
<label>
用户名:
</label><input
type=
"text"
name=
"username"
>
<label>
密码:
</label><input
type=
"password"
name=
"password"
>
<input
type=
"submit"
nam
e=
"提交"
/>
<input
type=
"submit"
valu
e=
"提交"
/>
</form>
</body>
</html>
\ No newline at end of file
bigsys-spring/pom.xml
View file @
b600d774
...
...
@@ -24,6 +24,13 @@
</properties>
<dependencies>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
<version>
3.0.1
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-aop
</artifactId>
...
...
bigsys-webdemo/src/main/resources/spring-mvc.xml
View file @
b600d774
...
...
@@ -13,6 +13,26 @@
<mvc:annotation-driven
/>
<mvc:resources
mapping=
"/static/**"
location=
"/,classpath:/static/"
/>
<bean
class=
"org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
>
<property
name=
"urlMap"
>
<map>
<entry
key=
"/static/**"
value=
"myResourceHandler"
/>
</map>
</property>
<property
name=
"order"
value=
"100000"
/>
</bean>
<bean
id=
"myResourceHandler"
name=
"myResourceHandler"
class=
"org.springframework.web.servlet.resource.ResourceHttpRequestHandler"
>
<property
name=
"locations"
value=
"classpath:/static/"
/>
<property
name=
"supportedMethods"
>
<list>
<value>
GET
</value>
<value>
HEAD
</value>
<value>
POST
</value>
</list>
</property>
</bean>
</beans>
\ No newline at end of file
bigsys-webdemo/src/main/webapp/WEB-INF/web.xml
View file @
b600d774
...
...
@@ -37,6 +37,25 @@
<url-pattern>
/*
</url-pattern>
</filter-mapping>
<!-- 配置Shiro过滤器,先让Shiro过滤系统接收到的请求 -->
<!-- 这里filter-name必须对应applicationContext.xml中定义的<bean id="shiroFilter"/> -->
<!-- 使用[/*]匹配所有请求,保证所有的可控请求都经过Shiro的过滤 -->
<!-- 通常会将此filter-mapping放置到最前面(即其他filter-mapping前面),以保证它是过滤器链中第一个起作用的 -->
<filter>
<filter-name>
shiroFilter
</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
<init-param>
<!-- 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由servlet container管理 -->
<param-name>
targetFilterLifecycle
</param-name>
<param-value>
true
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>
shiroFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
</web-app>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment