if (DatatypeHelper.isEmpty(encodedMessage)) { log.error("Request did not contain either a SAMLRequest or " + "SAMLResponse paramter. Invalid request for SAML 2 HTTP POST binding.");
/** * Set the entity protocol. * * @param protocol The protocol to set. */ public void setProtocol(String protocol) { entityProtocol = DatatypeHelper.safeTrimOrNullString(protocol); }
/** * Set the digest algorithm. * * @param alg the digest algorithm to set */ public void setAlgorithm(String alg) { if (DatatypeHelper.isEmpty(alg)) { throw new IllegalArgumentException("Digest algorithm criteria value cannot be null or empty"); } algorithm = DatatypeHelper.safeTrimOrNullString(alg); }
/** {@inheritDoc} */ protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { return DatatypeHelper.safeTrim(element.getAttributeNS(null, "id")); } }
/** * Shortcut for checking a DOM element node's namespace and local name. * * @param e An element to compare against * @param ns An XML namespace to compare * @param localName A local name to compare * @return true iff the element's local name and namespace match the parameters */ public static boolean isElementNamed(Element e, String ns, String localName) { return e != null && DatatypeHelper.safeEquals(ns, e.getNamespaceURI()) && DatatypeHelper.safeEquals(localName, e.getLocalName()); }
/** * Gets the list value of the <code>soap11:encodingStyle</code> attribute from the given SOAP object. * * @param soapObject the SOAP object to add the attribute to * * @return the list of encoding styles, or null if not present */ public static List<String> getSOAP11EncodingStyles(XMLObject soapObject) { if (soapObject instanceof EncodingStyleBearing) { List<String> value = ((EncodingStyleBearing) soapObject).getSOAP11EncodingStyles(); if (value != null) { return value; } } if (soapObject instanceof AttributeExtensibleXMLObject) { String value = DatatypeHelper.safeTrimOrNullString(((AttributeExtensibleXMLObject) soapObject) .getUnknownAttributes().get(EncodingStyleBearing.SOAP11_ENCODING_STYLE_ATTR_NAME)); if (value != null) { DatatypeHelper.stringToList(value, XMLHelper.LIST_DELIMITERS); } } return null; }
/** {@inheritDoc} */ protected boolean entityAttributeValueMatches(String entityAttributeValue) { return DatatypeHelper.safeEquals(getValue(), DatatypeHelper.safeTrim(entityAttributeValue)); } }
/** * Decodes X.509 certificates in DER or PEM format. * * @param certs encoded certs * * @return decoded certs * * @throws CertificateException thrown if the certificates can not be decoded * * @since 1.2 */ public static Collection<X509Certificate> decodeCertificate(File certs) throws CertificateException{ if(!certs.exists()){ throw new CertificateException("Certificate file " + certs.getAbsolutePath() + " does not exist"); } if(!certs.canRead()){ throw new CertificateException("Certificate file " + certs.getAbsolutePath() + " is not readable"); } try{ return decodeCertificate(DatatypeHelper.fileToByteArray(certs)); }catch(IOException e){ throw new CertificateException("Error reading certificate file " + certs.getAbsolutePath(), e); } }
/** * Gets the value of a list-type element as a list. * * @param element element whose value will be turned into a list * * @return list of values, never null */ public static List<String> getElementContentAsList(Element element) { if (element == null) { return Collections.emptyList(); } return DatatypeHelper.stringToList(element.getTextContent(), LIST_DELIMITERS); }
/** * Marshall an attribute name and value to a DOM Element. This is particularly useful for attributes whose names * appear in namespace-qualified form. * * @param attributeName the attribute name in QName form * @param attributeValues the attribute values * @param domElement the target element to which to marshall * @param isIDAttribute flag indicating whether the attribute being marshalled should be handled as an ID-typed * attribute */ public static void marshallAttribute(QName attributeName, List<String> attributeValues, Element domElement, boolean isIDAttribute) { marshallAttribute(attributeName, DatatypeHelper.listToStringValue(attributeValues, " "), domElement, isIDAttribute); }
/** {@inheritDoc} */ protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { return DatatypeHelper.safeTrim(element.getAttributeNS(null, "id")); } }
/** * Shortcut for checking a DOM element node's namespace and local name. * * @param e An element to compare against * @param ns An XML namespace to compare * @param localName A local name to compare * @return true iff the element's local name and namespace match the parameters */ public static boolean isElementNamed(Element e, String ns, String localName) { return e != null && DatatypeHelper.safeEquals(ns, e.getNamespaceURI()) && DatatypeHelper.safeEquals(localName, e.getLocalName()); }
/** * Gets the list value of the <code>wsse:Usage</code> attribute from the given SOAP object. * * @param soapObject the SOAP object to add the attribute to * * @return the list of usages, or null if not present */ public static List<String> getWSSEUsages(XMLObject soapObject) { if (soapObject instanceof UsageBearing) { List<String> value = ((UsageBearing)soapObject).getWSSEUsages(); if (value != null) { return value; } } if (soapObject instanceof AttributeExtensibleXMLObject) { String value = DatatypeHelper.safeTrimOrNullString(((AttributeExtensibleXMLObject)soapObject) .getUnknownAttributes().get(UsageBearing.WSSE_USAGE_ATTR_NAME)); if (value != null) { DatatypeHelper.stringToList(value, XMLHelper.LIST_DELIMITERS); } } return null; } }
/** * Decodes X.509 certificates in DER or PEM format. * * @param certs encoded certs * * @return decoded certs * * @throws CertificateException thrown if the certificates can not be decoded * * @since 1.2 */ public static Collection<X509Certificate> decodeCertificate(File certs) throws CertificateException{ if(!certs.exists()){ throw new CertificateException("Certificate file " + certs.getAbsolutePath() + " does not exist"); } if(!certs.canRead()){ throw new CertificateException("Certificate file " + certs.getAbsolutePath() + " is not readable"); } try{ return decodeCertificate(DatatypeHelper.fileToByteArray(certs)); }catch(IOException e){ throw new CertificateException("Error reading certificate file " + certs.getAbsolutePath(), e); } }
/** * Gets the value of a list-type element as a list. * * @param element element whose value will be turned into a list * * @return list of values, never null */ public static List<String> getElementContentAsList(Element element) { if (element == null) { return Collections.emptyList(); } return DatatypeHelper.stringToList(element.getTextContent(), LIST_DELIMITERS); }
/** * Marshall an attribute name and value to a DOM Element. This is particularly useful for attributes whose names * appear in namespace-qualified form. * * @param attributeName the attribute name in QName form * @param attributeValues the attribute values * @param domElement the target element to which to marshall * @param isIDAttribute flag indicating whether the attribute being marshalled should be handled as an ID-typed * attribute */ public static void marshallAttribute(QName attributeName, List<String> attributeValues, Element domElement, boolean isIDAttribute) { marshallAttribute(attributeName, DatatypeHelper.listToStringValue(attributeValues, " "), domElement, isIDAttribute); }
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { ResourceMatchType matchType = (ResourceMatchType) xmlObject; if (!DatatypeHelper.isEmpty(matchType.getMatchId())) { domElement.setAttribute(ResourceMatchType.MATCH_ID_ATTRIB_NAME, matchType.getMatchId()); } }
/** * Constructor. * * @param uri the URI of the namespace * @param prefix the prefix of the namespace */ public Namespace(String uri, String prefix) { namespaceURI = DatatypeHelper.safeTrimOrNullString(uri); namespacePrefix = DatatypeHelper.safeTrimOrNullString(prefix); nsStr = null; }
/** {@inheritDoc} */ protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { return DatatypeHelper.safeTrim(element.getAttributeNS(null, "id")); } }
/** {@inheritDoc} */ public void setValue(String newValue) { if (bigIntValue != null && (!DatatypeHelper.safeEquals(getValue(), newValue) || newValue == null)) { // Just clear the cached value, my not be needed in big int form again, // let it be lazily recreated if necessary bigIntValue = null; } super.setValue(newValue); }