use of com.enonic.xp.security.PrincipalKey in project xp by enonic.
the class IssueServiceImplTest_updateComment method updateComment.
@Test
public void updateComment() throws Exception {
Issue issue = this.createIssue(CreateIssueParams.create().title("issue-1"));
final Instant created = Instant.now().minus(1, ChronoUnit.MINUTES);
final PrincipalKey creator = PrincipalKey.from("user:store:me");
final String creatorDisplayName = "Me Myself";
final CreateIssueCommentParams params = CreateIssueCommentParams.create().text("text").issue(issue.getId()).creator(creator).creatorDisplayName(creatorDisplayName).created(created).build();
final IssueComment comment = this.issueService.createComment(params);
final IssueComment updatedComment = this.issueService.updateComment(UpdateIssueCommentParams.create().comment(comment.getId()).text("updated text").build());
assertNotNull(updatedComment);
assertEquals("updated text", updatedComment.getText());
assertEquals(creator, updatedComment.getCreator());
assertEquals(creatorDisplayName, updatedComment.getCreatorDisplayName());
assertEquals(created, updatedComment.getCreated());
}
use of com.enonic.xp.security.PrincipalKey in project xp by enonic.
the class XmlServiceDescriptorParser method doParse.
@Override
protected void doParse(final DomElement root) throws Exception {
assertTagName(root, "service");
final DomElement allowedPrincipals = root.getChild("allow");
if (allowedPrincipals != null) {
final List<PrincipalKey> allowedPrincipalKeys = new ArrayList<>();
final List<DomElement> allowedPrincipalList = allowedPrincipals.getChildren("principal");
for (DomElement allowedPrincipal : allowedPrincipalList) {
allowedPrincipalKeys.add(PrincipalKey.from(allowedPrincipal.getValue().trim()));
}
this.builder.setAllowedPrincipals(allowedPrincipalKeys);
}
}
use of com.enonic.xp.security.PrincipalKey in project xp by enonic.
the class UpdateProjectRoleNamesCommand method doUpdateRoles.
private void doUpdateRoles() {
for (ProjectRole projectRole : ProjectRole.values()) {
final PrincipalKey roleKey = ProjectAccessHelper.createRoleKey(projectName, projectRole);
final String newRoleDisplayName = createRoleDisplayName(projectRole);
securityService.getRole(roleKey).filter(role -> !newRoleDisplayName.equals(role.getDisplayName())).ifPresent((roleValue) -> doUpdateRoleDisplayName(roleValue, newRoleDisplayName));
}
}
use of com.enonic.xp.security.PrincipalKey in project xp by enonic.
the class CreateProjectRolesCommand method doCreateRoles.
private void doCreateRoles() {
for (ProjectRole projectRole : ProjectRole.values()) {
final PrincipalKey roleKey = ProjectAccessHelper.createRoleKey(projectName, projectRole);
final String roleDisplayName = createRoleDisplayName(projectRole);
securityService.getRole(roleKey).orElseGet(() -> doCreateRole(roleKey, roleDisplayName));
}
}
use of com.enonic.xp.security.PrincipalKey in project xp by enonic.
the class EditableScheduledJobTest method testChanged.
@Test
public void testChanged() {
final ScheduledJob source = ScheduledJob.create().name(ScheduledJobName.from("name")).descriptor(DescriptorKey.from("app:key")).calendar(mock(ScheduleCalendar.class)).creator(PrincipalKey.from("user:system:creator")).modifier(PrincipalKey.from("user:system:creator")).createdTime(Instant.parse("2016-11-02T10:36:00Z")).modifiedTime(Instant.parse("2016-11-02T10:36:00Z")).build();
final PrincipalKey user = PrincipalKey.ofUser(IdProviderKey.createDefault(), "user");
final DescriptorKey descriptor = DescriptorKey.from(ApplicationKey.BASE, "descriptor");
final PropertyTree config = new PropertyTree();
config.addString("property", "value");
final String description = "description";
final EditableScheduledJob editable = new EditableScheduledJob(source);
editable.config = config;
editable.user = user;
editable.descriptor = descriptor;
editable.description = description;
editable.calendar = mock(ScheduleCalendar.class);
editable.enabled = true;
final ScheduledJob target = editable.build();
assertEquals(source.getName(), target.getName());
assertEquals(config, target.getConfig());
assertEquals(user, target.getUser());
assertEquals(descriptor, target.getDescriptor());
assertEquals(description, target.getDescription());
assertTrue(target.isEnabled());
}
Aggregations