本文整理汇总了Java中com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException类的典型用法代码示例。如果您正苦于以下问题:Java XMLSecurityException类的具体用法?Java XMLSecurityException怎么用?Java XMLSecurityException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLSecurityException类属于com.sun.org.apache.xml.internal.security.exceptions包,在下文中一共展示了XMLSecurityException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XPath2FilterContainer04
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Constructor XPath2FilterContainer04
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
private XPath2FilterContainer04(Element element, String BaseURI)
throws XMLSecurityException {
super(element, BaseURI);
String filterStr =
this.constructionElement.getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER);
if (!filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT)
&& !filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT)
&& !filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_UNION)) {
Object exArgs[] = { XPath2FilterContainer04._ATT_FILTER, filterStr,
XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT
+ ", "
+ XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT
+ " or "
+ XPath2FilterContainer04._ATT_FILTER_VALUE_UNION };
throw new XMLSecurityException("attributeValueIllegal", exArgs);
}
}
示例2: XPath2FilterContainer
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Constructor XPath2FilterContainer
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
private XPath2FilterContainer(Element element, String BaseURI) throws XMLSecurityException {
super(element, BaseURI);
String filterStr =
this.constructionElement.getAttributeNS(null, XPath2FilterContainer._ATT_FILTER);
if (!filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT)
&& !filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT)
&& !filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION)) {
Object exArgs[] = { XPath2FilterContainer._ATT_FILTER, filterStr,
XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT
+ ", "
+ XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT
+ " or "
+ XPath2FilterContainer._ATT_FILTER_VALUE_UNION };
throw new XMLSecurityException("attributeValueIllegal", exArgs);
}
}
示例3: verify
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Tests reference validation is success or false
*
* @return true if reference validation is success, otherwise false
* @throws ReferenceNotInitializedException
* @throws XMLSecurityException
*/
public boolean verify()
throws ReferenceNotInitializedException, XMLSecurityException {
byte[] elemDig = this.getDigestValue();
byte[] calcDig = this.calculateDigest(true);
boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);
if (!equal) {
log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
} else {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
}
}
return equal;
}
示例4: guaranteeThatElementInCorrectSpace
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
public void guaranteeThatElementInCorrectSpace(
ElementProxy expected, Element actual
) throws XMLSecurityException {
String expectedLocalname = expected.getBaseLocalName();
String expectedNamespace = expected.getBaseNamespace();
String localnameIS = actual.getLocalName();
String namespaceIS = actual.getNamespaceURI();
if ((expectedNamespace != namespaceIS) ||
!expectedLocalname.equals(localnameIS)) {
Object exArgs[] = { namespaceIS + ":" + localnameIS,
expectedNamespace + ":" + expectedLocalname};
throw new XMLSecurityException("xml.WrongElement", exArgs);
}
}
示例5: engineLookupResolveX509Certificate
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/** {@inheritDoc}. */
public X509Certificate engineLookupResolveX509Certificate(Element element, String baseURI, StorageResolver storage)
throws KeyResolverException {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
}
if (!engineCanResolve(element, baseURI, storage)) {
return null;
}
try {
return resolveCertificate(element, baseURI, storage);
} catch (XMLSecurityException e) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "XMLSecurityException", e);
}
}
return null;
}
示例6: ElementProxy
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Constructor ElementProxy
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public ElementProxy(Element element, String BaseURI) throws XMLSecurityException {
if (element == null) {
throw new XMLSecurityException("ElementProxy.nullElement");
}
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "setElement(\"" + element.getTagName() + "\", \"" + BaseURI + "\")");
}
this.doc = element.getOwnerDocument();
this.constructionElement = element;
this.baseURI = BaseURI;
this.guaranteeThatElementInCorrectSpace();
}
示例7: engineLookupAndResolvePublicKey
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/** {@inheritDoc}. */
public PublicKey engineLookupAndResolvePublicKey(Element element, String baseURI, StorageResolver storage)
throws KeyResolverException {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
}
if (!engineCanResolve(element, baseURI, storage)) {
return null;
}
try {
DEREncodedKeyValue derKeyValue = new DEREncodedKeyValue(element, baseURI);
return derKeyValue.getPublicKey();
} catch (XMLSecurityException e) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "XMLSecurityException", e);
}
}
return null;
}
示例8: validateReference
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Validate the Element referred to by the KeyInfoReference.
*
* @param referentElement
*
* @throws XMLSecurityException
*/
private void validateReference(Element referentElement) throws XMLSecurityException {
if (!XMLUtils.elementIsInSignatureSpace(referentElement, Constants._TAG_KEYINFO)) {
Object exArgs[] = { new QName(referentElement.getNamespaceURI(), referentElement.getLocalName()) };
throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.WrongType", exArgs);
}
KeyInfo referent = new KeyInfo(referentElement, "");
if (referent.containsKeyInfoReference()) {
if (secureValidation) {
throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.ReferenceWithSecure");
} else {
// Don't support chains of references at this time. If do support in the future, this is where the code
// would go to validate that don't have a cycle, resulting in an infinite loop. This may be unrealistic
// to implement, and/or very expensive given remote URI references.
throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.ReferenceWithoutSecure");
}
}
}
示例9: SignedInfo
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* @param doc
* @param signatureMethodElem
* @param canonicalizationMethodElem
* @throws XMLSecurityException
*/
public SignedInfo(
Document doc, Element signatureMethodElem, Element canonicalizationMethodElem
) throws XMLSecurityException {
super(doc);
// Check this?
this.c14nMethod = canonicalizationMethodElem;
this.constructionElement.appendChild(c14nMethod);
XMLUtils.addReturnToElement(this.constructionElement);
this.signatureAlgorithm =
new SignatureAlgorithm(signatureMethodElem, null);
signatureMethod = this.signatureAlgorithm.getElement();
this.constructionElement.appendChild(signatureMethod);
XMLUtils.addReturnToElement(this.constructionElement);
}
示例10: getInclusiveNamespaces
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
public String getInclusiveNamespaces() {
String c14nMethodURI = c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
if (!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
return null;
}
Element inclusiveElement = XMLUtils.getNextElement(c14nMethod.getFirstChild());
if (inclusiveElement != null) {
try {
String inclusiveNamespaces =
new InclusiveNamespaces(
inclusiveElement,
InclusiveNamespaces.ExclusiveCanonicalizationNamespace
).getInclusiveNamespaces();
return inclusiveNamespaces;
} catch (XMLSecurityException e) {
return null;
}
}
return null;
}
示例11: newKeyInfo
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* @param element
* @return a new KeyInfo
* @throws XMLEncryptionException
*/
KeyInfo newKeyInfo(Element element) throws XMLEncryptionException {
try {
KeyInfo ki = new KeyInfo(element, null);
ki.setSecureValidation(secureValidation);
if (internalKeyResolvers != null) {
int size = internalKeyResolvers.size();
for (int i = 0; i < size; i++) {
ki.registerInternalKeyResolver(internalKeyResolvers.get(i));
}
}
return ki;
} catch (XMLSecurityException xse) {
throw new XMLEncryptionException("Error loading Key Info", xse);
}
}
示例12: SignatureAlgorithm
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Constructor SignatureAlgorithm
*
* @param element
* @param baseURI
* @param secureValidation
* @throws XMLSecurityException
*/
public SignatureAlgorithm(
Element element, String baseURI, boolean secureValidation
) throws XMLSecurityException {
super(element, baseURI);
algorithmURI = this.getURI();
Attr attr = element.getAttributeNodeNS(null, "Id");
if (attr != null) {
element.setIdAttributeNode(attr, true);
}
if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI)
|| XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) {
Object exArgs[] = { algorithmURI };
throw new XMLSecurityException("signature.signatureAlgorithm", exArgs);
}
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(this.constructionElement);
}
示例13: engineLookupAndResolvePublicKey
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/** {@inheritDoc}. */
public PublicKey engineLookupAndResolvePublicKey(Element element, String baseURI, StorageResolver storage)
throws KeyResolverException {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
}
if (!engineCanResolve(element, baseURI, storage)) {
return null;
}
try {
KeyInfo referent = resolveReferentKeyInfo(element, baseURI, storage);
if (referent != null) {
return referent.getPublicKey();
}
} catch (XMLSecurityException e) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "XMLSecurityException", e);
}
}
return null;
}
示例14: setDefaultPrefix
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/**
* Method setDefaultPrefix
*
* @param namespace
* @param prefix
* @throws XMLSecurityException
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to set the default prefix
*/
public static void setDefaultPrefix(String namespace, String prefix)
throws XMLSecurityException {
JavaUtils.checkRegisterPermission();
if (prefixMappings.containsValue(prefix)) {
String storedPrefix = prefixMappings.get(namespace);
if (!storedPrefix.equals(prefix)) {
Object exArgs[] = { prefix, namespace, storedPrefix };
throw new XMLSecurityException("prefix.AlreadyAssigned", exArgs);
}
}
if (Constants.SignatureSpecNS.equals(namespace)) {
XMLUtils.setDsPrefix(prefix);
}
if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) {
XMLUtils.setXencPrefix(prefix);
}
prefixMappings.put(namespace, prefix);
}
示例15: engineLookupAndResolvePrivateKey
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; //导入依赖的package包/类
/** {@inheritDoc}. */
public PrivateKey engineLookupAndResolvePrivateKey(Element element, String baseURI, StorageResolver storage)
throws KeyResolverException {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
}
if (!engineCanResolve(element, baseURI, storage)) {
return null;
}
try {
KeyInfo referent = resolveReferentKeyInfo(element, baseURI, storage);
if (referent != null) {
return referent.getPrivateKey();
}
} catch (XMLSecurityException e) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "XMLSecurityException", e);
}
}
return null;
}