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 4a476bb commit a78dd3d
Showing 1 changed file with 5 additions and 4 deletions.
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 @@ -84,8 +83,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 a78dd3d

Please sign in to comment.