Search in sources :

Example 1 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class TimeZone method setDefaultZone.

private static synchronized TimeZone setDefaultZone() {
    TimeZone tz;
    // get the time zone ID from the system properties
    String zoneID = AccessController.doPrivileged(new GetPropertyAction("user.timezone"));
    // platform to Java time zone ID mapping.
    if (zoneID == null || zoneID.isEmpty()) {
        String javaHome = AccessController.doPrivileged(new GetPropertyAction("java.home"));
        try {
            zoneID = getSystemTimeZoneID(javaHome);
            if (zoneID == null) {
                zoneID = GMT_ID;
            }
        } catch (NullPointerException e) {
            zoneID = GMT_ID;
        }
    }
    // Get the time zone for zoneID. But not fall back to
    // "GMT" here.
    tz = getTimeZone(zoneID, false);
    if (tz == null) {
        // If the given zone ID is unknown in Java, try to
        // get the GMT-offset-based time zone ID,
        // a.k.a. custom time zone ID (e.g., "GMT-08:00").
        String gmtOffsetID = getSystemGMTOffsetID();
        if (gmtOffsetID != null) {
            zoneID = gmtOffsetID;
        }
        tz = getTimeZone(zoneID, true);
    }
    assert tz != null;
    final String id = zoneID;
    AccessController.doPrivileged(new PrivilegedAction<Void>() {

        @Override
        public Void run() {
            System.setProperty("user.timezone", id);
            return null;
        }
    });
    defaultTimeZone = tz;
    return tz;
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Example 2 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class SwingUtilities method getSuppressDropTarget.

/**
     * Returns true if <code>setTransferHandler</code> should change the
     * <code>DropTarget</code>.
     */
private static boolean getSuppressDropTarget() {
    if (!checkedSuppressDropSupport) {
        suppressDropSupport = Boolean.valueOf(AccessController.doPrivileged(new GetPropertyAction("suppressSwingDropSupport")));
        checkedSuppressDropSupport = true;
    }
    return suppressDropSupport;
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Example 3 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class MetalLookAndFeel method isWindows.

/**
     * Returns true if running on Windows.
     */
static boolean isWindows() {
    if (!checkedWindows) {
        OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
        if (osType == OSInfo.OSType.WINDOWS) {
            isWindows = true;
            String systemFonts = AccessController.doPrivileged(new GetPropertyAction("swing.useSystemFontSettings"));
            useSystemFonts = (systemFonts != null && (Boolean.valueOf(systemFonts).booleanValue()));
        }
        checkedWindows = true;
    }
    return isWindows;
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Example 4 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class SunGraphicsEnvironment method getScaleFactor.

public static double getScaleFactor(String propertyName) {
    String scaleFactor = AccessController.doPrivileged(new GetPropertyAction(propertyName, "-1"));
    if (scaleFactor == null || scaleFactor.equals("-1")) {
        return -1;
    }
    try {
        double units = 1.0;
        if (scaleFactor.endsWith("x")) {
            scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 1);
        } else if (scaleFactor.endsWith("dpi")) {
            units = 96;
            scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 3);
        } else if (scaleFactor.endsWith("%")) {
            units = 100;
            scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 1);
        }
        double scale = Double.parseDouble(scaleFactor);
        return scale <= 0 ? -1 : scale / units;
    } catch (NumberFormatException ignored) {
        return -1;
    }
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Example 5 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class JRSUIUtils method currentMacOSXVersionMatchesGivenVersionRange.

static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
    // split the "10.x.y" version number
    String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
    String[] fragments = osVersion.split("\\.");
    // sanity check the "10." part of the version
    if (!fragments[0].equals("10"))
        return false;
    if (fragments.length < 2)
        return false;
    // check if os.version matches the given version using the given match method
    try {
        int minorVers = Integer.parseInt(fragments[1]);
        if (inclusive && minorVers == version)
            return true;
        if (matchBelow && minorVers < version)
            return true;
        if (matchAbove && minorVers > version)
            return true;
    } catch (NumberFormatException e) {
    // was not an integer
    }
    return false;
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Aggregations

GetPropertyAction (sun.security.action.GetPropertyAction)26 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Graphics (java.awt.Graphics)1 Rectangle (java.awt.Rectangle)1 Toolkit (java.awt.Toolkit)1 CMMException (java.awt.color.CMMException)1 ContainerEvent (java.awt.event.ContainerEvent)1 ContainerListener (java.awt.event.ContainerListener)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetSocketAddress (java.net.InetSocketAddress)1 Proxy (java.net.Proxy)1 ProxySelector (java.net.ProxySelector)1 ServerSocket (java.net.ServerSocket)1 SocketException (java.net.SocketException)1 URI (java.net.URI)1