/** * @return a string describing all directives in this rule set, suitable as value for the * <code>"Content-Security-Policy"</code> HTTP header * @see <a href="https://www.w3.org/TR/CSP2/#policy_token">https://www.w3.org/TR/CSP2/#policy_token</a> */ public String toToken() { List<String> cspDirectives = new ArrayList<>(); for (Entry<String, String> entry : m_directives.entrySet()) { if (entry.getKey() != null && entry.getValue() != null) { cspDirectives.add(StringUtility.join(SOURCE_SEPARATOR, entry.getKey(), entry.getValue())); } } return StringUtility.join(DIRECTIVE_SEPARATOR, cspDirectives); }
/** * Adds {@code value} for {@code key} directive or appends {@code value} if directive with {@code key} already exists. */ protected ContentSecurityPolicy addOrAppend(String key, String value) { if (value == null) { return this; } if (m_directives.containsKey(key)) { String existingSource = m_directives.get(key); // Check for duplicates and do not add new value, if value already is part of the existing source if (!StringUtility.containsString(existingSource, value)) { m_directives.put(key, StringUtility.join(SOURCE_SEPARATOR, existingSource, value)); } } else { m_directives.put(key, value); } return this; }
protected void extractDestinationName(final URI uri) { String name; if (uri.isOpaque()) { // "scheme:scheme-specific-part" name = uri.getSchemeSpecificPart(); } else { // "scheme://host/path?parameters=map" name = StringUtility.join("", uri.getHost(), uri.getPath()); // If the host is empty, strip the path's leading slash. This is the case if three slashes are used after // the scheme. This format is recommended, because the host (unlike the path) may not contain special characters. if (StringUtility.startsWith(name, "/")) { name = name.substring(1); } } m_destinationName = Assertions.assertNotNullOrEmpty(name, "Missing destination name [{}]", m_rawValue); }
/** * Removes a class (all occurrences) from a given class string. */ public String removeCssClass(String cssClasses, String cssClass) { String[] classes = StringUtility.split(cssClasses, " "); for (int i = 0; i < classes.length; i++) { if (ObjectUtility.equals(classes[i], cssClass)) { classes[i] = null; } } return StringUtility.join(" ", classes); }
private static String getFormDisplayName(IForm f) { return StringUtility.join(" - ", ObjectUtility.nvl(f.getTitle(), f.getClass().getName()), f.getSubTitle()); }
/** * Rewrites the <code>pathInfo</code> part of the current request if the rewriteRule and rewriteReplacement is set on * the options object. This allows to redirect the request to a different URL than the URL that has been requested. */ protected String rewriteUrl(HttpServletRequest req, HttpProxyRequestOptions options) { String pathInfo = req.getPathInfo(); IRewriteRule rewriteRule = options.getRewriteRule(); if (rewriteRule != null) { pathInfo = rewriteRule.rewrite(pathInfo); } return StringUtility.join("", getRemoteBaseUrl(), pathInfo, StringUtility.box("?", req.getQueryString(), "")); }
protected void updateCopyPasteTextInternal() { if (m_copyPasteTextInternal == null) { m_copyPasteTextInternal = StringUtility.join("\n\n", m_header, m_body, m_html == null ? null : BEANS.get(HtmlHelper.class).toPlainText(m_html.toHtml()), m_hiddenText); } }
/** * @return the identifier to name the {@link Connection}. */ protected String computeClientId(final Map<Object, Object> properties) { final String clientId = ObjectUtility.toString(properties.get(JMS_CLIENT_ID)); if (clientId != null) { return clientId; } final String nodeId = BEANS.get(NodeIdentifier.class).get(); return StringUtility.join(" ", m_symbolicName, StringUtility.box("(", nodeId, ")")); }
protected IHtmlElement createTitleHtml() { String title = StringUtility.join(" ", getProductName(), getProductVersion()); if (StringUtility.hasText(title)) { // Set as form title instead of including in the info HTML setTitle(title); } return null; }
out.println("<h3>" + title + " " + version + "</h3>"); if (hasReadDiagnosticsServletPermission) { out.println("<form method='POST' action='" + StringUtility.join("?", req.getRequestURL().toString(), req.getQueryString()) + "'>"); out.print(diagnosticHTML); out.println("<p><input type='submit' value='submit'/></p>");
/** * Sets the member variables for all errors that were not handled by {@link #parseError(Throwable)}. By default, * produces a generic "some internal problem has happened" message, hiding the technical details. */ protected void parseUnexpectedProblem(Throwable error) { String errorCode = null; if (error != null) { extractStatus(error); if (m_status.getCode() > 0) { errorCode = String.valueOf(m_status.getCode()); } else { String s = error.getClass().getSimpleName(); errorCode = s.charAt(0) + "" + s.length(); } } // The application might be in an inconsistent state -> user should reload it. // The same message is shown if an exception occurs on the UI. m_header = TEXTS.get("UnexpectedProblem"); m_body = StringUtility.join("\n\n", TEXTS.get("InternalProcessingErrorMsg", (errorCode == null ? "" : " (" + TEXTS.get("ErrorCodeX", errorCode) + ")")), TEXTS.get("UiInconsistentMsg")); m_yesButtonText = TEXTS.get("Reload"); m_noButtonText = TEXTS.get("Ignore"); m_reloadOnYesClick = true; } }
protected void applyLookupResult(ITableRow tableRow, List<? extends ILookupRow<?>> result) { // disable row changed trigger on row try { tableRow.setRowChanging(true); // Cell cell = tableRow.getCellForUpdate(this); String separator = getResultRowSeparator(); List<String> texts = CollectionUtility.emptyArrayList(); List<String> tooltipTexts = CollectionUtility.emptyArrayList(); for (ILookupRow<?> row : result) { texts.add(row.getText()); tooltipTexts.add(row.getTooltipText()); } cell.setText(StringUtility.join(separator, texts)); cell.setTooltipText(StringUtility.join(separator, tooltipTexts)); } finally { tableRow.setRowPropertiesChanged(false); tableRow.setRowChanging(false); } }
@Override public void init(final Map<Object, Object> properties) throws Exception { m_symbolicName = Objects.toString(properties.get(SYMBOLIC_NAME), StringUtility.join(" ", CONFIG.getPropertyValue(ApplicationNameProperty.class), "MOM")); if (Platform.get().inDevelopmentMode()) { LOG.info("{} configuration: {}", m_symbolicName, properties); } try { m_contextEnvironment = createContextEnvironment(properties); m_connectionFactory = createConnectionFactory(properties); m_clientId = computeClientId(properties); m_connection = createConnection(); m_defaultMarshaller = createDefaultMarshaller(properties); initRequestReply(properties); LOG.info("{} initialized: {}", m_symbolicName, m_connection); } catch (Exception e) { try { destroy(); } catch (RuntimeException re) { e.addSuppressed(re); } throw e; } }
private boolean writeResource(final HttpServletRequest req, final HttpServletResponse resp, final String resourcePath) throws IOException { IRemoteFileService rfs = BEANS.get(getConfiguredRemoteFileServiceClass()); RemoteFile spec = new RemoteFile((resourcePath == null) ? null : StringUtility.join("", m_folder, resourcePath), -1); RemoteFile remoteFile = rfs.getRemoteFile(spec); if (!remoteFile.exists()) { return false; } HttpCacheObject obj = new HttpCacheObject(new HttpCacheKey(resourcePath), remoteFile.toBinaryResource()); if (BEANS.get(HttpCacheControl.class).checkAndSetCacheHeaders(req, resp, obj)) { return true; } rfs.streamRemoteFile(remoteFile, resp.getOutputStream()); return true; }
props.setProperty("mail.imap.ssl.protocols", StringUtility.join(" ", getSSLProtocols()));