List of usage examples for org.springframework.util StringUtils collectionToDelimitedString
public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim)
From source file:org.opentestsystem.shared.security.oauth.client.grant.samlbearer.SamlAssertionAccessTokenProvider.java
private MultiValueMap<String, String> getParametersForTokenRequest( final BaseOAuth2ProtectedResourceDetails resource, final String assertion) { final MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("grant_type", SAML2_BEARER_GRANT_TYPE); form.set("assertion", assertion); form.set("client_id", resource.getClientId()); LOGGER.info("YEAH... " + resource.getClientId()); if (resource.isScoped()) { final String scopeString = resource.getScope() != null ? StringUtils.collectionToDelimitedString(resource.getScope(), " ") : ""; form.set("scope", scopeString); LOGGER.info("YEAH... scope " + scopeString); }/*from www . j a v a 2 s .c o m*/ return form; }
From source file:org.springframework.beans.AbstractNestablePropertyAccessor.java
/** * Parse the given property name into the corresponding property name tokens. * @param propertyName the property name to parse * @return representation of the parsed property tokens *///from w w w. ja v a 2 s .c o m private PropertyTokenHolder getPropertyNameTokens(String propertyName) { String actualName = null; List<String> keys = new ArrayList<>(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); searchIndex = -1; if (keyStart != -1) { int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length()); if (keyEnd != -1) { if (actualName == null) { actualName = propertyName.substring(0, keyStart); } String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd); if (key.length() > 1 && (key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) { key = key.substring(1, key.length() - 1); } keys.add(key); searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length(); } } } PropertyTokenHolder tokens = new PropertyTokenHolder(actualName != null ? actualName : propertyName); if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys); } return tokens; }
From source file:org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityInterceptor.java
private void sendFailureResponse(HttpServletRequest request, HttpServletResponse response) throws Exception { if (request.getUserPrincipal() != null) { String roles = StringUtils.collectionToDelimitedString(this.roles, " "); response.sendError(HttpStatus.FORBIDDEN.value(), "Access is denied. User must have one of the these roles: " + roles); } else {/*from www . j a v a2s. co m*/ logUnauthorizedAttempt(); response.sendError(HttpStatus.UNAUTHORIZED.value(), "Full authentication is required to access this resource."); } }
From source file:org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.java
private String getProtocols(Connector connector) { try {/*from www. jav a 2 s . co m*/ List<String> protocols = connector.getProtocols(); return " (" + StringUtils.collectionToDelimitedString(protocols, ", ") + ")"; } catch (NoSuchMethodError ex) { // Not available with Jetty 8 return ""; } }
From source file:org.springframework.boot.context.embedded.jetty.JettyWebServer.java
private String getProtocols(Connector connector) { List<String> protocols = connector.getProtocols(); return " (" + StringUtils.collectionToDelimitedString(protocols, ", ") + ")"; }
From source file:org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainer.java
private String getPortsDescription() { List<Port> ports = getPorts(); if (!ports.isEmpty()) { return StringUtils.collectionToDelimitedString(ports, " "); }//from ww w.j ava 2 s . co m return "unknown"; }
From source file:org.springframework.boot.context.embedded.undertow.UndertowWebServer.java
private String getPortsDescription() { List<UndertowWebServer.Port> ports = getActualPorts(); if (!ports.isEmpty()) { return StringUtils.collectionToDelimitedString(ports, " "); }//w w w. j av a2 s . c o m return "unknown"; }
From source file:org.springframework.boot.web.embedded.undertow.UndertowServletWebServer.java
private String getPortsDescription() { List<Port> ports = getActualPorts(); if (!ports.isEmpty()) { return StringUtils.collectionToDelimitedString(ports, " "); }//from w w w. j ava 2s .c o m return "unknown"; }
From source file:org.springframework.cloud.dataflow.server.service.impl.AbstractStreamService.java
public StreamDefinition createStream(String streamName, String dsl, boolean deploy) { StreamDefinition streamDefinition = createStreamDefinition(streamName, dsl); List<String> errorMessages = new ArrayList<>(); for (StreamAppDefinition streamAppDefinition : streamDefinition.getAppDefinitions()) { final String appName = streamAppDefinition.getRegisteredAppName(); try {/*from w ww.ja v a 2s. co m*/ final ApplicationType appType = DataFlowServerUtil.determineApplicationType(streamAppDefinition); if (!appRegistry.appExist(appName, appType)) { errorMessages.add(String.format( "Application name '%s' with type '%s' does not exist in the app registry.", appName, appType)); } } catch (CannotDetermineApplicationTypeException e) { errorMessages.add(String.format("Cannot determine application type for application '%s': %s", appName, e.getMessage())); continue; } } if (!errorMessages.isEmpty()) { throw new InvalidStreamDefinitionException( StringUtils.collectionToDelimitedString(errorMessages, "\n")); } this.streamDefinitionRepository.save(streamDefinition); if (deploy) { this.deployStream(streamName, new HashMap<>()); } return streamDefinition; }
From source file:org.springframework.cloud.dataflow.server.service.impl.DefaultStreamService.java
/** * Create a new stream.// w w w. j a v a 2 s . com * * @param streamName stream name * @param dsl DSL definition for stream * @param deploy if {@code true}, the stream is deployed upon creation (default is * {@code false}) * @return the created stream definition already exists * @throws InvalidStreamDefinitionException if there are errors in parsing the stream DSL, * resolving the name, or type of applications in the stream */ public StreamDefinition createStream(String streamName, String dsl, boolean deploy) { StreamDefinition streamDefinition = createStreamDefinition(streamName, dsl); List<String> errorMessages = new ArrayList<>(); for (StreamAppDefinition streamAppDefinition : streamDefinition.getAppDefinitions()) { final String appName = streamAppDefinition.getRegisteredAppName(); ApplicationType applicationType = streamAppDefinition.getApplicationType(); if (!streamValidationService.isRegistered(appName, applicationType)) { errorMessages.add( String.format("Application name '%s' with type '%s' does not exist in the app registry.", appName, applicationType)); } } if (!errorMessages.isEmpty()) { throw new InvalidStreamDefinitionException( StringUtils.collectionToDelimitedString(errorMessages, "\n")); } if (this.streamDefinitionRepository.existsById(streamName)) { throw new DuplicateStreamDefinitionException(String.format( "Cannot create stream %s because another one has already " + "been created with the same name", streamName)); } final StreamDefinition savedStreamDefinition = this.streamDefinitionRepository.save(streamDefinition); if (deploy) { this.deployStream(streamName, new HashMap<>()); } auditRecordService.populateAndSaveAuditRecord(AuditOperationType.STREAM, AuditActionType.CREATE, streamDefinition.getName(), this.auditServiceUtils.convertStreamDefinitionToAuditData(savedStreamDefinition)); return streamDefinition; }