package nxm.sys.lib;

/**
  Security privileges

  @author Jay Hallam
*/
public class Privileges {

  /** Privilege mask string list*/
  public static final String privsList = "EXECUTE,QUERYOS,SOCKET,FILE,NATIVE,MULTICAST";

  /** Privilege masks: <pre>
      PRIV_EXECUTE   = execute OS commands
      PRIV_QUERYOS   = query OS and System properties (was used for unsigned Applets, but Applet support has been removed)
      PRIV_SOCKET    = enable network sockets access
      PRIV_FILE      = enable file access
      PRIV_NATIVE    = enable native code
      PRIV_MULTICAST = enable sending multicast network packets
      PRIV_NONE      = no privileges (0)
      PRIV_ALL       = enable all privileges (-1 = all bits set)
      </pre>
   */
  public static final int PRIV_EXECUTE=0x1, PRIV_QUERYOS=0x2, PRIV_SOCKET=0x4,
                          PRIV_FILE=0x8,    PRIV_NATIVE=0x10, PRIV_MULTICAST=0x20,
                          PRIV_NONE=0,      PRIV_ALL=-1;

  /** No argument constructor */
  @Deprecated
  public Privileges () { // TODO: deprecated this unused constructor
  }

  /** Get the privileges mask string
   *  @return the privileges mask string only for the enumerated ones in {@link #privsList} */
  public static String getPrivMaskString () {
    int mask = Shell.privs; //should be Shell.getPrivs();
    String maskStr = null;
    if (mask == -1 ) maskStr = "ALL";
    else             maskStr = Parser.mask2s(Privileges.privsList, mask);
    return maskStr;
  }

}
