-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36dc704
commit 68733ec
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
gateway/src/main/java/org/georchestra/gateway/security/oauth2/LdapEnabledCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.georchestra.gateway.security.oauth2; | ||
|
||
import com.jayway.jsonpath.JsonPath; | ||
import org.springframework.beans.factory.config.YamlMapFactoryBean; | ||
import org.springframework.context.annotation.Condition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.core.io.FileSystemResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
|
||
import java.util.LinkedHashMap; | ||
|
||
public class LdapEnabledCondition implements Condition { | ||
|
||
@Override | ||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
Resource resource = new FileSystemResource( | ||
System.getProperty("georchestra.datadir", "/etc/georchestra") + "/gateway/security.yaml"); | ||
YamlMapFactoryBean yaml = new YamlMapFactoryBean(); | ||
yaml.setResources(resource); | ||
LinkedHashMap<String, LinkedHashMap<String, Object>> ldap = JsonPath.read(yaml.getObject().get("georchestra"), | ||
"$.gateway.security.ldap"); | ||
return ldap.values().stream().anyMatch(el -> el.containsKey("enabled") && ((Boolean) el.get("enabled"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters