当前位置:网站首页>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;
}
}边栏推荐
- Methods for MySQL to avoid inserting duplicate records
- QUIC or TCP
- Reading redis source code (V) master-slave replication and sentinel mechanism
- method
- Qingdao stadium has made headlines again, but it has nothing to do with sports
- CFS After the CHM file is opened, the hyperlink content cannot be loaded and blank is displayed
- Record a penetration caused by log4j
- How to customize a finished label template
- How to gracefully solve the problem of platform font adaptation
- The commercial s2b2b e-commerce platform of aquatic industry improves the competitiveness of enterprises and creates a strong engine for industrial development
猜你喜欢

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
What is sitelock? What is the function?

Vulnhub DC-5

5. concept of ruler method

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

C language series - Section 4 - arrays

6. template for integer and real number dichotomy

8. greed
随机推荐
Simple implementation of promise basic method
How to make keyword targeted layout based on search sources?
Reading redis source code (VI) multi threading of redis 6.0
Construction and exploration of vivo database and storage platform
Section 6: basic configuration I of spingboot
Quic implementation in rust --- Quinn
Initial xxE
The difference between the use of return, break and continue in the if statement in JS
How to generate DataMatrix code in batch through TXT file
Reading redis source code (II) underlying data structure
2022-02-05: the k-th decimal number of dictionary order. Given integers n and K, find 1
Redis source code reading (I) general overview
Applet control version update best practices
[SaaS examination certification] apaas_ Tencent Qianfan magic pen
Concept and function of ES6 symbol
Vulnhub DC-5
Pytest common summary
Use ES6 new Target to simulate abstract classes
Methods for MySQL to avoid inserting duplicate records
Golang string comparison