You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by gracemeilen <gi...@git.apache.org> on 2016/08/05 22:42:16 UTC
[GitHub] incubator-geode pull request #228: GEODE-1673: Use security.json as default
GitHub user gracemeilen opened a pull request:
https://github.com/apache/incubator-geode/pull/228
GEODE-1673: Use security.json as default
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gracemeilen/incubator-geode feature/GEODE-1673-2
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-geode/pull/228.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #228
----
commit 97588e2966a50c6be7e6ea70c14c0e9f07bc6594
Author: gmeilen <gr...@gmail.com>
Date: 2016-08-02T18:29:40Z
GEODE-1673: Use security.json as default
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-geode pull request #228: GEODE-1673: Use security.json as default
Posted by jinmeiliao <gi...@git.apache.org>.
Github user jinmeiliao commented on a diff in the pull request:
https://github.com/apache/incubator-geode/pull/228#discussion_r73898764
--- Diff: geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java ---
@@ -126,26 +126,33 @@ public boolean authorize(final Principal principal, final ResourcePermission con
@Override
public void init(final Properties securityProperties) throws NotAuthorizedException {
- String jsonPropertyValue = securityProperties.getProperty(SECURITY_JSON);
+ boolean initialized = false;
+
+ String jsonPropertyValue = securityProperties != null ? securityProperties.getProperty(SECURITY_JSON) : null;
if (jsonPropertyValue == null) {
- throw new AuthenticationFailedException("SampleSecurityManager: property [" + SECURITY_JSON + "] must be set.");
- }
+ initialized = initializeFromJsonResource(DEFAULT_JSON_FILE_NAME);
+ } else {
- // 1st try to load value as a json resource
- boolean initialized = initializeFromJsonResource(jsonPropertyValue);
+ // 1st try to load value as a json resource
+ initialized = initializeFromJsonResource(jsonPropertyValue);
- // 2nd try to load value as a json file
- if (!initialized) {
- initialized = initializeFromJsonFile(new File(jsonPropertyValue));
- }
+ // 2nd try to load value as a json file
--- End diff --
Do we really need the 2nd try and 3rd try? We don't use SampleSeucurityManager this way. If we can get rid these additional tries, then the init could be simple as this:
String jsonPropertyValue = securityProperties.getProperty(SECURITY_JSON);
if(jsonPropertyValue == null) jsonPropertyValue = DEFAULT_JSON_FILE_NAME;
if(!initializeFromJsonResource(jsonPropertyValue)){
// throw exception....
}
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-geode pull request #228: GEODE-1673: Use security.json as default
Posted by jinmeiliao <gi...@git.apache.org>.
Github user jinmeiliao commented on a diff in the pull request:
https://github.com/apache/incubator-geode/pull/228#discussion_r73898883
--- Diff: geode-core/src/test/java/org/apache/geode/security/templates/SampleSecurityManagerTest.java ---
@@ -65,6 +65,16 @@ public void setUp() throws Exception {
}
@Test
+ public void shouldDefaultToSecurityJsonInClasspathIfNullProperties() throws Exception {
+ this.sampleSecurityManager.init(null);
+ }
+
+ @Test
+ public void shouldDefaultToSecurityJsonInClasspathIfEmptyProperties() throws Exception {
+ this.sampleSecurityManager.init(new Properties());
--- End diff --
add some asserts here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-geode pull request #228: GEODE-1673: Use security.json as default
Posted by gracemeilen <gi...@git.apache.org>.
Github user gracemeilen closed the pull request at:
https://github.com/apache/incubator-geode/pull/228
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-geode pull request #228: GEODE-1673: Use security.json as default
Posted by jinmeiliao <gi...@git.apache.org>.
Github user jinmeiliao commented on a diff in the pull request:
https://github.com/apache/incubator-geode/pull/228#discussion_r73898847
--- Diff: geode-core/src/test/java/org/apache/geode/security/templates/SampleSecurityManagerTest.java ---
@@ -65,6 +65,16 @@ public void setUp() throws Exception {
}
@Test
+ public void shouldDefaultToSecurityJsonInClasspathIfNullProperties() throws Exception {
+ this.sampleSecurityManager.init(null);
--- End diff --
should we add some asserts here?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---