This repository was archived by the owner on Dec 12, 2018. It is now read-only.
Description One user had the problem that the shiro.ini in Windows was:
stormpathClient.apiKeyFileLocation = C:/stormpathApiKey.properties
while in 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:
stormpathClient.apiKeyFileLocation = C:/stormpathApiKey.properties
to
apikeyReader = com.stormpath.test.ApiKeyReader
stormpathClient.apiKeyReader = $apikeyReader