javax.security.auth.AuthPermission Java Examples
The following examples show how to use
javax.security.auth.AuthPermission.
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: ConfigFile.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #2
Source File: ConfigFile.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #3
Source File: ConfigFile.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #4
Source File: ConfigFile.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #5
Source File: ConfigFile.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #6
Source File: ConfigFile.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #7
Source File: ConfigFile.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #8
Source File: ConfigFile.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #9
Source File: ConfigFile.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Refresh and reload the Configuration by re-reading all of the * login configurations. * * @throws SecurityException if the caller does not have permission * to refresh the Configuration. */ @Override public synchronized void engineRefresh() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("refreshLoginConfiguration")); } AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { try { init(); } catch (IOException ioe) { throw new SecurityException(ioe.getLocalizedMessage(), ioe); } return null; } }); }
Example #10
Source File: ProtectedResource.java From quarkus with Apache License 2.0 | 5 votes |
@GET @Produces(MediaType.APPLICATION_JSON) public Uni<List<Permission>> permissions() { return identity.checkPermission(new AuthPermission("Permission Resource")).onItem() .apply(new Function<Boolean, List<Permission>>() { @Override public List<Permission> apply(Boolean granted) { if (granted) { return identity.getAttribute("permissions"); } throw new ForbiddenException(); } }); }
Example #11
Source File: ProtectedResource.java From quarkus with Apache License 2.0 | 5 votes |
@GET @Produces(MediaType.APPLICATION_JSON) public Uni<List<Permission>> permissions() { return identity.checkPermission(new AuthPermission("Permission Resource")).onItem() .apply(new Function<Boolean, List<Permission>>() { @Override public List<Permission> apply(Boolean granted) { if (granted) { return identity.getAttribute("permissions"); } throw new ForbiddenException(); } }); }
Example #12
Source File: JavaxTypesTest.java From jackson-modules-base with Apache License 2.0 | 5 votes |
public void testAuthPermission() throws Exception { AuthPermission in = new AuthPermission("foo"); String json = MAPPER.writeValueAsString(in); assertNotNull(json); // actually, deserialization won't work by default. So let's just check // some lexical aspects if (!json.contains("\"name\":")) { fail("Unexpected JSON, missing 'name' property: "+json); } }
Example #13
Source File: Configuration.java From JDKSourceCode1.8 with MIT License | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #14
Source File: Configuration.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #15
Source File: Configuration.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #16
Source File: Configuration.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #17
Source File: Configuration.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #18
Source File: Configuration.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #19
Source File: Configuration.java From Bytecoder with Apache License 2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #20
Source File: Configuration.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #21
Source File: Configuration.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #22
Source File: Configuration.java From Java8CN with Apache License 2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #23
Source File: Configuration.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #24
Source File: Configuration.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #25
Source File: Configuration.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #26
Source File: Configuration.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(String type) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new AuthPermission ("createLoginConfiguration." + type)); } }
Example #27
Source File: JMXPluggableAuthenticator.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Creates an instance of <code>JMXPluggableAuthenticator</code> * and initializes it with a {@link LoginContext}. * * @param env the environment containing configuration properties for the * authenticator. Can be null, which is equivalent to an empty * Map. * @exception SecurityException if the authentication mechanism cannot be * initialized. */ public JMXPluggableAuthenticator(Map<?, ?> env) { String loginConfigName = null; String passwordFile = null; if (env != null) { loginConfigName = (String) env.get(LOGIN_CONFIG_PROP); passwordFile = (String) env.get(PASSWORD_FILE_PROP); } try { if (loginConfigName != null) { // use the supplied JAAS login configuration loginContext = new LoginContext(loginConfigName, new JMXCallbackHandler()); } else { // use the default JAAS login configuration (file-based) SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( new AuthPermission("createLoginContext." + LOGIN_CONFIG_NAME)); } final String pf = passwordFile; try { loginContext = AccessController.doPrivileged( new PrivilegedExceptionAction<LoginContext>() { public LoginContext run() throws LoginException { return new LoginContext( LOGIN_CONFIG_NAME, null, new JMXCallbackHandler(), new FileLoginConfig(pf)); } }); } catch (PrivilegedActionException pae) { throw (LoginException) pae.getException(); } } } catch (LoginException le) { authenticationFailure("authenticate", le); } catch (SecurityException se) { authenticationFailure("authenticate", se); } }
Example #28
Source File: Configuration.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Get the installed login Configuration. * * <p> * * @return the login Configuration. If a Configuration object was set * via the {@code Configuration.setConfiguration} method, * then that object is returned. Otherwise, a default * Configuration object is returned. * * @exception SecurityException if the caller does not have permission * to retrieve the Configuration. * * @see #setConfiguration */ public static Configuration getConfiguration() { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new AuthPermission("getLoginConfiguration")); synchronized (Configuration.class) { if (configuration == null) { String config_class = null; config_class = AccessController.doPrivileged (new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty ("login.configuration.provider"); } }); if (config_class == null) { config_class = "sun.security.provider.ConfigFile"; } try { final String finalClass = config_class; Configuration untrustedImpl = AccessController.doPrivileged( new PrivilegedExceptionAction<Configuration>() { public Configuration run() throws ClassNotFoundException, InstantiationException, IllegalAccessException { Class<? extends Configuration> implClass = Class.forName( finalClass, false, Thread.currentThread().getContextClassLoader() ).asSubclass(Configuration.class); return implClass.newInstance(); } }); AccessController.doPrivileged( new PrivilegedExceptionAction<Void>() { public Void run() { setConfiguration(untrustedImpl); return null; } }, Objects.requireNonNull(untrustedImpl.acc) ); } catch (PrivilegedActionException e) { Exception ee = e.getException(); if (ee instanceof InstantiationException) { throw (SecurityException) new SecurityException ("Configuration error:" + ee.getCause().getMessage() + "\n").initCause(ee.getCause()); } else { throw (SecurityException) new SecurityException ("Configuration error: " + ee.toString() + "\n").initCause(ee); } } } return configuration; } }
Example #29
Source File: Configuration.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Get the installed login Configuration. * * <p> * * @return the login Configuration. If a Configuration object was set * via the {@code Configuration.setConfiguration} method, * then that object is returned. Otherwise, a default * Configuration object is returned. * * @exception SecurityException if the caller does not have permission * to retrieve the Configuration. * * @see #setConfiguration */ public static Configuration getConfiguration() { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new AuthPermission("getLoginConfiguration")); synchronized (Configuration.class) { if (configuration == null) { String config_class = null; config_class = AccessController.doPrivileged (new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty ("login.configuration.provider"); } }); if (config_class == null) { config_class = "sun.security.provider.ConfigFile"; } try { final String finalClass = config_class; Configuration untrustedImpl = AccessController.doPrivileged( new PrivilegedExceptionAction<Configuration>() { public Configuration run() throws ClassNotFoundException, InstantiationException, IllegalAccessException { Class<? extends Configuration> implClass = Class.forName( finalClass, false, Thread.currentThread().getContextClassLoader() ).asSubclass(Configuration.class); return implClass.newInstance(); } }); AccessController.doPrivileged( new PrivilegedExceptionAction<Void>() { public Void run() { setConfiguration(untrustedImpl); return null; } }, Objects.requireNonNull(untrustedImpl.acc) ); } catch (PrivilegedActionException e) { Exception ee = e.getException(); if (ee instanceof InstantiationException) { throw (SecurityException) new SecurityException ("Configuration error:" + ee.getCause().getMessage() + "\n").initCause(ee.getCause()); } else { throw (SecurityException) new SecurityException ("Configuration error: " + ee.toString() + "\n").initCause(ee); } } } return configuration; } }
Example #30
Source File: LoginContext.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void init(String name) throws LoginException { SecurityManager sm = System.getSecurityManager(); if (sm != null && creatorAcc == null) { sm.checkPermission(new AuthPermission ("createLoginContext." + name)); } if (name == null) throw new LoginException (ResourcesMgr.getString("Invalid.null.input.name")); // get the Configuration if (config == null) { config = java.security.AccessController.doPrivileged (new java.security.PrivilegedAction<Configuration>() { public Configuration run() { return Configuration.getConfiguration(); } }); } // get the LoginModules configured for this application AppConfigurationEntry[] entries = config.getAppConfigurationEntry(name); if (entries == null) { if (sm != null && creatorAcc == null) { sm.checkPermission(new AuthPermission ("createLoginContext." + OTHER)); } entries = config.getAppConfigurationEntry(OTHER); if (entries == null) { MessageFormat form = new MessageFormat(ResourcesMgr.getString ("No.LoginModules.configured.for.name")); Object[] source = {name}; throw new LoginException(form.format(source)); } } moduleStack = new ModuleInfo[entries.length]; for (int i = 0; i < entries.length; i++) { // clone returned array moduleStack[i] = new ModuleInfo (new AppConfigurationEntry (entries[i].getLoginModuleName(), entries[i].getControlFlag(), entries[i].getOptions()), null); } contextClassLoader = java.security.AccessController.doPrivileged (new java.security.PrivilegedAction<ClassLoader>() { public ClassLoader run() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { // Don't use bootstrap class loader directly to ensure // proper package access control! loader = ClassLoader.getSystemClassLoader(); } return loader; } }); }