本文整理汇总了Java中sun.security.util.SecurityConstants.ALL_PERMISSION属性的典型用法代码示例。如果您正苦于以下问题:Java SecurityConstants.ALL_PERMISSION属性的具体用法?Java SecurityConstants.ALL_PERMISSION怎么用?Java SecurityConstants.ALL_PERMISSION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sun.security.util.SecurityConstants
的用法示例。
在下文中一共展示了SecurityConstants.ALL_PERMISSION属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKnownInstance
/**
* Creates one of the well-known permissions directly instead of
* via reflection. Keep list short to not penalize non-JDK-defined
* permissions.
*/
private static final Permission getKnownInstance(Class<?> claz,
String name, String actions) {
if (claz.equals(FilePermission.class)) {
return new FilePermission(name, actions);
} else if (claz.equals(SocketPermission.class)) {
return new SocketPermission(name, actions);
} else if (claz.equals(RuntimePermission.class)) {
return new RuntimePermission(name, actions);
} else if (claz.equals(PropertyPermission.class)) {
return new PropertyPermission(name, actions);
} else if (claz.equals(NetPermission.class)) {
return new NetPermission(name, actions);
} else if (claz.equals(AllPermission.class)) {
return SecurityConstants.ALL_PERMISSION;
} else {
return null;
}
}
示例2: elements
/**
* Returns an enumeration of all the AllPermission objects in the
* container.
*
* @return an enumeration of all the AllPermission objects.
*/
public Enumeration<Permission> elements() {
return new Enumeration<Permission>() {
private boolean hasMore = all_allowed;
public boolean hasMoreElements() {
return hasMore;
}
public Permission nextElement() {
hasMore = false;
return SecurityConstants.ALL_PERMISSION;
}
};
}
示例3: elements
/**
* Returns an enumeration of all the AllPermission objects in the
* container.
*
* @return an enumeration of all the AllPermission objects.
*/
public Enumeration<Permission> elements() {
return new Enumeration<>() {
private boolean hasMore = all_allowed;
public boolean hasMoreElements() {
return hasMore;
}
public Permission nextElement() {
hasMore = false;
return SecurityConstants.ALL_PERMISSION;
}
};
}
示例4: checkTopLevelWindow
/**
* Returns <code>false</code> if the calling
* thread is not trusted to bring up the top-level window indicated
* by the <code>window</code> argument. In this case, the caller can
* still decide to show the window, but the window should include
* some sort of visual warning. If the method returns
* <code>true</code>, then the window can be shown without any
* special restrictions.
* <p>
* See class <code>Window</code> for more information on trusted and
* untrusted windows.
* <p>
* This method calls
* <code>checkPermission</code> with the
* <code>AWTPermission("showWindowWithoutWarningBanner")</code> permission,
* and returns <code>true</code> if a SecurityException is not thrown,
* otherwise it returns <code>false</code>.
* In the case of subset Profiles of Java SE that do not include the
* {@code java.awt} package, {@code checkPermission} is instead called
* to check the permission {@code java.security.AllPermission}.
* <p>
* If you override this method, then you should make a call to
* <code>super.checkTopLevelWindow</code>
* at the point the overridden method would normally return
* <code>false</code>, and the value of
* <code>super.checkTopLevelWindow</code> should
* be returned.
*
* @param window the new window that is being created.
* @return <code>true</code> if the calling thread is trusted to put up
* top-level windows; <code>false</code> otherwise.
* @exception NullPointerException if the <code>window</code> argument is
* <code>null</code>.
* @deprecated The dependency on {@code AWTPermission} creates an
* impediment to future modularization of the Java platform.
* Users of this method should instead invoke
* {@link #checkPermission} directly.
* This method will be changed in a future release to check
* the permission {@code java.security.AllPermission}.
* @see java.awt.Window
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
public boolean checkTopLevelWindow(Object window) {
if (window == null) {
throw new NullPointerException("window can't be null");
}
Permission perm = SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION;
if (perm == null) {
perm = SecurityConstants.ALL_PERMISSION;
}
try {
checkPermission(perm);
return true;
} catch (SecurityException se) {
// just return false
}
return false;
}
示例5: checkSystemClipboardAccess
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to access the system clipboard.
* <p>
* This method calls <code>checkPermission</code> with the
* <code>AWTPermission("accessClipboard")</code>
* permission.
* In the case of subset Profiles of Java SE that do not include the
* {@code java.awt} package, {@code checkPermission} is instead called
* to check the permission {@code java.security.AllPermission}.
* <p>
* If you override this method, then you should make a call to
* <code>super.checkSystemClipboardAccess</code>
* at the point the overridden method would normally throw an
* exception.
*
* @since JDK1.1
* @exception SecurityException if the calling thread does not have
* permission to access the system clipboard.
* @deprecated The dependency on {@code AWTPermission} creates an
* impediment to future modularization of the Java platform.
* Users of this method should instead invoke
* {@link #checkPermission} directly.
* This method will be changed in a future release to check
* the permission {@code java.security.AllPermission}.
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
public void checkSystemClipboardAccess() {
Permission perm = SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION;
if (perm == null) {
perm = SecurityConstants.ALL_PERMISSION;
}
checkPermission(perm);
}
示例6: checkAwtEventQueueAccess
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to access the AWT event queue.
* <p>
* This method calls <code>checkPermission</code> with the
* <code>AWTPermission("accessEventQueue")</code> permission.
* In the case of subset Profiles of Java SE that do not include the
* {@code java.awt} package, {@code checkPermission} is instead called
* to check the permission {@code java.security.AllPermission}.
*
* <p>
* If you override this method, then you should make a call to
* <code>super.checkAwtEventQueueAccess</code>
* at the point the overridden method would normally throw an
* exception.
*
* @since JDK1.1
* @exception SecurityException if the calling thread does not have
* permission to access the AWT event queue.
* @deprecated The dependency on {@code AWTPermission} creates an
* impediment to future modularization of the Java platform.
* Users of this method should instead invoke
* {@link #checkPermission} directly.
* This method will be changed in a future release to check
* the permission {@code java.security.AllPermission}.
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
public void checkAwtEventQueueAccess() {
Permission perm = SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION;
if (perm == null) {
perm = SecurityConstants.ALL_PERMISSION;
}
checkPermission(perm);
}
示例7: getPermission
/**
* Returns a permission object representing the permission
* necessary to make the connection represented by this
* object. This method returns null if no permission is
* required to make the connection. By default, this method
* returns {@code java.security.AllPermission}. Subclasses
* should override this method and return the permission
* that best represents the permission required to make a
* a connection to the URL. For example, a {@code URLConnection}
* representing a {@code file:} URL would return a
* {@code java.io.FilePermission} object.
*
* <p>The permission returned may dependent upon the state of the
* connection. For example, the permission before connecting may be
* different from that after connecting. For example, an HTTP
* sever, say foo.com, may redirect the connection to a different
* host, say bar.com. Before connecting the permission returned by
* the connection will represent the permission needed to connect
* to foo.com, while the permission returned after connecting will
* be to bar.com.
*
* <p>Permissions are generally used for two purposes: to protect
* caches of objects obtained through URLConnections, and to check
* the right of a recipient to learn about a particular URL. In
* the first case, the permission should be obtained
* <em>after</em> the object has been obtained. For example, in an
* HTTP connection, this will represent the permission to connect
* to the host from which the data was ultimately fetched. In the
* second case, the permission should be obtained and tested
* <em>before</em> connecting.
*
* @return the permission object representing the permission
* necessary to make the connection represented by this
* URLConnection.
*
* @exception IOException if the computation of the permission
* requires network or file I/O and an exception occurs while
* computing it.
*/
public Permission getPermission() throws IOException {
return SecurityConstants.ALL_PERMISSION;
}