List of usage examples for java.security Permission getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.jboss.dashboard.security.PermissionManager.java
/** * Find the permission descriptor for given principal and permission *//*from w w w . j a v a 2 s . com*/ public PermissionDescriptor find(final Principal prpal, final Permission perm) { final List<PermissionDescriptor> results = new ArrayList<PermissionDescriptor>(1); HibernateTxFragment txFragment = new HibernateTxFragment() { protected void txFragment(Session session) throws Exception { StringBuffer buf = new StringBuffer(); buf.append( " from " + PermissionDescriptor.class.getName() + " as item where item.dbid is not null "); if (prpal != null) { buf.append(" and item.principalClass = :principalClass "); buf.append(" and item.principalName = :principalName "); } buf.append( "and item.permissionClass = :permissionClass and item.permissionResource = :permissionResource"); Query query = session.createQuery(buf.toString()); if (prpal != null) { query.setString("principalClass", prpal.getClass().getName()); query.setString("principalName", prpal.getName()); } query.setString("permissionClass", perm.getClass().getName()); query.setString("permissionResource", perm.getName()); query.setCacheable(true); FlushMode oldFlushMode = session.getFlushMode(); session.setFlushMode(FlushMode.NEVER); results.addAll(query.list()); session.setFlushMode(oldFlushMode); } }; try { txFragment.execute(); if (!results.isEmpty()) return results.get(0); else return null; } catch (Exception e) { log.error("Error retrieving PermissionDescriptor", e); return null; } }
From source file:org.jboss.dashboard.security.UIPolicy.java
public Permission getPermission(Principal prpal, Class permClass, String permName) { PermissionCollection permCollection = getPermissions(prpal); if (permCollection != null) { Enumeration en = permCollection.elements(); while (en.hasMoreElements()) { Permission perm = (Permission) en.nextElement(); if (perm.getName().equals(permName) && perm.getClass().getName().equals(permClass.getName())) { return perm; }/* w w w.j av a 2s . c o m*/ } } return null; }
From source file:org.jboss.dashboard.security.UIPolicy.java
public Map getPermissions(Object resource, Class permClass) throws Exception { final Map results = new HashMap(); Method getResName = permClass.getMethod("getResourceName", new Class[] { Object.class }); String resourceName = (String) getResName.invoke(permClass, new Object[] { resource }); for (Iterator it = permissionMap.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Permissions perms = (Permissions) entry.getValue(); for (Enumeration en = perms.elements(); en.hasMoreElements();) { Permission perm = (Permission) en.nextElement(); if (perm.getName().equals(resourceName) && permClass.equals(perm.getClass())) { results.put(entry.getKey(), perm); }/*from www . j av a2 s . co m*/ } } return results; }
From source file:org.wildfly.test.security.common.elytron.PermissionRef.java
public static PermissionRef fromPermission(Permission perm, String module) { return builder().className(perm.getClass().getName()).action(perm.getActions()).targetName(perm.getName()) .module(module).build();/*from w w w.j a va 2 s . c o m*/ }