use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class SecurityAuditLogSupportImpl method createRole.
@Override
public void createRole(final CreateRoleParams params) {
if (isEnabledAuditLogs) {
PropertyTree data = new PropertyTree();
PropertySet paramsSet = data.addSet("params");
paramsSet.setString("key", params.getKey().toString());
paramsSet.setString("displayName", params.getDisplayName());
paramsSet.setString("description", params.getDescription());
log("system.security.principal.create", data, AuditLogUris.from(params.getKey().toString()));
}
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class SecurityAuditLogSupportImpl method removeRelationship.
@Override
public void removeRelationship(final PrincipalRelationship relationship) {
if (isEnabledAuditLogs) {
PropertyTree data = new PropertyTree();
PropertySet paramsSet = data.addSet("params");
paramsSet.setString("principal", relationship.getTo().toString());
paramsSet.setString("leaves", relationship.getFrom().toString());
AuditLogUris auditLogUris = AuditLogUris.from(relationship.getTo().toString(), relationship.getFrom().toString());
log("system.security.principal.removeRelationship", data, auditLogUris);
}
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class SecurityInitializer method initializeSystemIdProvider.
private void initializeSystemIdProvider() {
LOG.info("Initializing id provider [" + IdProviderKey.system() + "]");
final PropertyTree idProviderConfigTree = new PropertyTree();
if (!"false".equalsIgnoreCase(System.getProperty(ADMIN_USER_CREATION_PROPERTY_KEY))) {
idProviderConfigTree.setBoolean("adminUserCreationEnabled", true);
}
final IdProviderConfig idProviderConfig = IdProviderConfig.create().applicationKey(SYSTEM_ID_PROVIDER_KEY).config(idProviderConfigTree).build();
final CreateIdProviderParams createParams = CreateIdProviderParams.create().key(IdProviderKey.system()).displayName(SYSTEM_ID_PROVIDER_DISPLAY_NAME).idProviderConfig(idProviderConfig).permissions(DEFAULT_ID_PROVIDER_ACL).build();
this.securityService.createIdProvider(createParams);
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class PrincipalKeyNodeTranslator method toKey.
public static PrincipalKey toKey(final Node node) {
final String principalId = node.name().toString();
final PropertyTree rootDataSet = node.data();
final String principalType = rootDataSet.getString(PrincipalPropertyNames.PRINCIPAL_TYPE_KEY);
final String idProviderKey = rootDataSet.getString(PrincipalPropertyNames.ID_PROVIDER_KEY);
final PrincipalType type = PrincipalType.valueOf(principalType);
switch(type) {
case USER:
return PrincipalKey.ofUser(IdProviderKey.from(idProviderKey), principalId);
case GROUP:
return PrincipalKey.ofGroup(IdProviderKey.from(idProviderKey), principalId);
case ROLE:
return PrincipalKey.ofRole(principalId);
}
throw new IllegalArgumentException("Invalid principal type in node: " + type);
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class PrincipalNodeTranslator method toCreateNodeParams.
public static CreateNodeParams toCreateNodeParams(final Principal principal) {
Preconditions.checkNotNull(principal);
final CreateNodeParams.Builder builder = CreateNodeParams.create().name(PrincipalKeyNodeTranslator.toNodeName(principal.getKey()).toString()).parent(principal.getKey().toPath().getParentPath()).setNodeId(NodeId.from(principal.getKey().toString().toLowerCase())).inheritPermissions(true).indexConfigDocument(PrincipalIndexConfigFactory.create());
final PropertyTree data = new PropertyTree();
data.setString(PrincipalPropertyNames.DISPLAY_NAME_KEY, principal.getDisplayName());
data.setString(PrincipalPropertyNames.PRINCIPAL_TYPE_KEY, principal.getKey().getType().toString());
if (!principal.getKey().isRole()) {
data.setString(PrincipalPropertyNames.ID_PROVIDER_KEY, principal.getKey().getIdProviderKey().toString());
}
switch(principal.getKey().getType()) {
case USER:
populateUserData(data.getRoot(), (User) principal);
break;
case ROLE:
populateRoleData(data.getRoot(), (Role) principal);
break;
case GROUP:
populateGroupData(data.getRoot(), (Group) principal);
break;
}
builder.data(data);
return builder.build();
}
Aggregations