public int hashCode() { int result = 17; try { byte[] bytes = getSKIBytes(); for (int i = 0; i < bytes.length; i++) { result = 31 * result + bytes[i]; } } catch (XMLSecurityException e) { LOG.debug(e.getMessage(), e); } return result; }
public int hashCode() { int result = 17; try { byte[] bytes = getCertificateBytes(); for (int i = 0; i < bytes.length; i++) { result = 31 * result + bytes[i]; } } catch (XMLSecurityException e) { LOG.debug(e.getMessage(), e); } return result; }
public OutboundSecurityToken getSecurityToken() { try { return securityTokenProvider.getSecurityToken(); } catch (XMLSecurityException e) { LOG.debug(e.getMessage(), e); } return null; } };
private SecretKey getSecretKeyFromToken(KerberosServiceSecurityToken kerberosToken) { try { Map<String, Key> secretKeys = kerberosToken.getSecretKey(); if (secretKeys != null) { SecretKey foundKey = null; for (Entry<String, Key> entry : kerberosToken.getSecretKey().entrySet()) { if (entry.getValue() instanceof SecretKey) { SecretKey secretKey = (SecretKey)entry.getValue(); if (foundKey == null || secretKey.getEncoded().length > foundKey.getEncoded().length) { foundKey = secretKey; } } } return foundKey; } } catch (XMLSecurityException e) { LOG.fine(e.getMessage()); } return null; } }
private SecretKey getSecretKeyFromToken(KerberosServiceSecurityToken kerberosToken) { try { Map<String, Key> secretKeys = kerberosToken.getSecretKey(); if (secretKeys != null) { SecretKey foundKey = null; for (Entry<String, Key> entry : kerberosToken.getSecretKey().entrySet()) { if (entry.getValue() instanceof SecretKey) { SecretKey secretKey = (SecretKey)entry.getValue(); if (foundKey == null || secretKey.getEncoded().length > foundKey.getEncoded().length) { foundKey = secretKey; } } } return foundKey; } } catch (XMLSecurityException e) { LOG.fine(e.getMessage()); } return null; } }
private boolean matchKey(TokenCancellerParameters tokenParameters, byte[] secretKey) { Map<String, Object> messageContext = tokenParameters.getMessageContext(); if (matchDOMSignatureSecret(messageContext, secretKey)) { return true; } try { if (matchStreamingSignatureSecret(messageContext, secretKey)) { return true; } } catch (XMLSecurityException ex) { LOG.log(Level.FINE, ex.getMessage(), ex); return false; } return false; }
private boolean matchKey(TokenCancellerParameters tokenParameters, byte[] secretKey) { Map<String, Object> messageContext = tokenParameters.getMessageContext(); if (matchDOMSignatureSecret(messageContext, secretKey)) { return true; } try { if (matchStreamingSignatureSecret(messageContext, secretKey)) { return true; } } catch (XMLSecurityException ex) { LOG.log(Level.FINE, ex.getMessage(), ex); return false; } return false; }
XMLSecurityException ex = new XMLSecurityException("empty", new Object[] {"The request was not signed or encrypted"}); throwFault(ex.getMessage(), ex); XMLSecurityException ex = new XMLSecurityException("empty", new Object[] {"The request was not signed"}); throwFault(ex.getMessage(), ex); XMLSecurityException ex = new XMLSecurityException("empty", new Object[] {"The request was not encrypted"}); throwFault(ex.getMessage(), ex);
XMLSecurityException ex = new XMLSecurityException("empty", new Object[] {"The request was not signed or encrypted"}); throwFault(ex.getMessage(), ex); XMLSecurityException ex = new XMLSecurityException("empty", new Object[] {"The request was not signed"}); throwFault(ex.getMessage(), ex); XMLSecurityException ex = new XMLSecurityException("empty", new Object[] {"The request was not encrypted"}); throwFault(ex.getMessage(), ex);
LOG.log(Level.FINE, e.getMessage(), e); return null;
LOG.log(Level.FINE, e.getMessage(), e); return null;
LOG.log(Level.FINE, ex.getMessage(), ex); return null;
private XMLSignature createSignature(Document signatureDocument, String baseUri, String signingKeyAlgorithm) throws XAdES4jXMLSigException, UnsupportedAlgorithmException { Algorithm signatureAlg = this.algorithmsProvider.getSignatureAlgorithm(signingKeyAlgorithm); if (null == signatureAlg) { throw new NullPointerException("Signature algorithm not provided"); } Element signatureAlgElem = createElementForAlgorithm(signatureAlg, Constants._TAG_SIGNATUREMETHOD, signatureDocument); Algorithm canonAlg = this.algorithmsProvider.getCanonicalizationAlgorithmForSignature(); if (null == canonAlg) { throw new NullPointerException("Canonicalization algorithm not provided"); } Element canonAlgElem = createElementForAlgorithm(canonAlg, Constants._TAG_CANONICALIZATIONMETHOD, signatureDocument); try { return new XMLSignature(signatureDocument, baseUri, signatureAlgElem, canonAlgElem); } catch (XMLSecurityException ex) { // Following the code, doesn't seem to be thrown at all. throw new XAdES4jXMLSigException(ex.getMessage(), ex); } }
LOG.debug(ex.getMessage(), ex);
LOG.log(Level.FINE, ex.getMessage(), ex); return null;
/** {@inheritDoc} */ public Signature unmarshall(Element signatureElement) throws UnmarshallingException { log.debug("Starting to unmarshall Apache XML-Security-based SignatureImpl element"); SignatureImpl signature = new SignatureImpl(signatureElement.getNamespaceURI(), signatureElement.getLocalName(), signatureElement.getPrefix()); try { log.debug("Constructing Apache XMLSignature object"); XMLSignature xmlSignature = new XMLSignature(signatureElement, ""); SignedInfo signedInfo = xmlSignature.getSignedInfo(); log.debug("Adding canonicalization and signing algorithms, and HMAC output length to Signature"); signature.setCanonicalizationAlgorithm(signedInfo.getCanonicalizationMethodURI()); signature.setSignatureAlgorithm(signedInfo.getSignatureMethodURI()); signature.setHMACOutputLength(getHMACOutputLengthValue(signedInfo.getSignatureMethodElement())); org.apache.xml.security.keys.KeyInfo xmlSecKeyInfo = xmlSignature.getKeyInfo(); if (xmlSecKeyInfo != null) { log.debug("Adding KeyInfo to Signature"); Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller( xmlSecKeyInfo.getElement()); KeyInfo keyInfo = (KeyInfo) unmarshaller.unmarshall(xmlSecKeyInfo.getElement()); signature.setKeyInfo(keyInfo); } signature.setXMLSignature(xmlSignature); signature.setDOM(signatureElement); return signature; } catch (XMLSecurityException e) { log.error("Error constructing Apache XMLSignature instance from Signature element: {}", e.getMessage()); throw new UnmarshallingException("Unable to unmarshall Signature with Apache XMLSignature", e); } }
LOG.error(ex.getMessage(), ex);
/** {@inheritDoc} */ public Signature unmarshall(Element signatureElement) throws UnmarshallingException { log.debug("Starting to unmarshall Apache XML-Security-based SignatureImpl element"); SignatureImpl signature = new SignatureImpl(signatureElement.getNamespaceURI(), signatureElement.getLocalName(), signatureElement.getPrefix()); try { log.debug("Constructing Apache XMLSignature object"); XMLSignature xmlSignature = new XMLSignature(signatureElement, ""); SignedInfo signedInfo = xmlSignature.getSignedInfo(); log.debug("Adding canonicalization and signing algorithms, and HMAC output length to Signature"); signature.setCanonicalizationAlgorithm(signedInfo.getCanonicalizationMethodURI()); signature.setSignatureAlgorithm(signedInfo.getSignatureMethodURI()); signature.setHMACOutputLength(getHMACOutputLengthValue(signedInfo.getSignatureMethodElement())); org.apache.xml.security.keys.KeyInfo xmlSecKeyInfo = xmlSignature.getKeyInfo(); if (xmlSecKeyInfo != null) { log.debug("Adding KeyInfo to Signature"); Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller( xmlSecKeyInfo.getElement()); KeyInfo keyInfo = (KeyInfo) unmarshaller.unmarshall(xmlSecKeyInfo.getElement()); signature.setKeyInfo(keyInfo); } signature.setXMLSignature(xmlSignature); signature.setDOM(signatureElement); return signature; } catch (XMLSecurityException e) { log.error("Error constructing Apache XMLSignature instance from Signature element: {}", e.getMessage()); throw new UnmarshallingException("Unable to unmarshall Signature with Apache XMLSignature", e); } }
/** * Extract the reference within the provided XML signature while ensuring that there * is only one such reference, and that (if appropriate) it is not empty. * * @param signature signature to extract the reference from * @return the extracted reference * @throws ValidationException if a reference could not be extracted */ private Reference extractReference(@Nonnull final XMLSignature signature) throws ValidationException { int numReferences = signature.getSignedInfo().getLength(); if (numReferences != 1) { throw new ValidationException("Signature SignedInfo had invalid number of References: " + numReferences); } try { final Reference ref = signature.getSignedInfo().item(0); if (ref == null) { throw new ValidationException("Signature Reference was null"); } if (!emptyReferencePermitted) { if (Strings.isNullOrEmpty(ref.getURI())) { throw new ValidationException("empty references are not permitted"); } } return ref; } catch (XMLSecurityException e) { throw new ValidationException("Apache XML Security exception obtaining Reference: " + e.getMessage()); } }
httpsSecurityToken.addTokenUsage(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE); } catch (XMLSecurityException e) { LOG.fine(e.getMessage());