use of org.apache.shiro.config.IniSecurityManagerFactory in project qi4j-sdk by Qi4j.
the class StandaloneShiroTest method documentationSupport_before.
public void documentationSupport_before() {
// START SNIPPET: before
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:standalone-shiro.ini");
SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
// END SNIPPET: before
}
use of org.apache.shiro.config.IniSecurityManagerFactory in project geode by apache.
the class IntegratedSecurityService method initSecurity.
/**
* initialize Shiro's Security Manager and Security Utilities
*/
public void initSecurity(Properties securityProps) {
if (securityProps == null) {
return;
}
String shiroConfig = securityProps.getProperty(SECURITY_SHIRO_INIT);
String securityManagerConfig = securityProps.getProperty(SECURITY_MANAGER);
String clientAuthenticatorConfig = securityProps.getProperty(SECURITY_CLIENT_AUTHENTICATOR);
String peerAuthenticatorConfig = securityProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
if (StringUtils.isNotBlank(shiroConfig)) {
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:" + shiroConfig);
// we will need to make sure that shiro uses a case sensitive permission resolver
Section main = factory.getIni().addSection("main");
main.put("geodePermissionResolver", "org.apache.geode.internal.security.shiro.GeodePermissionResolver");
if (!main.containsKey("iniRealm.permissionResolver")) {
main.put("iniRealm.permissionResolver", "$geodePermissionResolver");
}
org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
isIntegratedSecurity = true;
isClientAuthenticator = false;
isPeerAuthenticator = false;
} else // only set up shiro realm if user has implemented SecurityManager
if (StringUtils.isNotBlank(securityManagerConfig)) {
SecurityManager securityManager = SecurityService.getObjectOfTypeFromClassName(securityManagerConfig, SecurityManager.class);
securityManager.init(securityProps);
this.setSecurityManager(securityManager);
} else {
isIntegratedSecurity = null;
isClientAuthenticator = StringUtils.isNotBlank(clientAuthenticatorConfig);
isPeerAuthenticator = StringUtils.isNotBlank(peerAuthenticatorConfig);
}
// this initializes the post processor
String customPostProcessor = securityProps.getProperty(SECURITY_POST_PROCESSOR);
if (StringUtils.isNotBlank(customPostProcessor)) {
postProcessor = SecurityService.getObjectOfTypeFromClassName(customPostProcessor, PostProcessor.class);
postProcessor.init(securityProps);
} else {
postProcessor = null;
}
}
use of org.apache.shiro.config.IniSecurityManagerFactory in project bamboobsc by billchen198318.
the class SubjectBuilderForBackground method login.
public static void login() throws Exception {
Factory<org.apache.shiro.mgt.SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
org.apache.shiro.mgt.SecurityManager securityManager = (org.apache.shiro.mgt.SecurityManager) factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject currentUser = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(Constants.SYSTEM_BACKGROUND_USER, Constants.SYSTEM_BACKGROUND_PASSWORD);
currentUser.login(token);
//System.out.println(currentUser.hasRole("admin"));
//System.out.println(currentUser.hasRole("*"));
}
Aggregations