org.owasp.encoder.Encode.forHtmlAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(14.0k)|赞(0)|评价(0)|浏览(261)

本文整理了Java中org.owasp.encoder.Encode.forHtmlAttribute()方法的一些代码示例,展示了Encode.forHtmlAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Encode.forHtmlAttribute()方法的具体详情如下:
包路径:org.owasp.encoder.Encode
类名称:Encode
方法名:forHtmlAttribute

Encode.forHtmlAttribute介绍

[英]See #forHtmlAttribute(String) for description of encoding. This version writes directly to a Writer without an intervening string.
[中]有关编码的说明,请参见#forHtmlAttribute(字符串)。此版本直接写入写入程序,无需插入字符串。

代码示例

代码示例来源:origin: primefaces/primefaces

/**
 * @see Encode#forHtmlAttribute(String)
 */
public static String forHtmlAttribute(String input) {
  return Encode.forHtmlAttribute(input);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * Encodes for HTML text attributes.
 *
 * @param s
 * @return Encoded String
 */
public static String encodeForHtmlAttribute(String s) {
  return Encode.forHtmlAttribute(s);
}

代码示例来源:origin: OWASP/owasp-java-encoder

/** {@inheritDoc} */
public String encodeForHTMLAttribute(String s) {
  return Encode.forHtmlAttribute(s);
}

代码示例来源:origin: org.owasp.encoder/encoder-esapi

/** {@inheritDoc} */
public String encodeForHTMLAttribute(String s) {
  return Encode.forHtmlAttribute(s);
}

代码示例来源:origin: org.wso2.carbon.identity.authenticator.outbound.saml2sso/org.wso2.carbon.identity.authenticator.outbound.saml2sso

protected String buildPostPage(String saml2SSOUrl, String samlRequest, String relayState) {
  String postPage  = Config.getInstance().getAuthnRequestPage();
  postPage = postPage.replace("$url", Encode.forHtmlAttribute(saml2SSOUrl));
  StringBuilder hiddenInputBuilder = new StringBuilder("");
  hiddenInputBuilder.append("<input type='hidden' name='" + SAML2AuthConstants.SAML_REQUEST + "' value='")
      .append(samlRequest).append("'>");
  if (relayState != null) {
    hiddenInputBuilder.append("<input type='hidden' name='" + SAML2AuthConstants.RELAY_STATE + "' value='")
        .append(relayState).append("'>");
  }
  postPage = postPage.replace("<!--$params-->", hiddenInputBuilder.toString());
  if (logger.isDebugEnabled()) {
    logger.debug("SAML2 SSO Authenticator HTTP-POST page: " + postPage);
  }
  return postPage;
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml.cloud/org.wso2.carbon.identity.sso.saml.cloud

private String getRedirectHtml(String acUrl, String relayState, SAMLLogoutResponse logoutResponse) {
  String finalPage = null;
  String htmlPage = IdentitySAMLSSOServiceComponent.getSsoRedirectHtml();
  String pageWithAcs = htmlPage.replace("$acUrl", acUrl);
  String pageWithAcsResponse = pageWithAcs.replace("<!--$params-->", "<!--$params-->\n" + "<input " +
      "type='hidden' name='SAMLResponse' value='" + Encode.forHtmlAttribute(logoutResponse.getRespString
      ()) + "'>");
  String pageWithAcsResponseRelay = pageWithAcsResponse;
  if (relayState != null) {
    pageWithAcsResponseRelay = pageWithAcsResponse.replace("<!--$params-->", "<!--$params-->\n" + "<input" +
       " type='hidden' name='RelayState' value='" + Encode.forHtmlAttribute(relayState) + "'>");
  }
  finalPage = pageWithAcsResponseRelay;
  if (log.isDebugEnabled()) {
    log.debug("samlsso_response.html " + finalPage);
  }
  return finalPage;
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml.cloud/org.wso2.carbon.identity.sso.saml.cloud

private String getPostHtml(String acUrl, String relayState, SAMLLogoutResponse logoutResponse) {
  StringBuilder out = new StringBuilder();
  out.append("<html>");
  out.append("<body>");
  out.append("<p>You are now redirected back to " + Encode.forHtmlContent(acUrl));
  out.append(" If the redirection fails, please click the post button.</p>");
  out.append("<form method='post' action='" + Encode.forHtmlAttribute(acUrl) + "'>");
  out.append("<p>");
  out.append("<input type='hidden' name='SAMLResponse' value='" +
        Encode.forHtmlAttribute(logoutResponse.getRespString()) + "'>");
  if (relayState != null) {
    out.append("<input type='hidden' name='RelayState' value='" + Encode.forHtmlAttribute(relayState) +
          "'>");
  }
  out.append("<button type='submit'>POST</button>");
  out.append("</p>");
  out.append("</form>");
  out.append("<script type='text/javascript'>");
  out.append("document.forms[0].submit();");
  out.append("</script>");
  out.append("</body>");
  out.append("</html>");
  return out.toString();
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml.cloud/org.wso2.carbon.identity.sso.saml.cloud

private String getRedirectHtml(String acUrl, String relayState, String authenticatedIdPs, SAMLLoginResponse
    loginResponse) {
  String finalPage = null;
  String htmlPage = IdentitySAMLSSOServiceComponent.getSsoRedirectHtml();
  String pageWithAcs = htmlPage.replace("$acUrl", acUrl);
  String pageWithAcsResponse = pageWithAcs.replace("<!--$params-->", "<!--$params-->\n" + "<input " +
      "type='hidden' name='SAMLResponse' value='" + Encode.forHtmlAttribute(loginResponse.getRespString
      ()) + "'>");
  String pageWithAcsResponseRelay = pageWithAcsResponse;
  if (relayState != null) {
    pageWithAcsResponseRelay = pageWithAcsResponse.replace("<!--$params-->", "<!--$params-->\n" + "<input" +
        " type='hidden' name='RelayState' value='" + Encode.forHtmlAttribute(relayState) + "'>");
  }
  if (StringUtils.isBlank(authenticatedIdPs)) {
    finalPage = pageWithAcsResponseRelay;
  } else {
    finalPage = pageWithAcsResponseRelay.replace(
        "<!--$additionalParams-->",
        "<input type='hidden' name='AuthenticatedIdPs' value='"
            + Encode.forHtmlAttribute(authenticatedIdPs) + "'>");
  }
  if (log.isDebugEnabled()) {
    log.debug("samlsso_response.html " + finalPage);
  }
  return finalPage;
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml.cloud/org.wso2.carbon.identity.sso.saml.cloud

private String getPostHtml(String acUrl, String relayState, String authenticatedIdPs, SAMLLoginResponse
    loginResponse) {
  StringBuilder out = new StringBuilder();
  out.append("<html>");
  out.append("<body>");
  out.append("<p>You are now redirected back to " + Encode.forHtmlContent(acUrl));
  out.append(" If the redirection fails, please click the post button.</p>");
  out.append("<form method='post' action='" + Encode.forHtmlAttribute(acUrl) + "'>");
  out.append("<p>");
  out.append("<input type='hidden' name='SAMLResponse' value='" + Encode.forHtmlAttribute(loginResponse
      .getRespString()) + "'>");
  if (relayState != null) {
    out.append("<input type='hidden' name='RelayState' value='" + Encode.forHtmlAttribute(relayState) +
        "'>");
  }
  if (StringUtils.isBlank(authenticatedIdPs)) {
    out.append("<input type='hidden' name='AuthenticatedIdPs' value='" +
        Encode.forHtmlAttribute(authenticatedIdPs) + "'>");
  }
  out.append("<button type='submit'>POST</button>");
  out.append("</p>");
  out.append("</form>");
  out.append("<script type='text/javascript'>");
  out.append("document.forms[0].submit();");
  out.append("</script>");
  out.append("</body>");
  out.append("</html>");
  return out.toString();
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml2/org.wso2.carbon.identity.authenticator.inbound.saml2sso

private String getRedirectHtml(String acUrl, String relayState, SAML2SSOResponse saml2SSOResponse) {

    String htmlPage = Config.getInstance().getSsoResponseHtml();
    String pageWithAcs = htmlPage.replace("$acUrl", acUrl);
    String pageWithAcsResponse = pageWithAcs.replace("<!--$params-->", "<!--$params-->\n" + "<input " +
                                      "type='hidden' name='SAMLResponse' value='"
                                      + Encode.forHtmlAttribute(
        saml2SSOResponse.getRespString
            ()) + "'>");
    String pageWithAcsResponseRelay = pageWithAcsResponse;

    if (relayState != null) {
      pageWithAcsResponseRelay = pageWithAcsResponse.replace("<!--$params-->", "<!--$params-->\n" + "<input" +
                                           " type='hidden' "
                                           + "name='RelayState' value='"
                                           + Encode.forHtmlAttribute(
          relayState) + "'>");
    }

    if (logger.isDebugEnabled()) {
      logger.debug("samlsso_response.html " + pageWithAcsResponseRelay);
    }
    return pageWithAcsResponseRelay;
  }
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.sts/org.wso2.carbon.identity.sts.passive.ui

String pageWithReply = htmlPage.replace("$url", String.valueOf(respToken.getReplyTo()));
String pageWithReplyAction = pageWithReply.replace("$action", Encode.forHtmlAttribute(String.valueOf(action)));
String pageWithReplyActionResult = pageWithReplyAction.replace("$result",
    Encode.forHtmlAttribute(String.valueOf(respToken.getResults())));
String pageWithReplyActionResultContext;
if (respToken.getContext() != null) {
      PassiveRequestorConstants.PASSIVE_ADDITIONAL_PARAMETER,
      PassiveRequestorConstants.PASSIVE_ADDITIONAL_PARAMETER + "<input type='hidden' name='wctx' value='"
          + Encode.forHtmlAttribute(respToken.getContext()) + "'>");
} else {
  pageWithReplyActionResultContext = pageWithReplyActionResult;
  finalPage = pageWithReplyActionResultContext.replace(PassiveRequestorConstants.PASSIVE_ADDITIONAL_PARAMETER,
      "<input type='hidden' name='AuthenticatedIdPs' value='" +
          Encode.forHtmlAttribute(authenticatedIdPs) + "'>");

代码示例来源:origin: OWASP/owasp-java-encoder

@Override
  public void doTag() throws JspException, IOException {
    Encode.forHtmlAttribute(getJspContext().getOut(), _value);
  }
}

代码示例来源:origin: org.owasp.encoder/encoder-jsp

@Override
  public void doTag() throws JspException, IOException {
    Encode.forHtmlAttribute(getJspContext().getOut(), _value);
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sts.passive.ui

String pageWithReply = htmlPage.replace("$url", String.valueOf(respToken.getReplyTo()));
String pageWithReplyAction = pageWithReply.replace("$action", Encode.forHtmlAttribute(String.valueOf(action)));
String pageWithReplyActionResult = pageWithReplyAction.replace("$result",
    Encode.forHtmlAttribute(String.valueOf(respToken.getResults())));
String pageWithReplyActionResultContext;
if (respToken.getContext() != null) {
      PassiveRequestorConstants.PASSIVE_ADDITIONAL_PARAMETER,
      PassiveRequestorConstants.PASSIVE_ADDITIONAL_PARAMETER + "<input type='hidden' name='wctx' value='"
          + Encode.forHtmlAttribute(respToken.getContext()) + "'>");
} else {
  pageWithReplyActionResultContext = pageWithReplyActionResult;
  finalPage = pageWithReplyActionResultContext.replace(PassiveRequestorConstants.PASSIVE_ADDITIONAL_PARAMETER,
      "<input type='hidden' name='AuthenticatedIdPs' value='" +
          Encode.forHtmlAttribute(authenticatedIdPs) + "'>");

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider

Encode.forHtmlAttribute((String) session.getAttribute
        (OpenIDConstants.SessionAttribute.AUTHENTICATED_OPENID)) + "'>");
out.println("<input type='hidden' name='openid.return_to' value='" +
    Encode.forHtmlAttribute(((ParameterList) session.getAttribute(OpenId.PARAM_LIST)).
        getParameterValue(OpenId.ATTR_RETURN_TO)) + "'>");
    if (value != null) {
      out.println("<input type='hidden' name='claimTag' value='" +
          Encode.forHtmlAttribute(claimMapping.getLocalClaim().getClaimUri()) + "'>");
      out.println(
          "<input type='hidden' name='claimValue' value='" +
              Encode.forHtmlAttribute(userAttributes.get(claimMapping)) + "'>");

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider

Encode.forHtmlAttribute((String) session.getAttribute
        (OpenIDConstants.SessionAttribute.AUTHENTICATED_OPENID)) + "'>");
out.println("<input type='hidden' name='openid.return_to' value='" +
    Encode.forHtmlAttribute(((ParameterList) session.getAttribute(OpenId.PARAM_LIST)).
        getParameterValue(OpenId.ATTR_RETURN_TO)) + "'>");
    if (value != null) {
      out.println("<input type='hidden' name='claimTag' value='" +
          Encode.forHtmlAttribute(claimMapping.getLocalClaim().getClaimUri()) + "'>");
      out.println(
          "<input type='hidden' name='claimValue' value='" +
              Encode.forHtmlAttribute(userAttributes.get(claimMapping)) + "'>");

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sso.saml

String htmlPage = IdentitySAMLSSOServiceComponent.getSsoRedirectHtml();
String pageWithAcs = htmlPage.replace("$acUrl", acUrl);
String pageWithAcsResponse = pageWithAcs.replace("<!--$params-->", "<!--$params-->\n" + "<input type='hidden' name='SAMLResponse' value='" + Encode.forHtmlAttribute(response) + "'>");
String pageWithAcsResponseRelay = pageWithAcsResponse;
  pageWithAcsResponseRelay = pageWithAcsResponse.replace("<!--$params-->", "<!--$params-->\n" + "<input type='hidden' name='RelayState' value='" + Encode.forHtmlAttribute(relayState)+ "'>");
      "<!--$additionalParams-->",
      "<input type='hidden' name='AuthenticatedIdPs' value='"
          + Encode.forHtmlAttribute(authenticatedIdPs) + "'>");
out.println("<p>You are now redirected back to " + Encode.forHtmlContent(acUrl));
out.println(" If the redirection fails, please click the post button.</p>");
out.println("<form method='post' action='" + Encode.forHtmlAttribute(acUrl) + "'>");
out.println("<p>");
out.println("<input type='hidden' name='SAMLResponse' value='" + Encode.forHtmlAttribute(response) + "'>");
  out.println("<input type='hidden' name='RelayState' value='" + Encode.forHtmlAttribute(relayState) + "'>");
      Encode.forHtmlAttribute(authenticatedIdPs) + "'>");

代码示例来源:origin: org.wso2.carbon.identity.agent.sso.java/org.wso2.carbon.identity.sso.agent

for (String param : entry.getValue()) {
  htmlParams.append("<input type='hidden' name='").append(entry.getKey())
      .append("' value='").append(Encode.forHtmlAttribute(param)).append("'>\n");

相关文章