use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Attributes in project xtext-core by eclipse.
the class ManifestMerger2Test method testMergeRequiredBundles.
@Test
public void testMergeRequiredBundles() throws Exception {
String packageName = getClass().getPackage().getName().replace('.', '/');
InputStream resourceAsStream = getClass().getResourceAsStream("/" + packageName + "/Test_Manifest.MF");
MergeableManifest2 manifest = new MergeableManifest2(resourceAsStream);
Attributes attrs = manifest.getMainAttributes();
String before = attrs.get(MergeableManifest2.REQUIRE_BUNDLE).replaceAll("\\s", "");
manifest.addRequiredBundles(Collections.singleton("foo.bar.baz"));
String after = attrs.get(MergeableManifest2.REQUIRE_BUNDLE);
assertEquals(before + ",foo.bar.baz", after.replaceAll("\\s", ""));
}
use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Attributes in project xtext-core by eclipse.
the class ManifestMerger2Test method testNoChanges.
@Test
public void testNoChanges() throws Exception {
String packageName = getClass().getPackage().getName().replace('.', '/');
InputStream resourceAsStream = getClass().getResourceAsStream("/" + packageName + "/Test_Manifest.MF");
MergeableManifest2 manifest = new MergeableManifest2(resourceAsStream);
Attributes attrs = manifest.getMainAttributes();
String before = attrs.get(MergeableManifest2.EXPORT_PACKAGE).replaceAll("\\s", "");
manifest.addExportedPackages(Collections.singleton("foo.bar.baz"));
String after = attrs.get(MergeableManifest2.EXPORT_PACKAGE);
assertEquals(before + ",foo.bar.baz", after.replaceAll("\\s", ""));
}
use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Attributes in project ddf by codice.
the class XacmlPdpTest method testEnvironmentVariables.
@Test
public void testEnvironmentVariables() {
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), new KeyValueCollectionPermissionImpl(QUERY_ACTION));
List<AttributesType> attributes = request.getAttributes();
AttributesType environmentAttributes = null;
for (AttributesType attribute : attributes) {
if (attribute.getCategory().equals(ENVIRONMENT_CATEGORY)) {
environmentAttributes = attribute;
}
}
assertNotNull(environmentAttributes);
assertThat(environmentAttributes.getAttribute().get(0).getAttributeId(), is("item0"));
assertThat(environmentAttributes.getAttribute().get(0).getAttributeValue().size(), is(1));
assertThat(environmentAttributes.getAttribute().get(1).getAttributeId(), is("item1"));
assertThat(environmentAttributes.getAttribute().get(1).getAttributeValue().size(), is(2));
assertThat(environmentAttributes.getAttribute().get(2).getAttributeId(), is("item2"));
assertThat(environmentAttributes.getAttribute().get(2).getAttributeValue().size(), is(3));
}
use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Attributes in project carbon-identity-framework by wso2.
the class EntitlementUtil method getAttributes.
public static Attributes getAttributes(AttributeDTO attributeDataDTO) {
try {
AttributeValue value = Balana.getInstance().getAttributeFactory().createValue(new URI(attributeDataDTO.getAttributeDataType()), attributeDataDTO.getAttributeValue());
Attribute attribute = new Attribute(new URI(attributeDataDTO.getAttributeId()), null, null, value, XACMLConstants.XACML_VERSION_3_0);
Set<Attribute> set = new HashSet<Attribute>();
set.add(attribute);
String category = attributeDataDTO.getCategory();
// We are only creating XACML 3.0 requests Therefore covert order XACML categories to new uris
if (PDPConstants.SUBJECT_ELEMENT.equals(category)) {
category = PDPConstants.SUBJECT_CATEGORY_URI;
} else if (PDPConstants.RESOURCE_ELEMENT.equals(category)) {
category = PDPConstants.RESOURCE_CATEGORY_URI;
} else if (PDPConstants.ACTION_ELEMENT.equals(category)) {
category = PDPConstants.ACTION_CATEGORY_URI;
} else if (PDPConstants.ENVIRONMENT_ELEMENT.equals(category)) {
category = PDPConstants.ENVIRONMENT_CATEGORY_URI;
}
return new Attributes(new URI(category), set);
} catch (Exception e) {
log.debug(e);
// ignore and return null;
}
return null;
}
use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Attributes in project carbon-identity-framework by wso2.
the class JSONRequestParser method jsonAttributeSeperator.
/**
* This is to seperate JSON to attributes
* @param jsonAttribute - the map of category string and the JSON Element
* @param jsonCategory - the main object category
* @param categories - the set of categories
* @throws RequestParseException
* @throws UnknownIdentifierException
*/
private static void jsonAttributeSeperator(Map.Entry<String, JsonElement> jsonAttribute, JsonObject jsonCategory, Set<Attributes> categories) throws RequestParseException, UnknownIdentifierException {
Node content = null;
URI category = null;
Set<Attribute> attributes = null;
String id = null;
if (EntitlementEndpointConstants.CATEGORY_DEFAULT.equals(jsonAttribute.getKey())) {
if (jsonCategory.has(EntitlementEndpointConstants.CATEGORY_ID)) {
category = stringCateogryToURI(jsonCategory.get(EntitlementEndpointConstants.CATEGORY_ID).getAsString());
}
} else {
if (category == null) {
category = stringCateogryToURI(jsonAttribute.getKey());
}
if (jsonCategory.has(EntitlementEndpointConstants.ID)) {
id = jsonCategory.get(EntitlementEndpointConstants.ID).getAsString();
}
if (jsonCategory.has(EntitlementEndpointConstants.CONTENT)) {
DocumentBuilderFactory dbf;
Document doc = null;
String xmlContent = stringContentToXMLContent(jsonCategory.get(EntitlementEndpointConstants.CONTENT).getAsString());
dbf = IdentityUtil.getSecuredDocumentBuilderFactory();
dbf.setNamespaceAware(true);
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(xmlContent.getBytes())) {
doc = dbf.newDocumentBuilder().parse(inputStream);
} catch (Exception e) {
throw new JsonParseException("DOM of request element can not be created from String.", e);
}
if (doc != null) {
content = doc.getDocumentElement();
}
}
// Add all category attributes
if (jsonCategory.has(EntitlementEndpointConstants.ATTRIBUTE)) {
if (jsonCategory.get(EntitlementEndpointConstants.ATTRIBUTE).isJsonArray()) {
attributes = new HashSet<>();
for (JsonElement jsonElement : jsonCategory.get(EntitlementEndpointConstants.ATTRIBUTE).getAsJsonArray()) {
attributes.add(jsonObjectToAttribute(jsonElement.getAsJsonObject()));
}
}
}
}
// Build the Attributes object using above values
Attributes attributesObj = new Attributes(category, content, attributes, id);
categories.add(attributesObj);
}
Aggregations