本文整理汇总了Java中org.activiti.engine.impl.identity.Authentication类的典型用法代码示例。如果您正苦于以下问题:Java Authentication类的具体用法?Java Authentication怎么用?Java Authentication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Authentication类属于org.activiti.engine.impl.identity包,在下文中一共展示了Authentication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDelete
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public void onDelete(DelegateTask delegateTask) throws Exception {
HumanTaskDTO humanTaskDto = humanTaskConnector
.findHumanTaskByTaskId(delegateTask.getId());
if (humanTaskDto == null) {
return;
}
if ("complete".equals(humanTaskDto.getStatus())) {
return;
}
humanTaskDto.setStatus("delete");
humanTaskDto.setCompleteTime(new Date());
humanTaskDto.setAction("人工终止");
humanTaskDto.setOwner(humanTaskDto.getAssignee());
humanTaskDto.setAssignee(Authentication.getAuthenticatedUserId());
humanTaskConnector.saveHumanTask(humanTaskDto, false);
}
示例2: onDelete
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
@Override
public void onDelete(DelegateTask delegateTask) throws Exception {
HumanTaskDTO humanTaskDto = humanTaskConnector
.findHumanTaskByTaskId(delegateTask.getId());
if (humanTaskDto == null) {
return;
}
if (!"complete".equals(humanTaskDto.getStatus())) {
humanTaskDto.setStatus("delete");
humanTaskDto.setCompleteTime(new Date());
humanTaskDto.setAction("人工终止");
humanTaskDto.setOwner(humanTaskDto.getAssignee());
humanTaskDto.setAssignee(Authentication.getAuthenticatedUserId());
humanTaskConnector.saveHumanTask(humanTaskDto, false);
}
}
示例3: execute
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
TaskEntity taskEntity = commandContext.getTaskEntityManager()
.findTaskById(taskId);
// taskEntity.fireEvent(TaskListener.EVENTNAME_COMPLETE);
if ((Authentication.getAuthenticatedUserId() != null)
&& (taskEntity.getProcessInstanceId() != null)) {
taskEntity.getProcessInstance().involveUser(
Authentication.getAuthenticatedUserId(),
IdentityLinkType.PARTICIPANT);
}
Context.getCommandContext().getTaskEntityManager()
.deleteTask(taskEntity, comment, false);
if (taskEntity.getExecutionId() != null) {
ExecutionEntity execution = taskEntity.getExecution();
execution.removeTask(taskEntity);
// execution.signal(null, null);
}
return null;
}
示例4: testParticipantUserLink
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
@Deployment(resources = "org/activiti/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml")
public void testParticipantUserLink() {
Authentication.setAuthenticatedUserId(null);
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String processInstanceId = runtimeService
.createProcessInstanceQuery()
.singleResult()
.getId();
runtimeService.addParticipantUser(processInstanceId, "kermit");
List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId);
IdentityLink identityLink = identityLinks.get(0);
assertNull(identityLink.getGroupId());
assertEquals("kermit", identityLink.getUserId());
assertEquals(IdentityLinkType.PARTICIPANT, identityLink.getType());
assertEquals(processInstanceId, identityLink.getProcessInstanceId());
assertEquals(1, identityLinks.size());
runtimeService.deleteParticipantUser(processInstanceId, "kermit");
assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size());
}
示例5: testCustomTypeUserLink
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
@Deployment(resources = "org/activiti/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml")
public void testCustomTypeUserLink() {
Authentication.setAuthenticatedUserId(null);
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String processInstanceId = runtimeService
.createProcessInstanceQuery()
.singleResult()
.getId();
runtimeService.addUserIdentityLink(processInstanceId, "kermit", "interestee");
List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId);
IdentityLink identityLink = identityLinks.get(0);
assertNull(identityLink.getGroupId());
assertEquals("kermit", identityLink.getUserId());
assertEquals("interestee", identityLink.getType());
assertEquals(processInstanceId, identityLink.getProcessInstanceId());
assertEquals(1, identityLinks.size());
runtimeService.deleteUserIdentityLink(processInstanceId, "kermit", "interestee");
assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size());
}
示例6: testCustomLinkGroupLink
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
@Deployment(resources = "org/activiti/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml")
public void testCustomLinkGroupLink() {
Authentication.setAuthenticatedUserId(null);
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String processInstanceId = runtimeService
.createProcessInstanceQuery()
.singleResult()
.getId();
runtimeService.addGroupIdentityLink(processInstanceId, "muppets", "playing");
List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId);
IdentityLink identityLink = identityLinks.get(0);
assertEquals("muppets", identityLink.getGroupId());
assertNull("kermit", identityLink.getUserId());
assertEquals("playing", identityLink.getType());
assertEquals(processInstanceId, identityLink.getProcessInstanceId());
assertEquals(1, identityLinks.size());
runtimeService.deleteGroupIdentityLink(processInstanceId, "muppets", "playing");
assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size());
}
示例7: testProcessInstanceIdentityDeleteCandidateGroupEvents
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
/**
* Check deletion of links on process instances.
*/
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceIdentityDeleteCandidateGroupEvents() throws Exception {
Authentication.setAuthenticatedUserId(null);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
// Add identity link
taskService.addCandidateUser(task.getId(), "kermit");
taskService.addCandidateGroup(task.getId(), "sales");
// Three events are received, since the user link on the task also creates an involvement in the process. See previous test
assertEquals(6, listener.getEventsReceived().size());
listener.clearEventsReceived();
taskService.deleteCandidateUser(task.getId(), "kermit");
assertEquals(1, listener.getEventsReceived().size());
listener.clearEventsReceived();
taskService.deleteCandidateGroup(task.getId(), "sales");
assertEquals(1, listener.getEventsReceived().size());
}
示例8: HistoricProcessInstanceEntity
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public HistoricProcessInstanceEntity(ExecutionEntity processInstance) {
id = processInstance.getId();
processInstanceId = processInstance.getId();
businessKey = processInstance.getBusinessKey();
processDefinitionId = processInstance.getProcessDefinitionId();
processDefinitionKey = processInstance.getProcessDefinitionKey();
processDefinitionName = processInstance.getProcessDefinitionName();
processDefinitionVersion = processInstance.getProcessDefinitionVersion();
deploymentId = processInstance.getDeploymentId();
startTime = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
startUserId = Authentication.getAuthenticatedUserId();
startActivityId = processInstance.getActivityId();
superProcessInstanceId = processInstance.getSuperExecution() != null ? processInstance.getSuperExecution().getProcessInstanceId() : null;
// Inherit tenant id (if applicable)
if (processInstance.getTenantId() != null) {
tenantId = processInstance.getTenantId();
}
}
示例9: createAttachmentComment
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
@Override
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
if (isHistoryEnabled()) {
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime());
comment.setTaskId(taskId);
comment.setProcessInstanceId(processInstanceId);
if (create) {
comment.setAction(Event.ACTION_ADD_ATTACHMENT);
} else {
comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
}
comment.setMessage(attachmentName);
getSession(CommentEntityManager.class).insert(comment);
}
}
示例10: onRequestEnd
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public void onRequestEnd(HttpServletRequest request, HttpServletResponse response) {
// Clean up thread-local app
current.remove();
// Clear authentication context
Authentication.setAuthenticatedUserId(null);
// Callback to the login handler
loginHandler.onRequestEnd(request, response);
if(!isRunning() && !invalidatedSession) {
// Clear the session context, the application has been closed during this request, otherwise
// the application will be stuck on the spring-session scope and will be reused on the next
// request, which will lead to problems
if(request.getSession(false) != null) {
request.getSession().invalidate();
invalidatedSession = true;
}
}
}
示例11: execute
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_COMMENT);
comment.setTime(ClockUtil.getCurrentTime());
comment.setTaskId(taskId);
comment.setProcessInstanceId(processInstanceId);
comment.setAction(Event.ACTION_ADD_COMMENT);
String eventMessage = message.replaceAll("\\s+", " ");
if (eventMessage.length()>163) {
eventMessage = eventMessage.substring(0, 160)+"...";
}
comment.setMessage(eventMessage);
comment.setFullMessage(message);
commandContext
.getCommentManager()
.insert(comment);
return null;
}
示例12: execute
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
AttachmentEntity attachment = commandContext
.getDbSqlSession()
.selectById(AttachmentEntity.class, attachmentId);
commandContext
.getDbSqlSession()
.delete(AttachmentEntity.class, attachmentId);
if (attachment.getTaskId()!=null) {
CommentManager commentManager = commandContext.getCommentManager();
if (commentManager.isHistoryEnabled()) {
String authenticatedUserId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(authenticatedUserId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(ClockUtil.getCurrentTime());
comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
comment.setMessage(attachment.getName());
comment.setTaskId(attachment.getTaskId());
commentManager.insert(comment);
}
}
return null;
}
示例13: testAuthenticatedUserIdAvailable
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
@Deployment
public void testAuthenticatedUserIdAvailable() {
try {
// Setup authentication
Authentication.setAuthenticatedUserId("frederik");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testAuthenticatedUserIdAvailableProcess");
// Check if the variable that has been set in service-task is the authenticated user
String value = (String) runtimeService.getVariable(processInstance.getId(), "theUser");
assertNotNull(value);
assertEquals("frederik", value);
} finally {
// Cleanup
Authentication.setAuthenticatedUserId(null);
}
}
示例14: complete
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
public void complete() {
fireEvent(TaskListener.EVENTNAME_COMPLETE);
if (Authentication.getAuthenticatedUserId() != null && processInstanceId != null) {
getProcessInstance().involveUser(Authentication.getAuthenticatedUserId(), IdentityLinkType.PARTICIPANT);
}
Context
.getCommandContext()
.getTaskEntityManager()
.deleteTask(this, TaskEntity.DELETE_REASON_COMPLETED, false);
if (executionId!=null) {
ExecutionEntity execution = getExecution();
execution.removeTask(this);
execution.signal(null, null);
}
}
示例15: createAttachmentComment
import org.activiti.engine.impl.identity.Authentication; //导入依赖的package包/类
/**
* Creates a new comment to indicate a new attachment has been created or deleted,
* if history is enabled.
*/
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
if (isHistoryEnabled()) {
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(ClockUtil.getCurrentTime());
comment.setTaskId(taskId);
comment.setProcessInstanceId(processInstanceId);
if(create) {
comment.setAction(Event.ACTION_ADD_ATTACHMENT);
} else {
comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
}
comment.setMessage(attachmentName);
getSession(CommentEntityManager.class).insert(comment);
}
}