sun.security.action.GetPropertyAction Java Examples
The following examples show how to use
sun.security.action.GetPropertyAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Debug.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return the value of the boolean System property propName. * * Note use of doPrivileged(). Do make accessible to applications. */ static boolean getBooleanProperty(String propName, boolean defaultValue) { // if set, require value of either true or false String b = AccessController.doPrivileged( new GetPropertyAction(propName)); if (b == null) { return defaultValue; } else if (b.equalsIgnoreCase("false")) { return false; } else if (b.equalsIgnoreCase("true")) { return true; } else { throw new RuntimeException("Value of " + propName + " must either be 'true' or 'false'"); } }
Example #2
Source File: Window.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private void setWarningString() { warningString = null; SecurityManager sm = System.getSecurityManager(); if (sm != null) { try { sm.checkPermission(SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION); } catch (SecurityException se) { // make sure the privileged action is only // for getting the property! We don't want the // above checkPermission call to always succeed! warningString = AccessController.doPrivileged( new GetPropertyAction("awt.appletWarning", "Java Applet Window")); } } }
Example #3
Source File: JRSUIUtils.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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; }
Example #4
Source File: GSSUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Determines if the application doesn't mind if the mechanism obtains * the required credentials from outside of the current Subject. Our * Kerberos v5 mechanism would do a JAAS login on behalf of the * application if this were the case. * * The application indicates this by explicitly setting the system * property javax.security.auth.useSubjectCredsOnly to false. */ public static boolean useSubjectCredsOnly(GSSCaller caller) { // HTTP/SPNEGO doesn't use the standard JAAS framework. Instead, it // uses the java.net.Authenticator style, therefore always return // false here. if (caller instanceof HttpCaller) { return false; } /* * Don't use GetBooleanAction because the default value in the JRE * (when this is unset) has to treated as true. */ String propValue = AccessController.doPrivileged( new GetPropertyAction("javax.security.auth.useSubjectCredsOnly", "true")); /* * This property has to be explicitly set to "false". Invalid * values should be ignored and the default "true" assumed. */ return (!propValue.equalsIgnoreCase("false")); }
Example #5
Source File: GSSUtil.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Determines if the application doesn't mind if the mechanism obtains * the required credentials from outside of the current Subject. Our * Kerberos v5 mechanism would do a JAAS login on behalf of the * application if this were the case. * * The application indicates this by explicitly setting the system * property javax.security.auth.useSubjectCredsOnly to false. */ public static boolean useSubjectCredsOnly(GSSCaller caller) { // HTTP/SPNEGO doesn't use the standard JAAS framework. Instead, it // uses the java.net.Authenticator style, therefore always return // false here. if (caller instanceof HttpCaller) { return false; } /* * Don't use GetBooleanAction because the default value in the JRE * (when this is unset) has to treated as true. */ String propValue = AccessController.doPrivileged( new GetPropertyAction("javax.security.auth.useSubjectCredsOnly", "true")); /* * This property has to be explicitly set to "false". Invalid * values should be ignored and the default "true" assumed. */ return (!propValue.equalsIgnoreCase("false")); }
Example #6
Source File: JRSUIUtils.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #7
Source File: WindowsFileSystem.java From hottub with GNU General Public License v2.0 | 6 votes |
WindowsFileSystem(WindowsFileSystemProvider provider, String dir) { this.provider = provider; // parse default directory and check it is absolute WindowsPathParser.Result result = WindowsPathParser.parse(dir); if ((result.type() != WindowsPathType.ABSOLUTE) && (result.type() != WindowsPathType.UNC)) throw new AssertionError("Default directory is not an absolute path"); this.defaultDirectory = result.path(); this.defaultRoot = result.root(); PrivilegedAction<String> pa = new GetPropertyAction("os.version"); String osversion = AccessController.doPrivileged(pa); String[] vers = Util.split(osversion, '.'); int major = Integer.parseInt(vers[0]); int minor = Integer.parseInt(vers[1]); // symbolic links available on Vista and newer supportsLinks = (major >= 6); // enumeration of data streams available on Windows Server 2003 and newer supportsStreamEnumeration = (major >= 6) || (major == 5 && minor >= 2); }
Example #8
Source File: Locale.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static Locale initDefault() { String language, region, script, country, variant; Properties props = GetPropertyAction.privilegedGetProperties(); language = props.getProperty("user.language", "en"); // for compatibility, check for old user.region property region = props.getProperty("user.region"); if (region != null) { // region can be of form country, country_variant, or _variant int i = region.indexOf('_'); if (i >= 0) { country = region.substring(0, i); variant = region.substring(i + 1); } else { country = region; variant = ""; } script = ""; } else { script = props.getProperty("user.script", ""); country = props.getProperty("user.country", ""); variant = props.getProperty("user.variant", ""); } return getInstance(language, script, country, variant, null); }
Example #9
Source File: Locale.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static Locale initDefault(Locale.Category category) { return getInstance( AccessController.doPrivileged( new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())), AccessController.doPrivileged( new GetPropertyAction(category.scriptKey, defaultLocale.getScript())), AccessController.doPrivileged( new GetPropertyAction(category.countryKey, defaultLocale.getCountry())), AccessController.doPrivileged( new GetPropertyAction(category.variantKey, defaultLocale.getVariant())), null); }
Example #10
Source File: JISAutoDetect.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Returned Shift_JIS Charset name is OS dependent */ private static String getSJISName() { String osName = AccessController.doPrivileged( new GetPropertyAction("os.name")); if (osName.equals("Solaris") || osName.equals("SunOS")) return("PCK"); else if (osName.startsWith("Windows")) return("windows-31J"); else return("Shift_JIS"); }
Example #11
Source File: UIManager.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns the name of the <code>LookAndFeel</code> class that implements * the native system look and feel if there is one, otherwise * the name of the default cross platform <code>LookAndFeel</code> * class. This value can be overriden by setting the * <code>swing.systemlaf</code> system property. * * @return the <code>String</code> of the <code>LookAndFeel</code> * class * * @see #setLookAndFeel * @see #getCrossPlatformLookAndFeelClassName */ public static String getSystemLookAndFeelClassName() { String systemLAF = AccessController.doPrivileged( new GetPropertyAction("swing.systemlaf")); if (systemLAF != null) { return systemLAF; } OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction()); if (osType == OSInfo.OSType.WINDOWS) { return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } else { Toolkit toolkit = Toolkit.getDefaultToolkit(); if (toolkit instanceof SunToolkit) { SunToolkit suntk = (SunToolkit)toolkit; String desktop = suntk.getDesktop(); boolean gtkAvailable = suntk.isNativeGTKAvailable(); if ("gnome".equals(desktop) && gtkAvailable) { return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; } } if (osType == OSInfo.OSType.MACOSX) { if (toolkit.getClass() .getName() .equals("sun.lwawt.macosx.LWCToolkit")) { return "com.apple.laf.AquaLookAndFeel"; } } if (osType == OSInfo.OSType.SOLARIS) { return "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } } return getCrossPlatformLookAndFeelClassName(); }
Example #12
Source File: DefaultFileSystemProvider.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the default FileSystemProvider. */ public static FileSystemProvider create() { String osname = AccessController .doPrivileged(new GetPropertyAction("os.name")); if (osname.equals("SunOS")) return createProvider("sun.nio.fs.SolarisFileSystemProvider"); if (osname.equals("Linux")) return createProvider("sun.nio.fs.LinuxFileSystemProvider"); if (osname.contains("OS X")) return createProvider("sun.nio.fs.MacOSXFileSystemProvider"); if (osname.equals("AIX")) return createProvider("sun.nio.fs.AixFileSystemProvider"); throw new AssertionError("Platform not recognized"); }
Example #13
Source File: MetalLookAndFeel.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Return the theme currently being used by <code>MetalLookAndFeel</code>. * If the current theme is {@code null}, the default theme is created. * * @return the current theme * @see #setCurrentTheme * @since 1.5 */ public static MetalTheme getCurrentTheme() { MetalTheme currentTheme; AppContext context = AppContext.getAppContext(); currentTheme = (MetalTheme) context.get( "currentMetalTheme" ); if (currentTheme == null) { // This will happen in two cases: // . When MetalLookAndFeel is first being initialized. // . When a new AppContext has been created that hasn't // triggered UIManager to load a LAF. Rather than invoke // a method on the UIManager, which would trigger the loading // of a potentially different LAF, we directly set the // Theme here. if (useHighContrastTheme()) { currentTheme = new MetalHighContrastTheme(); } else { // Create the default theme. We prefer Ocean, but will // use DefaultMetalTheme if told to. String theme = AccessController.doPrivileged( new GetPropertyAction("swing.metalTheme")); if ("steel".equals(theme)) { currentTheme = new DefaultMetalTheme(); } else { currentTheme = new OceanTheme(); } } setCurrentTheme(currentTheme); } return currentTheme; }
Example #14
Source File: SunToolkit.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static boolean useSystemAAFontSettings() { if (!checkedSystemAAFontSettings) { useSystemAAFontSettings = true; /* initially set this true */ String systemAAFonts = null; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { systemAAFonts = AccessController.doPrivileged( new GetPropertyAction("awt.useSystemAAFontSettings")); } if (systemAAFonts != null) { useSystemAAFontSettings = Boolean.valueOf(systemAAFonts).booleanValue(); /* If it is anything other than "true", then it may be * a hint name , or it may be "off, "default", etc. */ if (!useSystemAAFontSettings) { desktopFontHints = getDesktopAAHintsByName(systemAAFonts); } } /* If its still true, apply the extra condition */ if (useSystemAAFontSettings) { useSystemAAFontSettings = lastExtraCondition; } checkedSystemAAFontSettings = true; } return useSystemAAFontSettings; }
Example #15
Source File: SwingUtilities.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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; }
Example #16
Source File: ThreadPool.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static int getDefaultThreadPoolInitialSize() { String propValue = AccessController.doPrivileged(new GetPropertyAction(DEFAULT_THREAD_POOL_INITIAL_SIZE)); if (propValue != null) { try { return Integer.parseInt(propValue); } catch (NumberFormatException x) { throw new Error("Value of property '" + DEFAULT_THREAD_POOL_INITIAL_SIZE + "' is invalid: " + x); } } return -1; }
Example #17
Source File: ProviderFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns an implementation of a {@code ProviderFactory} which * creates instances of Providers. * * The created Provider instances will be linked to all appropriate * and enabled system-defined tracing mechanisms in the JDK. * * @return a {@code ProviderFactory} that is used to create Providers. */ public static ProviderFactory getDefaultFactory() { HashSet<ProviderFactory> factories = new HashSet<ProviderFactory>(); // Try to instantiate a DTraceProviderFactory String prop = AccessController.doPrivileged( new GetPropertyAction("com.sun.tracing.dtrace")); if ( (prop == null || !prop.equals("disable")) && DTraceProviderFactory.isSupported() ) { factories.add(new DTraceProviderFactory()); } // Try to instantiate an output stream factory prop = AccessController.doPrivileged( new GetPropertyAction("sun.tracing.stream")); if (prop != null) { for (String spec : prop.split(",")) { PrintStream ps = getPrintStreamFromSpec(spec); if (ps != null) { factories.add(new PrintStreamProviderFactory(ps)); } } } // See how many factories we instantiated, and return an appropriate // factory that encapsulates that. if (factories.size() == 0) { return new NullProviderFactory(); } else if (factories.size() == 1) { return factories.toArray(new ProviderFactory[1])[0]; } else { return new MultiplexProviderFactory(factories); } }
Example #18
Source File: Util.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static boolean atBugLevel(String bl) { // package-private if (bugLevel == null) { if (!sun.misc.VM.isBooted()) return false; String value = AccessController.doPrivileged( new GetPropertyAction("sun.nio.ch.bugLevel")); bugLevel = (value != null) ? value : ""; } return bugLevel.equals(bl); }
Example #19
Source File: MetalLookAndFeel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Return the theme currently being used by <code>MetalLookAndFeel</code>. * If the current theme is {@code null}, the default theme is created. * * @return the current theme * @see #setCurrentTheme * @since 1.5 */ public static MetalTheme getCurrentTheme() { MetalTheme currentTheme; AppContext context = AppContext.getAppContext(); currentTheme = (MetalTheme) context.get( "currentMetalTheme" ); if (currentTheme == null) { // This will happen in two cases: // . When MetalLookAndFeel is first being initialized. // . When a new AppContext has been created that hasn't // triggered UIManager to load a LAF. Rather than invoke // a method on the UIManager, which would trigger the loading // of a potentially different LAF, we directly set the // Theme here. if (useHighContrastTheme()) { currentTheme = new MetalHighContrastTheme(); } else { // Create the default theme. We prefer Ocean, but will // use DefaultMetalTheme if told to. String theme = AccessController.doPrivileged( new GetPropertyAction("swing.metalTheme")); if ("steel".equals(theme)) { currentTheme = new DefaultMetalTheme(); } else { currentTheme = new OceanTheme(); } } setCurrentTheme(currentTheme); } return currentTheme; }
Example #20
Source File: WinNTFileSystem.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public WinNTFileSystem() { slash = AccessController.doPrivileged( new GetPropertyAction("file.separator")).charAt(0); semicolon = AccessController.doPrivileged( new GetPropertyAction("path.separator")).charAt(0); altSlash = (this.slash == '\\') ? '/' : '\\'; }
Example #21
Source File: Util.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static boolean atBugLevel(String bl) { // package-private if (bugLevel == null) { if (!sun.misc.VM.isBooted()) return false; String value = AccessController.doPrivileged( new GetPropertyAction("sun.nio.ch.bugLevel")); bugLevel = (value != null) ? value : ""; } return bugLevel.equals(bl); }
Example #22
Source File: SolarisFileSystemProvider.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override FileTypeDetector getFileTypeDetector() { Path userMimeTypes = Paths.get(AccessController.doPrivileged( new GetPropertyAction("user.home")), ".mime.types"); Path etcMimeTypes = Paths.get("/etc/mime.types"); return chain(new GnomeFileTypeDetector(), new MimeTypesFileTypeDetector(userMimeTypes), new MimeTypesFileTypeDetector(etcMimeTypes)); }
Example #23
Source File: MotifColorUtilities.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static void loadSystemColors(int[] systemColors) { if ("Linux".equals(AccessController.doPrivileged(new GetPropertyAction("os.name")))) { // Load motif default colors on Linux. loadMotifDefaultColors(systemColors); } else { try { loadSystemColorsForCDE(systemColors); } catch (Exception e) // Failure to load CDE colors. { loadMotifDefaultColors(systemColors); } } }
Example #24
Source File: DefaultSelectorProvider.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns the default SelectorProvider. */ public static SelectorProvider create() { String osname = AccessController .doPrivileged(new GetPropertyAction("os.name")); if (osname.equals("SunOS")) return createProvider("sun.nio.ch.DevPollSelectorProvider"); if (osname.equals("Linux")) return createProvider("sun.nio.ch.EPollSelectorProvider"); return new sun.nio.ch.PollSelectorProvider(); }
Example #25
Source File: LinuxFileSystemProvider.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override FileTypeDetector getFileTypeDetector() { Path userMimeTypes = Paths.get(AccessController.doPrivileged( new GetPropertyAction("user.home")), ".mime.types"); Path etcMimeTypes = Paths.get("/etc/mime.types"); return chain(new GnomeFileTypeDetector(), new MimeTypesFileTypeDetector(userMimeTypes), new MimeTypesFileTypeDetector(etcMimeTypes), new MagicFileTypeDetector()); }
Example #26
Source File: RMIMasterSocketFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Create a RMIMasterSocketFactory object. Establish order of * connection mechanisms to attempt on createSocket, if a direct * socket connection fails. */ public RMIMasterSocketFactory() { altFactoryList = new Vector<>(2); boolean setFactories = false; try { String proxyHost; proxyHost = java.security.AccessController.doPrivileged( new GetPropertyAction("http.proxyHost")); if (proxyHost == null) proxyHost = java.security.AccessController.doPrivileged( new GetPropertyAction("proxyHost")); boolean disable = java.security.AccessController.doPrivileged( new GetPropertyAction("java.rmi.server.disableHttp", "true")) .equalsIgnoreCase("true"); if (!disable && proxyHost != null && proxyHost.length() > 0) { setFactories = true; } } catch (Exception e) { // unable to obtain the properties, so use the default behavior. } if (setFactories) { altFactoryList.addElement(new RMIHttpToPortSocketFactory()); altFactoryList.addElement(new RMIHttpToCGISocketFactory()); } }
Example #27
Source File: UIManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns the name of the <code>LookAndFeel</code> class that implements * the native system look and feel if there is one, otherwise * the name of the default cross platform <code>LookAndFeel</code> * class. This value can be overriden by setting the * <code>swing.systemlaf</code> system property. * * @return the <code>String</code> of the <code>LookAndFeel</code> * class * * @see #setLookAndFeel * @see #getCrossPlatformLookAndFeelClassName */ public static String getSystemLookAndFeelClassName() { String systemLAF = AccessController.doPrivileged( new GetPropertyAction("swing.systemlaf")); if (systemLAF != null) { return systemLAF; } OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction()); if (osType == OSInfo.OSType.WINDOWS) { return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } else { String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop")); Toolkit toolkit = Toolkit.getDefaultToolkit(); if ("gnome".equals(desktop) && toolkit instanceof SunToolkit && ((SunToolkit) toolkit).isNativeGTKAvailable()) { // May be set on Linux and Solaris boxs. return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; } if (osType == OSInfo.OSType.MACOSX) { if (toolkit.getClass() .getName() .equals("sun.lwawt.macosx.LWCToolkit")) { return "com.apple.laf.AquaLookAndFeel"; } } if (osType == OSInfo.OSType.SOLARIS) { return "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } } return getCrossPlatformLookAndFeelClassName(); }
Example #28
Source File: SwingUtilities.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #29
Source File: DefaultFileSystemProvider.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns the default FileSystemProvider. */ public static FileSystemProvider create() { String osname = AccessController .doPrivileged(new GetPropertyAction("os.name")); if (osname.equals("SunOS")) return createProvider("sun.nio.fs.SolarisFileSystemProvider"); if (osname.equals("Linux")) return createProvider("sun.nio.fs.LinuxFileSystemProvider"); if (osname.contains("OS X")) return createProvider("sun.nio.fs.MacOSXFileSystemProvider"); if (osname.equals("AIX")) return createProvider("sun.nio.fs.AixFileSystemProvider"); throw new AssertionError("Platform not recognized"); }
Example #30
Source File: Util.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static boolean atBugLevel(String bl) { // package-private if (bugLevel == null) { if (!sun.misc.VM.isBooted()) return false; String value = AccessController.doPrivileged( new GetPropertyAction("sun.nio.ch.bugLevel")); bugLevel = (value != null) ? value : ""; } return bugLevel.equals(bl); }