Skip to content

Commit fb1a746

Browse files
[Issue #33] Add property for hazelcast password (when Hazelcast storage is used)
1 parent fb629f0 commit fb1a746

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ oauth20.database=
4242
db_host=
4343
redis.sentinels=
4444
redis.master=
45+
hazelcast.password=
4546
apifest-oauth20.nodes=
4647
custom.classes.jar=
4748
user.authenticate.class=
@@ -82,6 +83,10 @@ You can define the name of Redis master in the following property in the apifest
8283

8384
***redis.master***
8485

86+
If you use Hazelcast as a storage, you can set a password using the following property (otherwise the default Hazelcast password - dev-pass will be used):
87+
88+
***hazelcast.password***
89+
8590
In order to run ApiFest OAuth20 distributed storage, you need to setup all ApiFest OAuth20 nodes (as comma-separated list of IPs).
8691

8792
***apifest-oauth20.nodes***

apifest-oauth20/src/main/java/com/apifest/oauth20/OAuthServer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public final class OAuthServer {
6464
private static String redisMaster;
6565
private static String apifestOAuth20Nodes;
6666
private static URLClassLoader jarClassLoader;
67+
private static String hazelcastPassword;
6768

6869
// expires_in in sec for grant type password
6970
public static final int DEFAULT_PASSWORD_EXPIRES_IN = 900;
@@ -259,6 +260,8 @@ protected static void loadProperties(InputStream in) {
259260
}
260261
setHostAndPort((String) props.get("oauth20.host"), (String) props.get("oauth20.port"));
261262
apifestOAuth20Nodes = props.getProperty("apifest-oauth20.nodes");
263+
// dev-pass is the default password used in Hazelcast
264+
hazelcastPassword = props.getProperty("hazelcast.password", "dev-pass");
262265
} catch (IOException e) {
263266
log.error("Cannot load properties file", e);
264267
}
@@ -327,4 +330,7 @@ public static Class<ICustomGrantTypeHandler> getCustomGrantTypeHandler() {
327330
return customGrantTypeHandler;
328331
}
329332

333+
public static String getHazelcastPassword() {
334+
return hazelcastPassword;
335+
}
330336
}

apifest-oauth20/src/main/java/com/apifest/oauth20/persistence/hazelcast/HazelcastDBManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class HazelcastDBManager implements DBManager {
7676
static {
7777
// REVISIT: Hazelcast configuration
7878
Config config = createConfiguration();
79-
GroupConfig groupConfig = new GroupConfig("apifest-oauth20", "apifest-oauth20-pass");
79+
GroupConfig groupConfig = new GroupConfig("apifest-oauth20", OAuthServer.getHazelcastPassword());
8080
config.setGroupConfig(groupConfig);
8181
config.setMapConfigs(createMapConfigs());
8282
hazelcastClient = Hazelcast.newHazelcastInstance(config);

apifest-oauth20/src/main/resources/apifest-oauth.properties.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ apifest-oauth20.nodes=
88
custom.classes.jar=
99
user.authenticate.class=
1010
custom.grant_type=
11-
custom.grant_type.class=
11+
custom.grant_type.class=
12+
hazelcast.password=

0 commit comments

Comments
 (0)