Open mrioan opened 10 years ago
One user had the problem that the shiro.ini in Windows was:
Windows
stormpathClient.apiKeyFileLocation = C:/stormpathApiKey.properties
while in Linux:
Linux
stormpathClient.apiKeyFileLocation = /home/user/stormpathApiKey.properties
We might want to provide a way to read properties in an OS-independent way.
BTW, I suggested to user to do:
public class ApiKeyReader extends Reader { private static Logger logger = LoggerFactory.getLogger(ApiKeyReader.class); private FileReader reader; public ApiKeyReader() { try { String osName = System.getProperty("os.name"); if(osName.contains("Mac OS") || osName.contains("linux")) { reader = new FileReader("/Users/mario/.stormpath/api1Key.properties"); } else if(osName.contains("windows")) { reader = new FileReader("c:/apiKey.properties"); } else { throw new RuntimeException("Unrecognized OS: " + osName); } } catch (FileNotFoundException e) { logger.error(e.getMessage()); } } @Override public int read(char[] chars, int i, int i2) throws IOException { return reader.read(chars, i, i2); } @Override public void close() throws IOException { reader.close(); } }
Then, in shiro.ini change this:
to
apikeyReader = com.stormpath.test.ApiKeyReader stormpathClient.apiKeyReader = $apikeyReader
Another option is to be able to place the file relative to the shiro.ini file. I'm not sure how to do that the "right way", but my own webapp is organized such that "classpath:../apiKey.properties" works.
One user had the problem that the shiro.ini in
Windows
was:while in
Linux
:We might want to provide a way to read properties in an OS-independent way.
BTW, I suggested to user to do:
Then, in shiro.ini change this:
to