/** * Returns the octet value of the SignatureValue element. * Throws an XMLSignatureException if it has no or wrong content. * * @return the value of the SignatureValue element. * @throws XMLSignatureException If there is no content */ public byte[] getSignatureValue() throws XMLSignatureException { String content = XMLUtils.getFullTextChildrenFromElement(signatureValueElement); return XMLUtils.decode(content); }
/** * Method getBytesFromTextChild * * @return The base64 bytes from the text children of this element * @throws XMLSecurityException */ public byte[] getBytesFromTextChild() throws XMLSecurityException { return XMLUtils.decode(getTextFromTextChild()); }
/** * Get the pre-calculated digest value from the XMLSignatureInput. * * @param input XMLSignature * @return a pre-calculated digest value. * @throws ReferenceNotInitializedException if there is an error decoding digest value * in Base64. Properly encoded pre-calculated digest value must be set. */ private byte[] getPreCalculatedDigest(XMLSignatureInput input) throws ReferenceNotInitializedException { LOG.debug("Verifying element with pre-calculated digest"); String preCalculatedDigest = input.getPreCalculatedDigest(); return XMLUtils.decode(preCalculatedDigest); }
/** * Get the Salt value of this UsernameToken. * * @return Returns the binary Salt value or <code>null</code> if no Salt * value is available in the username token. * @throws WSSecurityException */ public byte[] getSalt() throws WSSecurityException { String salt = XMLUtils.getElementText(elementSalt); if (salt != null) { return org.apache.xml.security.utils.XMLUtils.decode(salt); } return null; }
/** * Method getDecodedBase64EncodedData * * @param element * @return a byte array containing the decoded data * @throws WSSecurityException */ public static byte[] getDecodedBase64EncodedData(Element element) throws WSSecurityException { String text = XMLUtils.getElementText(element); if (text == null) { return null; } return org.apache.xml.security.utils.XMLUtils.decode(text); } }
/** * get the byte array containing token information. * * @return the byte array containing token information */ public byte[] getToken() { if (data != null) { return data; } String text = XMLUtils.getElementText(element); if (text == null) { return null; } return org.apache.xml.security.utils.XMLUtils.decode(text); }
private ByteArrayInputStream unmarshalBase64Binary(Element elem) throws MarshalException { try { if (cf == null) { cf = CertificateFactory.getInstance("X.509"); } String content = XMLUtils.getFullTextChildrenFromElement(elem); return new ByteArrayInputStream(XMLUtils.decode(content)); } catch (CertificateException e) { throw new MarshalException("Cannot create CertificateFactory", e); } }
public static BigInteger decode(Element elem) throws MarshalException { try { String base64str = BaseStructure.textOfNode(elem); return new BigInteger(1, XMLUtils.decode(base64str)); } catch (Exception ex) { throw new MarshalException(ex); } }
DOMSignatureValue(Element sigValueElem) throws MarshalException { // base64 decode signatureValue String content = XMLUtils.getFullTextChildrenFromElement(sigValueElem); value = XMLUtils.decode(content); id = DOMUtils.getIdAttributeValue(sigValueElem, "Id"); }
public byte[] getSKIBytes() { if (skiBytes != null) { return skiBytes; } String text = XMLUtils.getElementText(getFirstElement()); if (text != null) { skiBytes = org.apache.xml.security.utils.XMLUtils.decode(text); } return skiBytes; }
@Override protected Key getKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algorithmUsage, String correlationID) throws XMLSecurityException { Key key = super.getKey(algorithmURI, algorithmUsage, correlationID); if (key == null) { String algoFamily = JCEAlgorithmMapper.getJCEKeyAlgorithmFromURI(algorithmURI); key = new SecretKeySpec(XMLUtils.decode(stringBuilder.toString()), algoFamily); setSecretKey(algorithmURI, key); } return key; } };
/** * Constructs a <code>SignatureConfirmation</code> object and parses the * <code>wsse11:SignatureConfirmation</code> element to initialize it. * * @param elem the <code>wsse11:SignatureCOnfirmation</code> element that * contains the confirmation data * @param bspEnforcer a BSPEnforcer instance used to enforce BSP rules */ public SignatureConfirmation(Element elem, BSPEnforcer bspEnforcer) throws WSSecurityException { element = elem; String id = getID(); if (id == null || "".equals(id)) { bspEnforcer.handleBSPRule(BSPRule.R5441); } String sv = element.getAttributeNS(null, SC_VALUE_ATTR); if (sv != null) { signatureValue = org.apache.xml.security.utils.XMLUtils.decode(sv); } }
/** * Returns the digest value. * * @return the digest value. * @throws XMLSecurityException if the Reference does not contain a DigestValue element */ public byte[] getDigestValue() throws XMLSecurityException { if (digestValueElement == null) { // The required element is not in the XML! Object[] exArgs ={ Constants._TAG_DIGESTVALUE, Constants.SignatureSpecNS }; throw new XMLSecurityException( "signature.Verification.NoSignatureElement", exArgs ); } String content = XMLUtils.getFullTextChildrenFromElement(digestValueElement); return XMLUtils.decode(content); }
/** * Method getVal * * @param localname * @param namespace * @return The biginteger contained in the given element */ public BigInteger getBigIntegerFromChildElement( String localname, String namespace ) { return new BigInteger(1, XMLUtils.decode( XMLUtils.selectNodeText( getFirstChild(), namespace, localname, 0 ).getNodeValue() )); }
/** * Get the derived key. * * After the <code>prepare()</code> method was called use this method * to compute a derived key. The generation of this secret key is according * to the UsernameTokenProfile 1.1 specification (section 4 - Key Derivation). * * @return Return the derived key of this token or null if <code>prepare()</code> * was not called before. */ public byte[] getDerivedKey() throws WSSecurityException { if (ut == null || !useDerivedKey) { return null; } if (passwordsAreEncoded) { return UsernameTokenUtil.generateDerivedKey(org.apache.xml.security.utils.XMLUtils.decode(password), saltValue, iteration); } else { return UsernameTokenUtil.generateDerivedKey(password, saltValue, iteration); } }
private byte[] getSignatureValue(Signature signature) throws WSSecurityException { Element signatureElement = signature.getDOM(); if (signatureElement != null) { Element signedInfoElem = XMLUtils.getNextElement(signatureElement.getFirstChild()); if (signedInfoElem != null) { Element signatureValueElement = XMLUtils.getNextElement(signedInfoElem.getNextSibling()); if (signatureValueElement != null) { String base64Input = XMLUtils.getFullTextChildrenFromElement(signatureValueElement); return XMLUtils.decode(base64Input); } } } return null; }
/** * Derive a key from this DerivedKeyToken instance * @param length * @param secret * @throws WSSecurityException */ public byte[] deriveKey(int length, byte[] secret) throws WSSecurityException { try { byte[] nonce = org.apache.xml.security.utils.XMLUtils.decode(getNonce()); return DerivedKeyUtils.deriveKey(getAlgorithm(), getLabel(), length, secret, nonce, getOffset()); } catch (Exception e) { throw new WSSecurityException( WSSecurityException.ErrorCode.FAILURE, e ); } }
/** * Create a WSUsernameTokenPrincipal from this UsernameToken object */ public Principal createPrincipal() throws WSSecurityException { WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(getName(), isHashed()); String nonce = getNonce(); if (nonce != null) { principal.setNonce(org.apache.xml.security.utils.XMLUtils.decode(nonce)); } principal.setPassword(getPassword()); principal.setCreatedTime(getCreated()); return principal; }
protected UsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement, boolean bspCompliant) throws WSSecurityException, Base64DecodingException { BSPEnforcer bspEnforcer = new org.apache.wss4j.common.bsp.BSPEnforcer(!bspCompliant); org.apache.wss4j.dom.message.token.UsernameToken ut = new org.apache.wss4j.dom.message.token.UsernameToken(tokenElement, false, bspEnforcer); WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(ut.getName(), ut.isHashed()); if (ut.getNonce() != null) { principal.setNonce(XMLUtils.decode(ut.getNonce())); } principal.setPassword(ut.getPassword()); principal.setCreatedTime(ut.getCreated()); principal.setPasswordType(ut.getPasswordType()); return principal; }
protected UsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement, boolean bspCompliant) throws WSSecurityException, Base64DecodingException { BSPEnforcer bspEnforcer = new org.apache.wss4j.common.bsp.BSPEnforcer(!bspCompliant); org.apache.wss4j.dom.message.token.UsernameToken ut = new org.apache.wss4j.dom.message.token.UsernameToken(tokenElement, false, bspEnforcer); WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(ut.getName(), ut.isHashed()); if (ut.getNonce() != null) { principal.setNonce(XMLUtils.decode(ut.getNonce())); } principal.setPassword(ut.getPassword()); principal.setCreatedTime(ut.getCreated()); principal.setPasswordType(ut.getPasswordType()); return principal; }