Skip navigation links
JNA API 5.10.0
com.sun.jna.platform.win32

Class Advapi32Util.Privilege

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Enclosing class:
    Advapi32Util


    public static class Advapi32Util.Privilege
    extends java.lang.Object
    implements java.io.Closeable
    Convenience class to enable certain Windows process privileges
    • Constructor Summary

      Constructors 
      Constructor and Description
      Privilege(java.lang.String... privileges)
      Construct and enable a set of privileges
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void close()
      Calls disable() to remove the privileges
      void disable()
      Disabled the prior enabled privilege
      Advapi32Util.Privilege enable()
      Enables the given privileges.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Privilege

        public Privilege(java.lang.String... privileges)
                  throws java.lang.IllegalArgumentException,
                         Win32Exception
        Construct and enable a set of privileges
        Parameters:
        privileges - the names of the privileges in the form of SE_* from Advapi32.java
        Throws:
        java.lang.IllegalArgumentException
        Win32Exception
    • Method Detail

      • close

        public void close()
        Calls disable() to remove the privileges
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface java.lang.AutoCloseable
        See Also:
        Closeable.close()
      • enable

        public Advapi32Util.Privilege enable()
                                      throws Win32Exception
        Enables the given privileges. If required, it will duplicate the process token. No resources are left open when this completes. That is, it is NOT required to drop the privileges, although it is considered a best practice if you do not need it. This class is state full. It keeps track of whether it has enabled the privileges. Multiple calls to enable() without a drop() in between have no affect.
        Returns:
        pointer to self (Privilege) as a convenience for try with resources statements
        Throws:
        Win32Exception
JNA API 5.10.0

Copyright © 2007-2018 Timothy Wall. All Rights Reserved.