List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:de.thingweb.servient.impl.MultiBindingThingServer.java
private static String urlizeTokens(String url) { return Arrays.stream(url.split("/")).map(MultiBindingThingServer::urlize).collect(Collectors.joining("/")); }
From source file:org.shredzone.cilla.plugin.social.manager.SocialHandlerManager.java
/** * Sets up the manager. All beans are scanned for {@link SocialHandler} annotations. * If found, {@link SocialBookmark} annotations will further describe the social * bookmark service./* w w w . ja v a 2 s. com*/ */ @PostConstruct public void setup() { Set<String> blacklistSet = Arrays.stream(blacklist.split("[,;]+")).map(String::trim) .filter(it -> !it.isEmpty()).collect(Collectors.toSet()); Collection<Object> beans = applicationContext.getBeansWithAnnotation(SocialHandler.class).values(); for (Object bean : beans) { SocialHandler shAnno = bean.getClass().getAnnotation(SocialHandler.class); if (shAnno != null) { for (Method method : bean.getClass().getMethods()) { SocialBookmark bookmarkAnno = AnnotationUtils.findAnnotation(method, SocialBookmark.class); if (bookmarkAnno != null) { processBookmarkHandler(bean, method, bookmarkAnno, blacklistSet); } } } } }
From source file:io.gravitee.management.security.config.basic.filter.JWTAuthenticationFilter.java
@Override @SuppressWarnings(value = "unchecked") public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; final Optional<Cookie> optionalStringToken; if (req.getCookies() == null) { optionalStringToken = Optional.empty(); } else {/*from w ww . ja va 2 s. co m*/ optionalStringToken = Arrays.stream(req.getCookies()) .filter(cookie -> HttpHeaders.AUTHORIZATION.equals(cookie.getName())).findAny(); } if (optionalStringToken.isPresent()) { String stringToken = optionalStringToken.get().getValue(); final String authorizationSchema = "Bearer"; if (stringToken.contains(authorizationSchema)) { stringToken = stringToken.substring(authorizationSchema.length()).trim(); try { final Map<String, Object> verify = jwtVerifier.verify(stringToken); final List<SimpleGrantedAuthority> authorities = ((List<Map>) verify.get(JWTClaims.PERMISSIONS)) .stream().map(map -> new SimpleGrantedAuthority(map.get("authority").toString())) .collect(Collectors.toList()); final UserDetails userDetails = new UserDetails(getStringValue(verify.get(JWTClaims.SUBJECT)), "", authorities, getStringValue(verify.get(JWTClaims.EMAIL)), getStringValue(verify.get(JWTClaims.FIRSTNAME)), getStringValue(verify.get(JWTClaims.LASTNAME))); SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken( userDetails, null, userDetails.getAuthorities())); } catch (Exception e) { LOGGER.error("Invalid token", e); final Cookie bearerCookie = jwtCookieGenerator.generate(null); res.addCookie(bearerCookie); res.sendError(HttpStatusCode.UNAUTHORIZED_401); } } else { LOGGER.info("Authorization schema not found"); } } else { LOGGER.info("Authorization cookie not found"); } chain.doFilter(request, response); }
From source file:ddf.catalog.validation.impl.validator.RelationshipValidator.java
public RelationshipValidator(String sourceAttribute, String sourceValue, String relationship, String targetAttribute, String... targetValues) { relationships.put(MUST_HAVE, this::mustHave); relationships.put(CANNOT_HAVE, this::cannotHave); relationships.put(CAN_ONLY_HAVE, this::canOnlyHave); this.sourceAttribute = sourceAttribute; this.sourceValue = sourceValue; this.relationship = relationship; this.targetAttribute = targetAttribute; if (targetValues != null) { this.targetValues = Arrays.stream(targetValues).filter(Objects::nonNull).map(Objects::toString) .collect(Collectors.toList()); } else {/*from ww w. j a v a 2 s .co m*/ this.targetValues = Collections.emptyList(); } if (!relationships.keySet().contains(relationship)) { throw new IllegalArgumentException( "Unrecognized relationship " + relationship + " for validator " + this.toString()); } if (CAN_ONLY_HAVE.equals(relationship) && CollectionUtils.isEmpty(this.targetValues)) { throw new IllegalArgumentException( "Relationship " + CAN_ONLY_HAVE + " must specify one or more target values"); } }
From source file:uk.dsxt.voting.client.datamodel.VotingInfoWeb.java
public VotingInfoWeb(Voting voting, BigDecimal amount, long timer) { if (voting == null || voting.getQuestions().length <= 0) { questions = new QuestionWeb[0]; } else {// ww w . j a va 2 s .c o m questions = Arrays.stream(voting.getQuestions()).map(QuestionWeb::new).toArray(QuestionWeb[]::new); } this.amount = amount; this.timer = timer; this.messageId = null; this.status = null; this.timestamp = null; this.signature = null; }
From source file:org.shredzone.cilla.admin.ListBean.java
/** * Returns a list of available time precisions. */// www.j a v a2s . c om public List<SelectItem> createTimeDefinitionList() { ResourceBundle msg = getResourceBundle(); return Arrays.stream(TimeDefinition.values()).map(TimeDefinition::name).map(value -> { String label = msg.getString("select.timedefinition." + value.toLowerCase()); String description = msg.getString("select.timedefinition.tt." + value.toLowerCase()); return new SelectItem(value, label, description); }).collect(toList()); }
From source file:org.leandreck.endpoints.processor.model.TypeNodeFactory.java
private Map<TypeNodeKind, ConcreteTypeNodeFactory> initFactories() { final Map<TypeNodeKind, ConcreteTypeNodeFactory> tmpFactories = new EnumMap<>(TypeNodeKind.class); Arrays.stream(TypeNodeKind.values()).forEach(it -> { try {//from www . j a v a 2 s .co m tmpFactories.put(it, it.getTypeNodeFactory().newConfiguredInstance(this, this.configuration, this.typeUtils, this.elementUtils)); } catch (final Exception e) { throw new InitTypeNodeFactoriesException(e); } }); return tmpFactories; }
From source file:com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder.java
public boolean containsAllFilesToDepth(final String sourcePath, final int maxDepth, final String... filenamePatterns) { final File sourceDirectory = new File(sourcePath); if (StringUtils.isBlank(sourcePath) || !sourceDirectory.isDirectory()) { return false; }/*w w w .j av a 2 s . co m*/ return Arrays.stream(filenamePatterns).map(pattern -> findFilesToDepth(sourceDirectory, pattern, maxDepth)) .allMatch(foundFiles -> !foundFiles.isEmpty()); }
From source file:org.pdfsam.module.PreferencesUsageDataStore.java
public List<ModuleUsage> getUsages() { Preferences prefs = Preferences.userRoot().node(USAGE_PATH); List<ModuleUsage> retList = new ArrayList<>(); try {/*w w w . j a v a2 s .c om*/ List<String> jsons = Arrays.stream(prefs.childrenNames()).parallel().map(name -> prefs.node(name)) .map(node -> node.get(MODULE_USAGE_KEY, "")).filter(json -> isNotBlank(json)).collect(toList()); for (String json : jsons) { retList.add(JSON.std.beanFrom(ModuleUsage.class, json)); } } catch (BackingStoreException | IOException e) { LOG.error("Unable to get modules usage statistics", e); } return retList; }