Tabnine Logo
PrivilegedAction
Code IndexAdd Tabnine to your IDE (free)

How to use
PrivilegedAction
in
java.security

Best Java code snippets using java.security.PrivilegedAction (Showing top 20 results out of 7,236)

Refine searchRefine arrow

  • AccessController
origin: wildfly/wildfly

private static <T> T doPrivileged(PrivilegedAction<T> action) {
 if (System.getSecurityManager() != null) {
   return AccessController.doPrivileged(action);
 } else {
   return action.run();
 }
}
origin: stackoverflow.com

 public static Charset defaultCharset() {
synchronized (Charset.class) {
  if (defaultCharset == null) {
  java.security.PrivilegedAction pa =
    new GetPropertyAction("file.encoding");
  String csn = (String)AccessController.doPrivileged(pa);
  Charset cs = lookup(csn);
  if (cs != null)
    return cs;
  return forName("UTF-8");
  }
  return defaultCharset;
}
}
origin: robovm/robovm

/**
 * Calls {@code action.run()}.
 */
public static <T> T doPrivileged(PrivilegedAction<T> action, AccessControlContext context) {
  return action.run();
}
origin: robovm/robovm

/**
 * Calls {@code action.run()}.
 */
public static <T> T doPrivileged(PrivilegedAction<T> action) {
  return action.run();
}
origin: javax.validation/validation-api

  private <P> P run(PrivilegedAction<P> action) {
    return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run();
  }
}
origin: stackoverflow.com

 public static Charset defaultCharset() {
  if (defaultCharset == null) {
  synchronized (Charset.class) {
  java.security.PrivilegedAction pa =
    new GetPropertyAction("file.encoding");
  String csn = (String)AccessController.doPrivileged(pa);
  Charset cs = lookup(csn);
  if (cs != null)
    defaultCharset = cs;
      else 
    defaultCharset = forName("UTF-8");
    }
}
return defaultCharset;
}
origin: robovm/robovm

/**
 * Calls {@code action.run()}.
 */
public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
  return action.run();
}
origin: org.apache.logging.log4j/log4j-api

/**
 * Gets the current Thread ClassLoader. Returns the system ClassLoader if the TCCL is {@code null}. If the system
 * ClassLoader is {@code null} as well, then the ClassLoader for this class is returned. If running with a
 * {@link SecurityManager} that does not allow access to the Thread ClassLoader or system ClassLoader, then the
 * ClassLoader for this class is returned.
 *
 * @return the current ThreadContextClassLoader.
 */
public static ClassLoader getThreadContextClassLoader() {
  if (GET_CLASS_LOADER_DISABLED) {
    // we can at least get this class's ClassLoader regardless of security context
    // however, if this is null, there's really no option left at this point
    return LoaderUtil.class.getClassLoader();
  }
  return SECURITY_MANAGER == null ? TCCL_GETTER.run() : AccessController.doPrivileged(TCCL_GETTER);
}
origin: apache/flume

@Override
public <T> T execute(PrivilegedAction<T> action) {
 return action.run();
}
origin: hibernate/hibernate-orm

private static Method doPrivilegedAction(PrivilegedAction<Method> privilegedAction) {
  Class<?> callerClass = getCallerClass();
  if ( !authorizedClasses.contains( callerClass.getName() ) ) {
    throw new SecurityException( "Unauthorized call by class " + callerClass );
  }
  return System.getSecurityManager() != null ? AccessController.doPrivileged( privilegedAction ) :
    privilegedAction.run();
}
origin: alibaba/druid

