本文整理汇总了Java中javax.xml.crypto.dsig.spec.ExcC14NParameterSpec类的典型用法代码示例。如果您正苦于以下问题:Java ExcC14NParameterSpec类的具体用法?Java ExcC14NParameterSpec怎么用?Java ExcC14NParameterSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExcC14NParameterSpec类属于javax.xml.crypto.dsig.spec包,在下文中一共展示了ExcC14NParameterSpec类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unmarshalParams
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
private void unmarshalParams(Element paramsElem) {
String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
this.inclusiveNamespaces = prefixListAttr;
int begin = 0;
int end = prefixListAttr.indexOf(' ');
List<String> prefixList = new ArrayList<String>();
while (end != -1) {
prefixList.add(prefixListAttr.substring(begin, end));
begin = end + 1;
end = prefixListAttr.indexOf(' ', begin);
}
if (begin <= prefixListAttr.length()) {
prefixList.add(prefixListAttr.substring(begin));
}
this.params = new ExcC14NParameterSpec(prefixList);
}
示例2: unmarshalParams
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
private void unmarshalParams(Element paramsElem) {
String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
this.inclusiveNamespaces = prefixListAttr;
int begin = 0;
int end = prefixListAttr.indexOf(' ');
List prefixList = new ArrayList();
while (end != -1) {
prefixList.add(prefixListAttr.substring(begin, end));
begin = end + 1;
end = prefixListAttr.indexOf(' ', begin);
}
if (begin <= prefixListAttr.length()) {
prefixList.add(prefixListAttr.substring(begin));
}
this.params = new ExcC14NParameterSpec(prefixList);
}
示例3: init
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException
{
if (params != null) {
if (!(params instanceof ExcC14NParameterSpec)) {
throw new InvalidAlgorithmParameterException
("params must be of type ExcC14NParameterSpec");
}
this.params = (C14NMethodParameterSpec)params;
}
}
示例4: marshalParams
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
super.marshalParams(parent, context);
AlgorithmParameterSpec spec = getParameterSpec();
if (spec == null) {
return;
}
String prefix = DOMUtils.getNSPrefix(context,
CanonicalizationMethod.EXCLUSIVE);
Element eElem = DOMUtils.createElement(ownerDoc,
"InclusiveNamespaces",
CanonicalizationMethod.EXCLUSIVE,
prefix);
if (prefix == null || prefix.length() == 0) {
eElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
CanonicalizationMethod.EXCLUSIVE);
} else {
eElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns:" + prefix,
CanonicalizationMethod.EXCLUSIVE);
}
ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec;
StringBuffer prefixListAttr = new StringBuffer("");
@SuppressWarnings("unchecked")
List<String> prefixList = params.getPrefixList();
for (int i = 0, size = prefixList.size(); i < size; i++) {
prefixListAttr.append(prefixList.get(i));
if (i < size - 1) {
prefixListAttr.append(" ");
}
}
DOMUtils.setAttribute(eElem, "PrefixList", prefixListAttr.toString());
this.inclusiveNamespaces = prefixListAttr.toString();
transformElem.appendChild(eElem);
}
示例5: marshalParams
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
super.marshalParams(parent, context);
AlgorithmParameterSpec spec = getParameterSpec();
if (spec == null) {
return;
}
String prefix = DOMUtils.getNSPrefix(context,
CanonicalizationMethod.EXCLUSIVE);
Element eElem = DOMUtils.createElement(ownerDoc,
"InclusiveNamespaces",
CanonicalizationMethod.EXCLUSIVE,
prefix);
if (prefix == null || prefix.length() == 0) {
eElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
CanonicalizationMethod.EXCLUSIVE);
} else {
eElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns:" + prefix,
CanonicalizationMethod.EXCLUSIVE);
}
ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec;
StringBuilder prefixListAttr = new StringBuilder("");
List<String> prefixList = params.getPrefixList();
for (int i = 0, size = prefixList.size(); i < size; i++) {
prefixListAttr.append(prefixList.get(i));
if (i < size - 1) {
prefixListAttr.append(" ");
}
}
DOMUtils.setAttribute(eElem, "PrefixList", prefixListAttr.toString());
this.inclusiveNamespaces = prefixListAttr.toString();
transformElem.appendChild(eElem);
}
示例6: init
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
@Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException
{
if (params != null) {
if (!(params instanceof ExcC14NParameterSpec)) {
throw new InvalidAlgorithmParameterException
("params must be of type ExcC14NParameterSpec");
}
this.params = (C14NMethodParameterSpec)params;
}
}
示例7: marshalParams
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
@Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
super.marshalParams(parent, context);
AlgorithmParameterSpec spec = getParameterSpec();
if (spec == null) {
return;
}
XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), transformElem);
String prefix =
DOMUtils.getNSPrefix(context, CanonicalizationMethod.EXCLUSIVE);
xwriter.writeStartElement(prefix, "InclusiveNamespaces", CanonicalizationMethod.EXCLUSIVE);
xwriter.writeNamespace(prefix, CanonicalizationMethod.EXCLUSIVE);
ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec;
StringBuilder prefixListAttr = new StringBuilder("");
List<String> prefixList = getParameterSpecPrefixList(params);
for (int i = 0, size = prefixList.size(); i < size; i++) {
prefixListAttr.append(prefixList.get(i));
if (i < size - 1) {
prefixListAttr.append(" ");
}
}
xwriter.writeAttribute("", "", "PrefixList", prefixListAttr.toString());
this.inclusiveNamespaces = prefixListAttr.toString();
xwriter.writeEndElement(); // "InclusiveNamespaces"
}
示例8: signSignature
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
private Element signSignature(String id, Element env, KeyInfoFactory keyInfoFactory, X509Credential credential) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, MarshalException, XMLSignatureException {
if (endorsingToken == null) return env;
NodeList nl = env.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
for (int i = 0; i < nl.getLength(); i++) {
Element e = (Element) nl.item(i);
if (e.hasAttributeNS(null, "Id")) {
e.setAttributeNS(WSSecurityConstants.WSU_NS, "Id", e.getAttribute("Id"));
e.setIdAttributeNS(WSSecurityConstants.WSU_NS, "Id", true);
}
}
env = SAMLUtil.loadElementFromString(XMLHelper.nodeToString(env));
DigestMethod digestMethod = xsf.newDigestMethod(DigestMethod.SHA1, null);
List<Transform> transforms = new ArrayList<Transform>(2);
transforms.add(xsf.newTransform("http://www.w3.org/2001/10/xml-exc-c14n#",new ExcC14NParameterSpec(Collections.singletonList("xsd"))));
List<Reference> refs = new ArrayList<Reference>();
Reference r = xsf.newReference("#"+id, digestMethod, transforms, null, null);
refs.add(r);
CanonicalizationMethod canonicalizationMethod = xsf.newCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE, (C14NMethodParameterSpec) null);
SignatureMethod signatureMethod = xsf.newSignatureMethod(SignatureMethod.RSA_SHA1, null);
SignedInfo signedInfo = xsf.newSignedInfo(canonicalizationMethod, signatureMethod, refs);
KeyInfo ki = generateKeyInfo(credential, keyInfoFactory, false);
XMLSignature signature = xsf.newXMLSignature(signedInfo, ki);
Node security = env.getElementsByTagNameNS(WSSecurityConstants.WSSE_NS, "Security").item(0);
DOMSignContext signContext = new DOMSignContext(credential.getPrivateKey(), security);
signContext.putNamespacePrefix(SAMLConstants.XMLSIG_NS, SAMLConstants.XMLSIG_PREFIX);
signContext.putNamespacePrefix(SAMLConstants.XMLENC_NS, SAMLConstants.XMLENC_PREFIX);
signature.sign(signContext);
return env;
}
示例9: init
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
if (!(params instanceof ExcC14NParameterSpec)) {
throw new InvalidAlgorithmParameterException
("params must be of type ExcC14NParameterSpec");
}
this.params = (C14NMethodParameterSpec) params;
}
}
示例10: marshalParams
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec; //导入依赖的package包/类
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException {
super.marshalParams(parent, context);
AlgorithmParameterSpec spec = getParameterSpec();
if (spec == null) {
return;
}
String prefix =
DOMUtils.getNSPrefix(context, CanonicalizationMethod.EXCLUSIVE);
Element excElem = DOMUtils.createElement
(ownerDoc, "InclusiveNamespaces",
CanonicalizationMethod.EXCLUSIVE, prefix);
if (prefix == null || prefix.length() == 0) {
excElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
CanonicalizationMethod.EXCLUSIVE);
} else {
excElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns:" + prefix, CanonicalizationMethod.EXCLUSIVE);
}
ExcC14NParameterSpec params = (ExcC14NParameterSpec) spec;
StringBuffer prefixListAttr = new StringBuffer("");
List prefixList = params.getPrefixList();
for (int i = 0, size = prefixList.size(); i < size; i++) {
prefixListAttr.append((String) prefixList.get(i));
if (i < size - 1) {
prefixListAttr.append(" ");
}
}
DOMUtils.setAttribute(excElem, "PrefixList", prefixListAttr.toString());
this.inclusiveNamespaces = prefixListAttr.toString();
transformElem.appendChild(excElem);
}