-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
139 additions
and
17 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
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
66 changes: 66 additions & 0 deletions
66
.../xtraplatform-auth/src/main/java/de/ii/xtraplatform/auth/app/external/XacmlRequest10.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,66 @@ | ||
/* | ||
* Copyright 2018-2020 interactive instruments GmbH | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package de.ii.xtraplatform.auth.app.external; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author zahnen | ||
*/ | ||
public class XacmlRequest10 { | ||
public final Map<String, Object> Request; | ||
|
||
public XacmlRequest10(String user, String method, String path, byte[] body) { | ||
List<Attribute> subject = | ||
ImmutableList.of(new Attribute("urn:oasis:names:tc:xacml:1.0:subject:subject-id", user)); | ||
List<Attribute> resource = | ||
ImmutableList.of(new Attribute("urn:oasis:names:tc:xacml:1.0:resource:resource-id", path)); | ||
ImmutableList.Builder<Attribute> action = | ||
ImmutableList.<Attribute>builder() | ||
.add(new Attribute("urn:oasis:names:tc:xacml:1.0:action:action-id", method)); | ||
if (method.equals("POST") || method.equals("PUT")) { | ||
action.add(new Attribute("payload", new String(body, StandardCharsets.UTF_8))); | ||
} | ||
|
||
Request = | ||
ImmutableMap.of( | ||
"Category", | ||
ImmutableList.of( | ||
ImmutableMap.of( | ||
"CategoryId", | ||
"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject", | ||
"Attribute", | ||
subject), | ||
ImmutableMap.of( | ||
"CategoryId", | ||
"urn:oasis:names:tc:xacml:3.0:attribute-category:resource", | ||
"Attribute", | ||
resource), | ||
ImmutableMap.of( | ||
"CategoryId", | ||
"urn:oasis:names:tc:xacml:3.0:attribute-category:action", | ||
"Attribute", | ||
action.build()))); | ||
} | ||
|
||
static class Attribute { | ||
public final String AttributeId; | ||
public final String Value; | ||
public final String DataType; | ||
|
||
Attribute(String attributeId, String value) { | ||
AttributeId = attributeId; | ||
Value = value; | ||
DataType = "http://www.w3.org/2001/XMLSchema#string"; | ||
} | ||
} | ||
} |
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
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
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