public static <T> T doPrivileged(PrivilegedAction<T> action) {
  final Boolean original = privileged.get();
  privileged.set(Boolean.TRUE);
  try {
    return action.run();
  } finally {
    privileged.set(original);
  }
}
origin: hibernate/hibernate-orm

  private AttributeAccess buildAttributeAccess(final String attributeName) {
    final PrivilegedAction<AttributeAccess> action = new PrivilegedAction<AttributeAccess>() {
      @Override
      public AttributeAccess run() {
        for ( Class clazz : classHierarchy ) {
          try {
            final Field field = clazz.getDeclaredField( attributeName );
            if ( field != null ) {
              return new FieldAttributeAccess( field );
            }
          }
          catch ( NoSuchFieldException e ) {
            final Method method = getMethod( clazz, attributeName );
            if ( method != null ) {
              return new MethodAttributeAccess( attributeName, method );
            }
          }
        }
        //we could not find any match
        return new NoSuchAttributeAccess( specifiedClass, attributeName );
      }
    };
    return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run();
  }
}
origin: robovm/robovm

    public Object call() { return action.run(); }};
}
origin: wildfly/wildfly

/**
 * Perform an action with permission checking enabled.  If permission checking is already enabled, the action is
 * simply run.
 *
 * @param action the action to perform
 * @param context the access control context to use
 * @param <T> the action return type
 * @return the return value of the action
 */
public static <T> T doChecked(PrivilegedAction<T> action, AccessControlContext context) {
  final Context ctx = CTX.get();
  if (ctx.checking) {
    return action.run();
  }
  ctx.checking = true;
  try {
    return AccessController.doPrivileged(action, context);
  } finally {
    ctx.checking = false;
  }
}
origin: wildfly/wildfly

/**
 * Perform an action with permission checking enabled.  If permission checking is already enabled, the action is
 * simply run.
 *
 * @param action the action to perform
 * @param <T> the action return type
 * @return the return value of the action
 */
public static <T> T doChecked(PrivilegedAction<T> action) {
  final Context ctx = CTX.get();
  if (ctx.checking) {
    return action.run();
  }
  ctx.checking = true;
  try {
    return action.run();
  } finally {
    ctx.checking = false;
  }
}
origin: wildfly/wildfly

static <T> T doPrivileged(final PrivilegedAction<T> action) {
  return WildFlySecurityManager.isChecking() ? AccessController.doPrivileged(action) : action.run();
}
origin: wildfly/wildfly

/**
 * Perform an action with permission checking disabled.  If permission checking is already disabled, the action is
 * simply run.  The immediate caller must have the {@code doUnchecked} runtime permission.
 *
 * @param action the action to perform
 * @param <T> the action return type
 * @return the return value of the action
 */
public static <T> T doUnchecked(PrivilegedAction<T> action) {
  final Context ctx = CTX.get();
  if (! ctx.checking) {
    return action.run();
  }
  ctx.checking = false;
  try {
    final SecurityManager sm = getSecurityManager();
    if (sm != null) {
      checkPDPermission(getCallerClass(2), doUncheckedPermission);
    }
    return action.run();
  } finally {
    ctx.checking = true;
  }
}
origin: hibernate/hibernate-orm

return System.getSecurityManager() != null ? AccessController.doPrivileged( getCallerClassAction ) :
    getCallerClassAction.run();
origin: org.mongodb/mongo-java-driver

void doAsSubject(final java.security.PrivilegedAction<Void> action) {
  if (getSubject() == null) {
    action.run();
  } else {
    Subject.doAs(getSubject(), action);
  }
}
origin: wildfly/wildfly

@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
  // TODO - special cases need to be handled where SecurityContext not established or minimal unauthenticated principal context instead.
  String previousContextID = this.setContextID(this.policyContextID);
  if (WildFlySecurityManager.isChecking()) {
    doPrivileged(pushAction);
  } else {
    pushAction.run();
  }
  try {
    return context.proceed();
  } finally {
    this.setContextID(previousContextID);
    if (WildFlySecurityManager.isChecking()) {
      doPrivileged(popAction);
    } else {
      popAction.run();
    }
  }
}
java.securityPrivilegedAction

Javadoc

Legacy security code; do not use.

Most used methods

  • run
    Performs the computation. This method will be called by AccessController.doPrivileged after enabling
  • <init>

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now