use of com.enonic.xp.security.acl.Permission in project xp by enonic.
the class PermissionsMapper method serialize.
private void serialize(final MapGenerator gen, final AccessControlEntry accessControlEntry) {
gen.value("principal", accessControlEntry.getPrincipal().toString());
gen.array("allow");
for (Permission permission : accessControlEntry.getAllowedPermissions()) {
gen.value(permission.toString());
}
gen.end();
gen.array("deny");
for (Permission permission : accessControlEntry.getDeniedPermissions()) {
gen.value(permission.toString());
}
gen.end();
}
use of com.enonic.xp.security.acl.Permission in project xp by enonic.
the class PermissionsXmlSerializer method serialize.
private void serialize(final Iterable<Permission> allowedPermissions, final String type) {
this.domBuilder.start(type);
this.domBuilder.attribute("type", "array");
for (final Permission permission : allowedPermissions) {
this.domBuilder.start("value");
this.domBuilder.text(permission.name());
this.domBuilder.end();
}
this.domBuilder.end();
}
use of com.enonic.xp.security.acl.Permission in project xp by enonic.
the class XmlNodeSerializerTest method doCreateNode.
private Node doCreateNode(final Instant instant) {
final PropertyTree propertyTree = new PropertyTree();
propertyTree.addString("myString", "myStringValue");
propertyTree.addString("myString", "myStringValue2");
propertyTree.addString("myEmptyString", "");
propertyTree.addBoolean("myBoolean", true);
propertyTree.addDouble("myDouble", 123.1);
propertyTree.addLong("myLong", 111L);
propertyTree.addXml("myXml", "<car><color>Arctic Grey<color><car>");
propertyTree.addString("myHtmlEncoded", "<p><a href=\"/naringsliv/tema/forsikrings-og-pensjonspakker\" data-event=\"{"event_category": "button", "event_action": "click","event_label": "se-php"}\">Se pakkene her</a></p>");
propertyTree.addGeoPoint("myGeoPoint", GeoPoint.from("8,4"));
// Date & Time
propertyTree.addInstant("myInstant", instant);
propertyTree.addLocalTime("myLocalTime", LocalTime.of(21, 42, 0));
propertyTree.addLocalDate("myLocalDate", LocalDate.of(2014, 11, 28));
propertyTree.addLocalDateTime("myLocalDateTime", LocalDateTime.of(2014, 11, 28, 21, 0, 0, 0));
// Links and ref
propertyTree.addReference("myRef", Reference.from("abcd"));
propertyTree.addLink("myLink", Link.from("/root/parent/child"));
// Binary refs
propertyTree.addBinaryReference("myBinaryRef1", BinaryReference.from("image.jpg"));
propertyTree.addBinaryReference("myBinaryRef2", BinaryReference.from("image2.jpg"));
// Property-set
final PropertySet mySubset = propertyTree.addSet("mySet");
mySubset.setString("myString", "myStringValue");
mySubset.setBoolean("myBoolean", true);
// Property-set in set
final PropertySet mySubSubset = mySubset.addSet("mySet");
mySubSubset.setString("myString", "myStringValue");
mySubSubset.setBoolean("myBoolean", true);
// Null values
propertyTree.addString("myString", null);
propertyTree.addBoolean("myBoolean", null);
propertyTree.addDouble("myDouble", null);
propertyTree.addLong("myLong", null);
propertyTree.addXml("myXml", null);
propertyTree.addGeoPoint("myGeoPoint", null);
propertyTree.addInstant("myInstant", null);
propertyTree.addLocalTime("myLocalTime", null);
propertyTree.addLocalDate("myLocalDate", null);
propertyTree.addLocalDateTime("myLocalDateTime", null);
propertyTree.addReference("myRef", null);
propertyTree.addLink("myLink", null);
propertyTree.addBinaryReference("myBinaryRef2", null);
propertyTree.addSet("nullSet", null);
// Index configs
final IndexConfig indexConfig = IndexConfig.create().enabled(true).fulltext(true).nGram(true).decideByType(false).includeInAllText(true).addIndexValueProcessor(IndexValueProcessors.HTML_STRIPPER).addLanguage("en").build();
final PatternIndexConfigDocument.Builder indexConfigDocumentBuilder = PatternIndexConfigDocument.create();
indexConfigDocumentBuilder.analyzer("no");
indexConfigDocumentBuilder.add("mydata", indexConfig);
indexConfigDocumentBuilder.addAllTextConfigLanguage("en");
// Permissions
final Permission createPermission = Permission.CREATE;
final Permission publishPermission = Permission.PUBLISH;
final PrincipalKey systemPrincipalKey = PrincipalKey.from("role:system.admin");
final PrincipalKey cmsPrincipalKey = PrincipalKey.from("role:cms.admin");
final AccessControlEntry systemAccessControlEntry = AccessControlEntry.create().principal(systemPrincipalKey).allowAll().build();
final AccessControlEntry cmsAccessControlEntry = AccessControlEntry.create().principal(cmsPrincipalKey).allow(createPermission).deny(publishPermission).build();
final AccessControlList accessControlList = AccessControlList.of(systemAccessControlEntry, cmsAccessControlEntry);
return Node.create().id(NodeId.from("abc")).name(NodeName.from("my-node-name")).parentPath(NodePath.ROOT).childOrder(ChildOrder.manualOrder()).nodeType(NodeType.from("content")).data(propertyTree).indexConfigDocument(indexConfigDocumentBuilder.build()).permissions(accessControlList).inheritPermissions(false).attachedBinaries(AttachedBinaries.create().add(new AttachedBinary(BinaryReference.from("image.jpg"), "a")).add(new AttachedBinary(BinaryReference.from("image2.jpg"), "b")).build()).build();
}
use of com.enonic.xp.security.acl.Permission in project xp by enonic.
the class AccessControlListStoreDocumentFactory method create.
static List<IndexItem> create(final AccessControlList accessControlList) {
final List<IndexItem> aclStoreDocumentItems = new ArrayList<>();
for (final AccessControlEntry entry : accessControlList) {
final Iterable<Permission> allowedPermissions = entry.getAllowedPermissions();
final PrincipalKey principalKey = entry.getPrincipal();
for (final Permission permission : allowedPermissions) {
aclStoreDocumentItems.add(new IndexItemString(getPathForPermission(permission), principalKey.toString()));
}
}
return aclStoreDocumentItems;
}
use of com.enonic.xp.security.acl.Permission in project xp by enonic.
the class PermissionsMapper method serialize.
private void serialize(final MapGenerator gen, final AccessControlEntry accessControlEntry) {
gen.value("principal", accessControlEntry.getPrincipal().toString());
gen.array("allow");
for (Permission permission : accessControlEntry.getAllowedPermissions()) {
gen.value(permission.toString());
}
gen.end();
gen.array("deny");
for (Permission permission : accessControlEntry.getDeniedPermissions()) {
gen.value(permission.toString());
}
gen.end();
}
Aggregations