Hi,
I have spent several days trying to find a solution for my issue so any help
would be more than welcome! I am using stormpath as my Client. Although I
know all the reasons why apiKeyFile should not be located inside the project
classpath, This is exactly what I need to do but I am having trouble setting
it properly.
Currently in my shiro.ini I have-
_______________
...
stormpathClient = com.stormpath.shiro.client.ClientFactory
stormpathClient.cacheManager = $cacheManager
stormpathClient.apiKeyFileLocation = c:/stormpathApiKey.properties
stormpathRealm = com.stormpath.shiro.realm.ApplicationRealm
stormpathRealm.client = $stormpathClient
...
_______________
When I change the apiKeyFileLocation to without the quote
'/stormpathApiKey.properties' or '/WEB-INF/stormpathApiKey.properties' it
does not work even though the file is present in both the src and the
WEB-INF folder.
I have also tried writing my own Environment Initializer class
IniWebEnvironment but that didn't work either. Here is what I tried to do:
_______________
public class ShiroWebEnvironment extends IniWebEnvironment{
private static final String applicationRestUrl =
"https://api.stormpath.com/v1/applications/APPHREF";
private static final String stormpathApiKeyFile =
"stormpathApiKey.properties";
@Override
public void init() {
Settings settings = new Settings();
String location = settings.getStormpathIniFilePath();
Ini ini = createIni(location, false);
ApplicationRealm stormpathRealm = new ApplicationRealm();
DefaultSecurityManager securityManager = new
DefaultSecurityManager(stormpathRealm);
MemoryConstrainedCacheManager cacheManager = new
MemoryConstrainedCacheManager();
securityManager.setCacheManager(cacheManager);
//Initializing Stormpath
ClientFactory stormpathClient = new ClientFactory();
stormpathClient.setCacheManager(cacheManager);
InputStream
apiKeyIS=SettingsProperties.class.getClassLoader().getResourceAsStream(stormpathApiKeyFile);
stormpathClient.setApiKeyInputStream(apiKeyIS);
stormpathRealm.setClient(stormpathClient.getInstance());
stormpathRealm.setApplicationRestUrl(applicationRestUrl);
stormpathRealm.setName(groupRoleResolverModeNames);
DefaultGroupRoleResolver groupRoleResolver = new
DefaultGroupRoleResolver();
stormpathRealm.setGroupRoleResolver(groupRoleResolver);
this.setIni(ini);
super.init();
}
_______________
Thank you so much!
--
View this message in context:
http://shiro-user.582556.n2.nabble.com/Dynamically-set-Client-apiKeyFileLocation-value-during-initialization-shiro-ini-tp7580145.html
Sent from the Shiro User mailing list archive at Nabble.com.