List of usage examples for java.util Collection containsAll
boolean containsAll(Collection<?> c);
From source file:org.simbasecurity.core.domain.repository.RuleDatabaseRepositoryTest.java
@Test public void canFindAllURLRulesForAUser() { Collection<URLRule> rules = ruleDatabaseRepository.findURLRules(USER_NAME); assertTrue(rules.containsAll(Arrays.asList(urlRuleEntity))); assertEquals(1, rules.size());// w w w . j a v a 2s .c o m }
From source file:org.simbasecurity.core.domain.repository.RuleDatabaseRepositoryTest.java
@Test public void canFindAllRulesNotLinkedToAPolicy() throws Exception { ResourceRuleEntity notLinkedRule = new ResourceRuleEntity("hipiejipie"); notLinkedRule.setResourceName("hipiejipie"); persistAndRefresh(notLinkedRule);//from ww w . j a va 2s . co m Policy anotherPolicy = new PolicyEntity("hipiepolicy"); anotherPolicy.addRule(notLinkedRule); persistAndRefresh(anotherPolicy); Collection<Rule> rules = ruleDatabaseRepository.findNotLinked(policy); assertTrue(rules.containsAll(Arrays.asList(notLinkedRule))); }
From source file:edu.uci.ics.jung.algorithms.filters.VertexPredicateFilter.java
@SuppressWarnings("unchecked") public Graph<V, E> transform(Graph<V, E> g) { Graph<V, E> filtered;/*ww w. j ava 2 s .c om*/ try { filtered = g.getClass().newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Unable to create copy of existing graph: ", e); } catch (IllegalAccessException e) { throw new RuntimeException("Unable to create copy of existing graph: ", e); } for (V v : g.getVertices()) if (vertex_pred.evaluate(v)) filtered.addVertex(v); Collection<V> filtered_vertices = filtered.getVertices(); for (E e : g.getEdges()) { Collection<V> incident = g.getIncidentVertices(e); if (filtered_vertices.containsAll(incident)) filtered.addEdge(e, incident); } return filtered; }
From source file:org.simbasecurity.core.domain.repository.RuleDatabaseRepositoryTest.java
@Test public void canFindAllURLRulesForAUserViaGroup() { setupWithGroups();/*from ww w.j ava2 s .c o m*/ Collection<URLRule> rules = ruleDatabaseRepository.findURLRules(USER_VIA_GROUP); assertTrue(rules.containsAll(Arrays.asList(urlRuleEntityViaGroup))); assertEquals(1, rules.size()); }
From source file:com.oltpbenchmark.util.TestCollectionUtil.java
/** * testAddAll//from w w w.j a v a 2s . c om */ public void testAddAll() { int cnt = rand.nextInt(50) + 1; List<Integer> l = new ArrayList<Integer>(); Integer a[] = new Integer[cnt]; for (int i = 0; i < cnt; i++) { int next = rand.nextInt(); l.add(next); a[i] = next; } // FOR Collection<Integer> c = CollectionUtil.addAll(new HashSet<Integer>(), l); assertEquals(l.size(), c.size()); assert (c.containsAll(l)); c = CollectionUtil.addAll(new HashSet<Integer>(), a); assertEquals(l.size(), c.size()); assert (c.containsAll(l)); }
From source file:org.keycloak.adapters.springsecurity.support.KeycloakSpringAdapterUtilsTest.java
@Test public void testCreateGrantedAuthorities() throws Exception { Collection<? extends GrantedAuthority> authorities = KeycloakSpringAdapterUtils .createGrantedAuthorities(context); assertNotNull(authorities);/*from w ww.ja v a 2 s. c o m*/ assertTrue(authorities.containsAll(KEYCLOAK_ROLES)); }
From source file:org.kuali.rice.devtools.jpa.eclipselink.conv.parser.helper.resolver.AbstractPrimaryKeyJoinColumnResolver.java
protected final List<Expression> getJoinColumns(String enclosingClass, String fieldName, String mappedClass) { final ObjectReferenceDescriptor ord = OjbUtil.findObjectReferenceDescriptor(mappedClass, fieldName, descriptorRepositories);/*from ww w . j ava 2 s .c o m*/ final List<Expression> joinColumns = new ArrayList<Expression>(); if (foundDescriptor(ord)) { final Collection<String> fks = getForeignKeys(ord); if (fks == null || fks.isEmpty()) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName + " but does not have any foreign keys configured"); return null; } final Collection<String> pks = OjbUtil.getPrimaryKeyNames(mappedClass, descriptorRepositories); if (pks.size() == fks.size() && pks.containsAll(fks) && !pks.isEmpty()) { final ClassDescriptor cd = OjbUtil.findClassDescriptor(mappedClass, descriptorRepositories); final ClassDescriptor icd; final String itemClassName = getItemClass(ord); if (StringUtils.isBlank(itemClassName)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName + " but does not class name attribute"); return null; } else { icd = OjbUtil.findClassDescriptor(itemClassName, descriptorRepositories); } final FieldDescriptor[] pfds = cd.getPkFields(); final FieldDescriptor[] ipfds = icd.getPkFields(); for (int i = 0; i < pfds.length; i++) { final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>(); pairs.add(new MemberValuePair("name", new StringLiteralExpr(pfds[i].getColumnName()))); pairs.add(new MemberValuePair("referencedColumnName", new StringLiteralExpr(ipfds[i].getColumnName()))); joinColumns.add(new NormalAnnotationExpr(new NameExpr("PrimaryKeyJoinColumn"), pairs)); } if (isCascadeDelete(ord)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor set to cascade delete but JPA does not support that configuration with primary key join columns."); } if (isCascadePersist(ord)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor set to cascade persist but JPA does not support that configuration with primary key join columns."); } } } return joinColumns; }
From source file:eu.trentorise.smartcampus.permissionprovider.controller.ResourceAccessController.java
/** * Check the access to the specified resource using the client app token header * @param token/*from w w w . j av a 2 s .c om*/ * @param resourceUri * @param request * @return */ @RequestMapping("/resources/access") public @ResponseBody Boolean canAccessResource(@RequestHeader("Authorization") String token, @RequestParam String scope, HttpServletRequest request) { try { String parsedToken = resourceFilterHelper.parseTokenFromRequest(request); OAuth2Authentication auth = resourceServerTokenServices.loadAuthentication(parsedToken); Collection<String> actualScope = auth.getAuthorizationRequest().getScope(); Collection<String> scopeSet = StringUtils.commaDelimitedListToSet(scope); if (actualScope != null && !actualScope.isEmpty() && actualScope.containsAll(scopeSet)) { return true; } } catch (AuthenticationException e) { logger.error("Error validating token: " + e.getMessage()); } return false; }
From source file:com.cognifide.cq.cqsm.foundation.actions.check.permissions.CheckPermissions.java
private boolean checkPermissionsForPath(final Set<Principal> authorizablesToCheck, final CqActions actions, final List<String> privilegesToCheck, String subpath) throws RepositoryException { Collection<String> allowedActions = actions.getAllowedActions(subpath, authorizablesToCheck); final boolean containsAll = allowedActions.containsAll(privilegesToCheck); return (!containsAll && isAllow) || (containsAll && !isAllow); }
From source file:org.cloudfoundry.identity.uaa.oauth.UaaUserApprovalHandler.java
private boolean isAutoApprove(ClientDetails client, Collection<String> scopes) { Map<String, Object> info = client.getAdditionalInformation(); if (info.containsKey("autoapprove")) { Object object = info.get("autoapprove"); if (object instanceof Boolean && (Boolean) object || "true".equals(object)) { return true; }/*from www . j a va 2 s . co m*/ if (object instanceof Collection) { @SuppressWarnings("unchecked") Collection<String> autoScopes = (Collection<String>) object; if (autoScopes.containsAll(scopes)) { return true; } } } return false; }