0
有一些配置問題。Apache Shiro Web應用程序的授權和身份驗證配置
我想阿帕奇四郎與蒙戈DB境界整合。
ini文件:
[main]
mongoDBRealm = realm.MongoRealm
securityManager.realms = $mongoDBRealm
# specify login page
shiro.loginUrl = /<ProjFolderNameInEclipse>/SuppliersLogin.html
# name of request parameter with username; if not present filter assumes 'username'
#authc.usernameParam = user
# name of request parameter with password; if not present filter assumes 'password'
#authc.passwordParam = pass
# does the user wish to be remembered?; if not present filter assumes 'rememberMe'
#authc.rememberMeParam = remember
# redirect after successful login
authc.successUrl = /<ProjFolderNameInEclipse>/pass.html
[urls]
# enable authc filter for all application pages
/<ProjFolderNameInEclipse>/SuppliersLogin.html = authc
這個INI與合作:
public static void main(String[] args) {
Factory<SecurityManager> factory = new IniSecurityManagerFactory("shiro.ini");
SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject currentUser = SecurityUtils.getSubject();
..
some logic
..
}
上面的代碼只是爲了確保該領域工作正常。
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<context-param>
<param-name>shiroConfigLocations</param-name>
<param-value>classpath:shiro.ini</param-value>
</context-param>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
</web-app>
現在我有簡單的登錄頁面所在的WebContent
文件夾中指出: 有以下形式:
<form method="POST" action="" name="loginform">
<header>
Sign In
</header>
<fieldset>
<section>
<label class="label">User name</label>
<label class="input"> <i class="icon-append fa fa-user"></i>
<input type="text" name="username">
<b class="tooltip tooltip-top-right"><i class="fa fa-user txt-color-teal"></i> Please enter email address/username</b></label>
</section>
<section>
<label class="label">Password</label>
<label class="input"> <i class="icon-append fa fa-lock"></i>
<input type="password" name="password">
<b class="tooltip tooltip-top-right"><i class="fa fa-lock txt-color-teal"></i> Enter your password</b> </label>
<div class="note">
<a href="forgotpassword.html">Forgot password?</a>
</div>
</section>
<section>
<label class="checkbox">
<input type="checkbox" name="remember" checked="">
<i></i>Stay signed in</label>
</section>
</fieldset>
<footer>
<!-- <button type="submit" class="btn btn-primary" value="Sign In"> -->
<button type="submit" class="btn btn-primary" value="Login" name="submit">
Sign in
</button>
</footer>
</form>
同時擊中提交BTN,實在不行旁邊的頁面重新裝入..
我做錯了什麼?