// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/model/Role.java
// public enum Role {
//     GUEST, USER, ADMIN, SYSTEM;
// }


import java.util.Arrays;
import java.util.concurrent.Callable;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import com.coverity.security.pie.example.model.Role;
package com.coverity.security.pie.example.util;




public class DoPrivileged {
    public static <T> T asSystem(Callable<T> callable) throws Exception {
        final SecurityContext priorContext = SecurityContextHolder.getContext();
        try {
            SecurityContextHolder.setContext(SecurityContextHolder.createEmptyContext());
            PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/model/Role.java
// public enum Role {
//     GUEST, USER, ADMIN, SYSTEM;
// }


// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/util/DoPrivileged.java
import java.util.Arrays;
import java.util.concurrent.Callable;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import com.coverity.security.pie.example.model.Role;

package com.coverity.security.pie.example.util;




public class DoPrivileged {
    public static <T> T asSystem(Callable<T> callable) throws Exception {
        final SecurityContext priorContext = SecurityContextHolder.getContext();
        try {
            SecurityContextHolder.setContext(SecurityContextHolder.createEmptyContext());
            PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(
                    "system", null, Arrays.asList(new SimpleGrantedAuthority(Role.SYSTEM.toString())));