本文整理汇总了Java中javax.xml.crypto.AlgorithmMethod类的典型用法代码示例。如果您正苦于以下问题:Java AlgorithmMethod类的具体用法?Java AlgorithmMethod怎么用?Java AlgorithmMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlgorithmMethod类属于javax.xml.crypto包,在下文中一共展示了AlgorithmMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)
throws KeySelectorException {
for (Object o : keyInfo.getContent()) {
if (o instanceof X509Data) {
for (Object o2 : ((X509Data) o).getContent()) {
if (o2 instanceof X509Certificate) {
final X509Certificate cert = (X509Certificate) o2;
return new KeySelectorResult() {
public Key getKey() {
return cert.getPublicKey();
}
};
}
}
}
}
return null;
}
示例2: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select(final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context) throws KeySelectorException {
for (final Object object : keyInfo.getContent()) {
final XMLStructure info = (XMLStructure) object;
if (info instanceof X509Data) {
final X509Data x509Data = (X509Data) info;
for (final Object certificado : x509Data.getContent()) {
if (certificado instanceof X509Certificate) {
final X509Certificate x509Certificate = (X509Certificate) certificado;
if (this.algEquals(method.getAlgorithm(), x509Certificate.getPublicKey().getAlgorithm())) {
return new KeySelectorResult() {
@Override
public Key getKey() {
return x509Certificate.getPublicKey();
}
};
}
}
}
}
}
throw new KeySelectorException("N\u00e3o foi localizada a chave do certificado.");
}
示例3: getTransformsXsltXpath
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
private List<AlgorithmMethod> getTransformsXsltXpath() {
try {
AlgorithmMethod transformXslt = XmlSignatureHelper.getXslTransform("/org/apache/camel/component/xmlsecurity/xslt_test.xsl");
Map<String, String> namespaceMap = new HashMap<String, String>(1);
namespaceMap.put("n0", "https://org.apache/camel/xmlsecurity/test");
AlgorithmMethod transformXpath = XmlSignatureHelper.getXPathTransform("//n0:XMLSecurity/n0:Content", namespaceMap);
// I removed base 64 transform because the JDK implementation does
// not correctly support this transformation
// AlgorithmMethod transformBase64 = helper.getBase64Transform();
List<AlgorithmMethod> result = new ArrayList<AlgorithmMethod>(3);
result.add(XmlSignatureHelper.getCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE));
result.add(transformXslt);
result.add(transformXpath);
// result.add(transformBase64);
return result;
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例4: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select(final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context) throws KeySelectorException {
for (final Object object : keyInfo.getContent()) {
final XMLStructure info = (XMLStructure) object;
if (info instanceof X509Data) {
final X509Data x509Data = (X509Data) info;
for (final Object certificado : x509Data.getContent()) {
if (certificado instanceof X509Certificate) {
final X509Certificate x509Certificate = (X509Certificate) certificado;
if (this.algEquals(method.getAlgorithm(), x509Certificate.getPublicKey().getAlgorithm())) {
return new KeySelectorResult() {
@Override
public Key getKey() {
return x509Certificate.getPublicKey();
}
};
}
}
}
}
}
throw new KeySelectorException("Nao foi localizada a chave do certificado.");
}
示例5: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select ( final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context ) throws KeySelectorException
{
if ( keyInfo == null )
{
throw new KeySelectorException ( "Null KeyInfo object!" );
}
final SignatureMethod sm = (SignatureMethod)method;
final List<?> list = keyInfo.getContent ();
for ( int i = 0; i < list.size (); i++ )
{
final XMLStructure xmlStructure = (XMLStructure)list.get ( i );
if ( xmlStructure instanceof KeyValue )
{
try
{
final PublicKey pk = ( (KeyValue)xmlStructure ).getPublicKey ();
// make sure algorithm is compatible with method
if ( algEquals ( sm.getAlgorithm (), pk.getAlgorithm () ) )
{
return new SimpleKeySelectorResult ( pk );
}
}
catch ( final KeyException ke )
{
throw new KeySelectorException ( ke );
}
}
}
throw new KeySelectorException ( "No KeyValue element found!" );
}
示例6: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select ( final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context ) throws KeySelectorException
{
if ( keyInfo == null )
{
throw new KeySelectorException ( "Null KeyInfo object!" );
}
final SignatureMethod sm = (SignatureMethod)method;
final List<?> list = keyInfo.getContent ();
for ( final Object l : list )
{
final XMLStructure xmlStructure = (XMLStructure)l;
if ( xmlStructure instanceof X509Data )
{
for ( final Object o : ( (X509Data)xmlStructure ).getContent () )
{
KeySelectorResult result = null;
if ( o instanceof X509Certificate )
{
result = findPublicKey ( (X509Certificate)o, sm );
}
if ( result != null )
{
return result;
}
}
}
}
throw new KeySelectorException ( "No KeyValue element found!" );
}
示例7: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select(KeyInfo keyInfo,
KeySelector.Purpose purpose, AlgorithmMethod algorithmMethod,
XMLCryptoContext context) throws KeySelectorException {
if (keyInfo == null) {
throw new KeySelectorException("Null KeyInfo object!");
}
@SuppressWarnings("unchecked")
List<XMLStructure> list = keyInfo.getContent();
for (XMLStructure xmlStructure : list) {
if (xmlStructure instanceof X509Data) {
X509Data x509Data = (X509Data) xmlStructure;
@SuppressWarnings("rawtypes")
List content = x509Data.getContent();
for (int i = 0; i < content.size(); i++) {
Object x509Content = content.get(i);
if (x509Content instanceof X509Certificate) {
X509Certificate certificate = (X509Certificate) x509Content;
try {
return getPublicKeyFromKeystore(certificate,
(SignatureMethod) algorithmMethod);
} catch (KeyStoreException e) {
throw new KeySelectorException(e);
}
}
}
}
}
throw new KeySelectorException("No X509Data element found.");
}
示例8: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select(KeyInfo keyInfo,
KeySelector.Purpose purpose, AlgorithmMethod algorithmMethod,
XMLCryptoContext context) throws KeySelectorException {
if (keyInfo == null) {
throw new KeySelectorException("Null KeyInfo object!");
}
@SuppressWarnings("unchecked")
List<XMLStructure> list = keyInfo.getContent();
for (XMLStructure xmlStructure : list) {
if (xmlStructure instanceof KeyValue) {
PublicKey publicKey = null;
try {
publicKey = ((KeyValue) xmlStructure).getPublicKey();
} catch (KeyException ke) {
throw new KeySelectorException(ke);
}
if (algorithmCompatibleWithMethod(
algorithmMethod.getAlgorithm(),
publicKey.getAlgorithm())) {
return new SimpleKeySelectorResult(publicKey);
}
}
}
throw new KeySelectorException("No RSA/DSA KeyValue element found");
}
示例9: getXslTranform
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
/**
* Returns a configuration for an XSL transformation.
*
* @param is
* input stream of the XSL
* @return XSL transform
* @throws IllegalArgumentException
* if <tt>is</tt> is <code>null</code>
* @throws Exception
* if an error during the reading of the XSL file occurs
*/
public static AlgorithmMethod getXslTranform(InputStream is) throws SAXException, IOException, ParserConfigurationException {
if (is == null) {
throw new IllegalArgumentException("is must not be null");
}
Document doc = parseInput(is);
DOMStructure stylesheet = new DOMStructure(doc.getDocumentElement());
XSLTTransformParameterSpec spec = new XSLTTransformParameterSpec(stylesheet);
XmlSignatureTransform transformXslt = new XmlSignatureTransform();
transformXslt.setAlgorithm(Transform.XSLT);
transformXslt.setParameterSpec(spec);
return transformXslt;
}
示例10: setCanonicalizationMethod
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
/**
* Sets the reference name for a AlgorithmMethod that can be found in the registry.
*/
public void setCanonicalizationMethod(String canonicalizationMethodName) {
if (getCamelContext() != null && canonicalizationMethodName != null) {
AlgorithmMethod method = getCamelContext().getRegistry().lookupByNameAndType(canonicalizationMethodName, AlgorithmMethod.class);
if (method != null) {
setCanonicalizationMethod(method);
}
}
if (canonicalizationMethodName != null) {
this.canonicalizationMethodName = canonicalizationMethodName;
}
}
示例11: setTransformMethods
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
/**
* Sets the reference name for a List<AlgorithmMethod> that can be found in the registry.
*/
public void setTransformMethods(String transformMethodsName) {
if (getCamelContext() != null && transformMethodsName != null) {
@SuppressWarnings("unchecked")
List<AlgorithmMethod> list = getCamelContext().getRegistry().lookupByNameAndType(transformMethodsName, List.class);
if (list != null) {
setTransformMethods(list);
}
}
if (transformMethodsName != null) {
this.transformMethodsName = transformMethodsName;
}
}
示例12: containsEnvelopedTransform
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
private boolean containsEnvelopedTransform(List<AlgorithmMethod> configuredTrafos) {
for (AlgorithmMethod m : configuredTrafos) {
if (Transform.ENVELOPED.equals(m.getAlgorithm())) {
return true;
}
}
return false;
}
示例13: getTransformsXPath2
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
private List<AlgorithmMethod> getTransformsXPath2() {
List<XPathAndFilter> list = new ArrayList<XPathAndFilter>(3);
XPathAndFilter xpath1 = new XPathAndFilter("//n0:ToBeSigned", XPathType.Filter.INTERSECT.toString());
list.add(xpath1);
XPathAndFilter xpath2 = new XPathAndFilter("//n0:NotToBeSigned", XPathType.Filter.SUBTRACT.toString());
list.add(xpath2);
XPathAndFilter xpath3 = new XPathAndFilter("//n0:ReallyToBeSigned", XPathType.Filter.UNION.toString());
list.add(xpath3);
List<AlgorithmMethod> result = new ArrayList<AlgorithmMethod>(2);
result.add(XmlSignatureHelper.getCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE));
result.add(XmlSignatureHelper.getXPath2Transform(list, getNamespaceMap()));
return result;
}
示例14: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)
throws KeySelectorException {
if (keyInfo == null) {
throw new KeySelectorException("Null KeyInfo object!");
}
SignatureMethod sm = (SignatureMethod) method;
@SuppressWarnings("rawtypes")
List list = keyInfo.getContent();
for (int i = 0; i < list.size(); i++) {
XMLStructure xmlStructure = (XMLStructure) list.get(i);
if (xmlStructure instanceof KeyValue) {
PublicKey pk = null;
try {
pk = ((KeyValue) xmlStructure).getPublicKey();
} catch (KeyException ke) {
throw new KeySelectorException(ke);
}
// make sure algorithm is compatible with method
if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
return new SimpleKeySelectorResult(pk);
}
}
}
throw new KeySelectorException("No KeyValue element found!");
}
示例15: select
import javax.xml.crypto.AlgorithmMethod; //导入依赖的package包/类
@Override
public KeySelectorResult select(final KeyInfo keyInfo,
final KeySelector.Purpose purpose,
final AlgorithmMethod method,
final XMLCryptoContext context)
throws KeySelectorException
{
if (keyInfo == null) {
throw new KeySelectorException("null KeyInfo");
}
List<?> list = keyInfo.getContent();
for (int i = 0; i < list.size(); i++) {
XMLStructure xmlStructure = (XMLStructure) list.get(i);
PublicKey pk = null;
if (xmlStructure instanceof KeyValue) {
try {
pk = ((KeyValue)xmlStructure).getPublicKey();
} catch (KeyException ke) {
throw new KeySelectorException(ke);
}
} else if (xmlStructure instanceof X509Data) {
List<sun.security.x509.X509CertImpl> certs = ((X509Data)xmlStructure).getContent();
pk = certs.get(0).getPublicKey();
} else {
log.error(xmlStructure + " not supported");
continue;
}
return new SimpleKeySelectorResult(pk);
}
throw new KeySelectorException("No supported KeyValue element found");
}