/** * 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()); }
/** * 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()); }
/** {@inheritDoc} */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof BaseObligationHandler) { return DatatypeHelper.safeEquals(getObligationId(), ((BaseObligationHandler) obj).getObligationId()); } return false; } }
/** {@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); }
/** {@inheritDoc} */ protected boolean entityAttributeValueMatches(String entityAttributeValue) { return DatatypeHelper.safeEquals(getValue(), DatatypeHelper.safeTrim(entityAttributeValue)); } }
/** {@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); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") public boolean equals(Object o) { if(o == this){ return true; } if (o instanceof Pair) { Pair<T1, T2> otherPair = (Pair<T1, T2>) o; return DatatypeHelper.safeEquals(getFirst(), otherPair.getFirst()) && DatatypeHelper.safeEquals(getSecond(), otherPair.getSecond()); } return false; }
/** {@inheritDoc} */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ScopedAttributeValue)) { return false; } ScopedAttributeValue otherValue = (ScopedAttributeValue) obj; return DatatypeHelper.safeEquals(getValue(), otherValue.getValue()) && DatatypeHelper.safeEquals(getScope(), otherValue.getScope()); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") public boolean equals(Object o) { if(o == this){ return true; } if (o instanceof Pair) { Pair<T1, T2> otherPair = (Pair<T1, T2>) o; return DatatypeHelper.safeEquals(getFirst(), otherPair.getFirst()) && DatatypeHelper.safeEquals(getSecond(), otherPair.getSecond()); } return false; }
/** * A helper function for derived classes. This 'nornmalizes' newString and then if it is different from oldString * invalidates the DOM. It returns the normalized value so subclasses just have to go. this.foo = * prepareForAssignment(this.foo, foo); * * @param oldValue - the current value * @param newValue - the new value * * @return the value that should be assigned */ protected String prepareForAssignment(String oldValue, String newValue) { String newString = DatatypeHelper.safeTrimOrNullString(newValue); if (!DatatypeHelper.safeEquals(oldValue, newString)) { releaseThisandParentDOM(); } return newString; }
/** * A helper function for derived classes. This 'nornmalizes' newString and then if it is different from oldString * invalidates the DOM. It returns the normalized value so subclasses just have to go. this.foo = * prepareForAssignment(this.foo, foo); * * @param oldValue - the current value * @param newValue - the new value * * @return the value that should be assigned */ protected String prepareForAssignment(String oldValue, String newValue) { String newString = DatatypeHelper.safeTrimOrNullString(newValue); if (!DatatypeHelper.safeEquals(oldValue, newString)) { releaseThisandParentDOM(); } return newString; }
/** * Unmarshalls a namespace declaration attribute. * * @param xmlObject the xmlObject to recieve the namespace decleration * @param attribute the namespace decleration attribute */ protected void unmarshallNamespaceAttribute(XMLObject xmlObject, Attr attribute) { if (log.isTraceEnabled()) { log.trace("{} is a namespace declaration, adding it to the list of namespaces on the XMLObject", XMLHelper.getNodeQName(attribute)); } Namespace namespace; if(DatatypeHelper.safeEquals(attribute.getLocalName(), XMLConstants.XMLNS_PREFIX)){ namespace = new Namespace(attribute.getValue(), null); }else{ namespace = new Namespace(attribute.getValue(), attribute.getLocalName()); } namespace.setAlwaysDeclare(true); xmlObject.getNamespaceManager().registerNamespaceDeclaration(namespace); }
/** * A helper function for derived classes. The mutator/setter method for any ID-typed attributes should call this * method in order to handle getting the old value removed from the ID-to-XMLObject mapping, and the new value added * to the mapping. * * @param oldID the old value of the ID-typed attribute * @param newID the new value of the ID-typed attribute */ protected void registerOwnID(String oldID, String newID) { String newString = DatatypeHelper.safeTrimOrNullString(newID); if (!DatatypeHelper.safeEquals(oldID, newString)) { if (oldID != null) { idIndex.deregisterIDMapping(oldID); } if (newString != null) { idIndex.registerIDMapping(newString, this); } } }
/** {@inheritDoc} */ public void setValue(String newValue) { // Dump our cached DOM if the new value really is new String currentCert = B64_CERT_STORE.get(b64CertIndex); String b64Cert = prepareForAssignment(currentCert, newValue); // This is a new value, remove the old one, add the new one if (!DatatypeHelper.safeEquals(currentCert, b64Cert)) { B64_CERT_STORE.remove(b64CertIndex); b64CertIndex = B64_CERT_STORE.put(b64Cert); } }
/** {@inheritDoc} */ public void setValue(String newValue) { // Dump our cached DOM if the new value really is new String currentCert = B64_CRL_STORE.get(b64CRLIndex); String b64Cert = prepareForAssignment(currentCert, newValue); // This is a new value, remove the old one, add the new one if (!DatatypeHelper.safeEquals(currentCert, b64Cert)) { B64_CRL_STORE.remove(b64CRLIndex); b64CRLIndex = B64_CRL_STORE.put(b64Cert); } }
/** {@inheritDoc} */ public void setValue(String newValue) { // Dump our cached DOM if the new value really is new String currentCert = B64_CERT_STORE.get(b64CertIndex); String b64Cert = prepareForAssignment(currentCert, newValue); // This is a new value, remove the old one, add the new one if (!DatatypeHelper.safeEquals(currentCert, b64Cert)) { B64_CERT_STORE.remove(b64CertIndex); b64CertIndex = B64_CERT_STORE.put(b64Cert); } }
/** {@inheritDoc} */ public void setValue(String newValue) { // Dump our cached DOM if the new value really is new String currentCert = B64_CRL_STORE.get(b64CRLIndex); String b64Cert = prepareForAssignment(currentCert, newValue); // This is a new value, remove the old one, add the new one if (!DatatypeHelper.safeEquals(currentCert, b64Cert)) { B64_CRL_STORE.remove(b64CRLIndex); b64CRLIndex = B64_CRL_STORE.put(b64Cert); } }
/** * Get the prefix bound to the specified namespace URI within the scope of the specified * XMLObject. * * @param xmlObject the XMLObject from which to search * @param namespaceURI the namespace URI to search * @return the prefix bound to the namespace URI, or none if not found */ public static String lookupNamespacePrefix(XMLObject xmlObject, String namespaceURI) { XMLObject current = xmlObject; while (current != null) { for (Namespace ns : current.getNamespaces()) { if (DatatypeHelper.safeEquals(ns.getNamespaceURI(), namespaceURI)) { return ns.getNamespacePrefix(); } } current = current.getParent(); } return null; }
/** * Validates the Version attribute * * @param response * @throws ValidationException */ protected void validateVersion(StatusResponse response) throws ValidationException { if (response.getVersion() == null) throw new ValidationException("Version attribute must not be null"); if (!DatatypeHelper.safeEquals(response.getVersion().toString(), SAMLVersion.VERSION_20.toString())) throw new ValidationException("Wrong SAML Version"); }
/** * Validates the Version attribute. * * @param request request to validate * @throws ValidationException if invalid */ protected void validateVersion(RequestAbstractType request) throws ValidationException { if (request.getVersion() == null) { throw new ValidationException("Version attribute must not be null"); } if (!DatatypeHelper.safeEquals(request.getVersion().toString(), SAMLVersion.VERSION_20.toString())) { throw new ValidationException("Wrong SAML Version"); } }