ScopedTest class get token from a property file which is ignored. So that there is no more possibility to commit token for mistake

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@133987 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-11-09 15:30:07 +00:00
parent 73f65aad08
commit 8ff76e17ea
1 changed files with 22 additions and 1 deletions

View File

@ -3,6 +3,10 @@
*/
package org.gcube.informationsystem.resourceregistry.publisher;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.gcube.common.authorization.client.Constants;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
import org.gcube.common.authorization.library.AuthorizationEntry;
@ -21,7 +25,24 @@ public class ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
private static final String TOKEN = "";
protected static final String PROPERTIES_FILENAME = "config.properties";
private static final String TOKEN_VARNAME = "TOKEN";
private static final String TOKEN;
static {
Properties properties = new Properties();
InputStream input = ScopedTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
try {
// load the properties file
properties.load(input);
} catch (IOException e) {
throw new RuntimeException(e);
}
TOKEN = properties.getProperty(TOKEN_VARNAME);
}
private static String getCurrentScope() throws ObjectNotFound, Exception{
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(TOKEN);