当前位置:网站首页>Flowable refactoring process editor to obtain user information
Flowable refactoring process editor to obtain user information
2022-06-23 03:03:00 【FHAdmin】
package org.flowable.ui.common.security;
import org.fh.util.Jurisdiction;
import org.flowable.common.engine.api.FlowableIllegalStateException;
import org.flowable.idm.api.User;
import org.flowable.ui.common.model.RemoteUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* explain : Refactoring process editor to get user information
* author :FH Admin
* from:fhadmin.cn
*/
public class SecurityUtils {
private static User assumeUser;
private static SecurityScopeProvider securityScopeProvider = new FlowableSecurityScopeProvider();
private SecurityUtils() {
}
/**
* Get the login of the current user.
*/
public static String getCurrentUserId() {
User user = getCurrentUserObject();
if (user != null) {
return user.getId();
}
return null;
}
/**
* @return the {@link User} object associated with the current logged in user.
*/
public static User getCurrentUserObject() {
if (assumeUser != null) {
return assumeUser;
}
RemoteUser user = new RemoteUser();
user.setId(Jurisdiction.getUsername());
user.setDisplayName(Jurisdiction.getName());
user.setFirstName(Jurisdiction.getName());
user.setLastName(Jurisdiction.getName());
user.setEmail("[email protected]");
user.setPassword("123456");
List<String> pris = new ArrayList<>();
pris.add(DefaultPrivileges.ACCESS_MODELER);
pris.add(DefaultPrivileges.ACCESS_IDM);
pris.add(DefaultPrivileges.ACCESS_ADMIN);
pris.add(DefaultPrivileges.ACCESS_TASK);
pris.add(DefaultPrivileges.ACCESS_REST_API);
user.setPrivileges(pris);
return user;
}
public static void setSecurityScopeProvider(SecurityScopeProvider securityScopeProvider) {
SecurityUtils.securityScopeProvider = securityScopeProvider;
}
public static SecurityScope getCurrentSecurityScope() {
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext != null && securityContext.getAuthentication() != null) {
return getSecurityScope(securityContext.getAuthentication());
}
return null;
}
public static SecurityScope getSecurityScope(Authentication authentication) {
return securityScopeProvider.getSecurityScope(authentication);
}
public static SecurityScope getAuthenticatedSecurityScope() {
SecurityScope currentSecurityScope = getCurrentSecurityScope();
if (currentSecurityScope != null) {
return currentSecurityScope;
}
throw new FlowableIllegalStateException("User is not authenticated");
}
public static void assumeUser(User user) {
assumeUser = user;
}
public static void clearAssumeUser() {
assumeUser = null;
}
}边栏推荐
- Goframe framework (RK boot): rapid configuration of server CORS
- 2022-01-30: minimum good base. For a given integer n, if K (k) of n
- No error is reported when using the Gorm framework to create a table, but the data cannot be inserted successfully
- Dynamic filling of drop-down box with micro overlap
- Call rest port to implement nailing notification
- New uniapp+uniui background management uniuadmin
- How to make keyword targeted layout based on search sources?
- Docker builds redis3 master-slave cluster and expands the capacity
- Aiot application innovation competition -- I am the master of my project, and use gn+ninja to complete the system construction (vscode Development)
- Cve-2021-4034 reappearance
猜你喜欢

Soft exam information system project manager_ Contract Law_ Copyright_ Implementation Regulations - Senior Information System Project Manager of soft exam 030

How to store, manage and view family photos in an orderly manner?

Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027

8. greed

5. concept of ruler method
What is sitelock? What is the function?

C language series - Section 4 - arrays

Vulnhub DC-5

6. template for integer and real number dichotomy
随机推荐
What if the software gets stuck and cannot end the process?
Biological psychiatry: defining individualized functional neuroanatomy for precision psychiatry
How to batch generate matrix 25 codes
Reading redis source code (II) underlying data structure
51. numerical arrangement
Account protection and use scheme
Methods for MySQL to avoid inserting duplicate records
WPF developer essential control library newbeecoder UI —NbMessageBox
How to gracefully solve the problem of platform font adaptation
Windows system poisoning, SQL Server database file recovery rescue and OA program file recovery
Pond sampling
Calling applet demo modifying the default large screen view
Establishment of JMeter distributed pressure measurement environment
Reading redis source code (V) master-slave replication and sentinel mechanism
2022-01-28: for example, {5, 3, 1, 4} all number pairs are: (5,3), (5,1)
PNAs: power spectrum shows obvious bold resting state time process in white matter
Optimization method of live weak network
Redis source code reading (I) general overview
The priority supplier field in the purchase information record of SAP mm primary level
DNS Service Setup