Skip to content

Commit

Permalink
Replace use of deprecated class WebIniSecurityManagerFactory with Ini…
Browse files Browse the repository at this point in the history
…WebEnvironment
  • Loading branch information
steinarb committed Mar 3, 2024
1 parent a5c86bc commit 0d3ecef
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

import org.apache.shiro.authc.SimpleAccount;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.Ini;
import org.apache.shiro.mgt.RealmSecurityManager;
import org.apache.shiro.realm.SimpleAccountRealm;
import org.apache.shiro.util.ThreadContext;
import org.apache.shiro.web.config.WebIniSecurityManagerFactory;
import org.apache.shiro.web.env.IniWebEnvironment;
import org.apache.shiro.web.mgt.WebSecurityManager;
import org.apache.shiro.web.subject.WebSubject;

Expand Down Expand Up @@ -88,8 +87,10 @@ protected WebSubject createSubjectAndBindItToThread(HttpServletRequest request,

public static WebSecurityManager getSecurityManager() {
if (securitymanager == null) {
var securityManagerFactory = new WebIniSecurityManagerFactory(Ini.fromResourcePath("classpath:test.shiro.ini"));
securitymanager = (WebSecurityManager) securityManagerFactory.getInstance();
var env = new IniWebEnvironment();
env.setConfigLocations("classpath:test.shiro.ini");
env.init();
securitymanager = env.getWebSecurityManager();
realm = findRealmFromSecurityManager(securitymanager);
}

Expand Down

0 comments on commit 0d3ecef

Please sign in to comment.