本文整理汇总了Java中org.apache.velocity.VelocityContext.get方法的典型用法代码示例。如果您正苦于以下问题:Java VelocityContext.get方法的具体用法?Java VelocityContext.get怎么用?Java VelocityContext.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.velocity.VelocityContext
的用法示例。
在下文中一共展示了VelocityContext.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFormDataToSign
import org.apache.velocity.VelocityContext; //导入方法依赖的package包/类
/**
* Build the form control data string over which the signature is computed.
*
* @param velocityContext the Velocity context which is already populated with the values for SAML message and relay
* state
* @param messageContext the SAML message context being processed
* @param sigAlgURI the signature algorithm URI
*
* @return the form control data string for signature computation
*/
protected String buildFormDataToSign(VelocityContext velocityContext, SAMLMessageContext messageContext, String sigAlgURI) {
StringBuilder builder = new StringBuilder();
boolean isRequest = false;
if (velocityContext.get("SAMLRequest") != null) {
isRequest = true;
}
String msgB64;
if (isRequest) {
msgB64 = (String) velocityContext.get("SAMLRequest");
} else {
msgB64 = (String) velocityContext.get("SAMLResponse");
}
String msg = null;
try {
msg = new String(Base64.decode(msgB64), "UTF-8");
} catch (UnsupportedEncodingException e) {
// All JVM's required to support UTF-8
}
if (isRequest) {
builder.append("SAMLRequest=" + msg);
} else {
builder.append("SAMLResponse=" + msg);
}
if (messageContext.getRelayState() != null) {
builder.append("&RelayState=" + messageContext.getRelayState());
}
builder.append("&SigAlg=" + sigAlgURI);
return builder.toString();
}
示例2: formatMailMessage
import org.apache.velocity.VelocityContext; //导入方法依赖的package包/类
public static MailMessage formatMailMessage(long userId, Event event, Position position) {
VelocityContext velocityContext = prepareContext(userId, event, position);
StringWriter writer = new StringWriter();
getTemplate(event, Context.getConfig().getString("mail.templatesPath", "mail") + "/")
.merge(velocityContext, writer);
return new MailMessage((String) velocityContext.get("subject"), writer.toString());
}