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 bcde389 commit c884966
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@

import static org.mockito.Mockito.mock;

import java.lang.reflect.Method;
import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

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.Realm;
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 @@ -92,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 c884966

Please sign in to comment.