Transform saml object into string without indenting the final string.

@param configBean the config bean
@param samlObject the saml object
@return the string writer
@throws SamlException the saml exception
17394
public static StringWriter transformSamlObject(final OpenSamlConfigBean configBean, final XMLObject samlObject) throws SamlException {
        return transformSamlObject(configBean, samlObject, false);
    }
507233
def to_string(self, indent="", newl="", addindent=""):
        '''
        
        '''
        buf = StringIO()
        self.to_xml().writexml(buf, indent=indent, addindent=addindent,
                               newl=newl)
        return buf.getvalue()
857779
public void writeTagsToJavaScript(Writer writer) throws IOException
    {
        writer.append("function fillTagService(tagService) {\n");
        writer.append("\t// (name, isPrime, isPseudo, color), [parent tags]\n");
        for (Tag tag : definedTags.values())
        {
            writer.append("\ttagService.registerTag(new Tag(");
            escapeOrNull(tag.getName(), writer);
            writer.append(", ");
            escapeOrNull(tag.getTitle(), writer);
            writer.append(", ").append("" + tag.isPrime())
                        .append(", ").append("" + tag.isPseudo())
                        .append(", ");
            escapeOrNull(tag.getColor(), writer);
            writer.append(")").append(", [");

            // We only have strings, not references, so we're letting registerTag() getOrCreate() the tag.
            for (Tag parentTag : tag.getParentTags())
            {
                writer.append("'").append(StringEscapeUtils.escapeEcmaScript(parentTag.getName())).append("',");
            }
            writer.append("]);\n");
        }
        writer.append("}\n");
    }
244231
protected void appendFullDocumentHeader(StringBuilder sb, Document doc) {
        if (appendDocumentXmlDeclaration(sb, doc)) {
            sb.append("\n");
        }
        if (appendDocumentType(sb, doc.getDoctype())) {
            sb.append("\n");
        }
        appendOnlyElementStartTagWithAttributes(sb, doc.getDocumentElement());
    }
1107299
public static String serialize(Object obj) throws SerializationException {
		try {
			if (obj != null) {
				return mapper.writeValueAsString(obj);
			} else {
				return null;
			}
		} catch (Exception e) {
			logger.error("SerializationException {}", e.getMessage());
			throw new SerializationException(e.getMessage());
		}
	}
1288293
public String writeXmlDocumentAsString(Document document) throws IOException {
        try {
            Transformer tr = transformerFactory.newTransformer();
            tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            tr.setOutputProperty(OutputKeys.INDENT, "yes");
            StringWriter writer = new StringWriter();
            StreamResult result = new StreamResult(writer);
            TransformerFactory tf = TransformerFactory.newInstance();
            tr.transform(new DOMSource(document), result);
            return writer.toString();
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
1316898
@SuppressWarnings("unchecked")
    static <T extends SAMLObject> MessageContext<T> toSamlObject(
            AggregatedHttpMessage msg, String name,
            Map<String, SamlIdentityProviderConfig> idpConfigs,
            @Nullable SamlIdentityProviderConfig defaultIdpConfig) {
        requireNonNull(msg, "msg");
        requireNonNull(name, "name");
        requireNonNull(idpConfigs, "idpConfigs");

        final SamlParameters parameters = new SamlParameters(msg);
        final T message = (T) fromDeflatedBase64(parameters.getFirstValue(name));

        final MessageContext<T> messageContext = new MessageContext<>();
        messageContext.setMessage(message);

        final Issuer issuer;
        if (message instanceof RequestAbstractType) {
            issuer = ((RequestAbstractType) message).getIssuer();
        } else if (message instanceof StatusResponseType) {
            issuer = ((StatusResponseType) message).getIssuer();
        } else {
            throw new SamlException("invalid message type: " + message.getClass().getSimpleName());
        }

        // Use the default identity provider config if there's no issuer.
        final SamlIdentityProviderConfig config;
        if (issuer != null) {
            final String idpEntityId = issuer.getValue();
            config = idpConfigs.get(idpEntityId);
            if (config == null) {
                throw new SamlException("a message from unknown identity provider: " + idpEntityId);
            }
        } else {
            if (defaultIdpConfig == null) {
                throw new SamlException("failed to get an Issuer element");
            }
            config = defaultIdpConfig;
        }

        // If this message is sent via HTTP-redirect binding protocol, its signature parameter should
        // be validated.
        validateSignature(config.signingCredential(), parameters, name);

        final String relayState = parameters.getFirstValueOrNull(RELAY_STATE);
        if (relayState != null) {
            final SAMLBindingContext context = messageContext.getSubcontext(SAMLBindingContext.class, true);
            assert context != null;
            context.setRelayState(relayState);
        }

        return messageContext;
    }
53548
void writeConfigPropsXml(List<ConfigPropType> props, Writer out, int indent) throws IOException
   {
      if (props == null || props.size() == 0)
         return;
      for (ConfigPropType prop : props)
      {
         writeIndent(out, indent);
         out.write("<config-property>");
         writeEol(out);

         writeIndent(out, indent + 1);
         out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
         writeEol(out);
         writeIndent(out, indent + 1);
         out.write("<config-property-type>java.lang." + prop.getType() + "</config-property-type>");
         writeEol(out);
         writeIndent(out, indent + 1);
         out.write("<config-property-value>" + prop.getValue() + "</config-property-value>");
         writeEol(out);

         writeIndent(out, indent);
         out.write("</config-property>");
         writeEol(out);
         writeEol(out);
      }
   }
803063
private void writeTextHandleTransformAs(String transformName, ExtensionMetadata metadata, Object source, String transformType)
    throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException {
    if (source == null) {
      throw new IllegalArgumentException("no source to write");
    }

    Class<?> as = source.getClass();

    TextWriteHandle sourceHandle = null;
    if (TextWriteHandle.class.isAssignableFrom(as)) {
      sourceHandle = (TextWriteHandle) source;
    } else {
      ContentHandle<?> handle = getHandleRegistry().makeHandle(as);
      if (!TextWriteHandle.class.isAssignableFrom(handle.getClass())) {
        throw new IllegalArgumentException(
          "Handle "+handle.getClass().getName()+
            " cannot be used to write transform source as "+as.getName()
        );
      }
      Utilities.setHandleContent(handle, source);
      sourceHandle = (TextWriteHandle) handle;
    }

    if (transformType.equals("javascript")) {
      writeJavascriptTransform(transformName, sourceHandle, metadata);
    }
    else if (transformType.equals("xquery")) {
      writeXQueryTransform(transformName, sourceHandle, metadata);
    }
  }
693093
protected MessageContext getEncoderMessageContext(final RequestAbstractType request, final T samlObject, final String relayState) {
        val ctx = new MessageContext<SAMLObject>();
        ctx.setMessage(samlObject);
        SAMLBindingSupport.setRelayState(ctx, relayState);
        SamlIdPUtils.preparePeerEntitySamlEndpointContext(request, ctx, adaptor, getBinding());
        val self = ctx.getSubcontext(SAMLSelfEntityContext.class, true);
        self.setEntityId(SamlIdPUtils.getIssuerFromSamlObject(samlObject));
        return ctx;
    }
248170
String deflateAndBase64Encode(SAMLObject message) throws MessageEncodingException {
        log.debug("Deflating and Base64 encoding SAML message");
        try {
            String messageStr = SerializeSupport.nodeToString(marshallMessage(message));
            log.trace("Output XML message: {}", messageStr);

            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            Deflater deflater = new Deflater(Deflater.DEFLATED, true);
            DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
            deflaterStream.write(messageStr.getBytes(StandardCharsets.UTF_8));
            deflaterStream.finish();

            return Base64Support.encode(bytesOut.toByteArray(), Base64Support.UNCHUNKED);
        } catch (IOException e) {
            throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
        }
    }
1080446
private void toStringDataDescription(final StringBuilder sb) {
        if (getRedefines() != null) {
            sb.append(',');
            sb.append("redefines:" + getRedefines());
        }
        if (isBlankWhenZero()) {
            sb.append(',');
            sb.append("isBlankWhenZero:" + isBlankWhenZero());
        }
        if (isExternal()) {
            sb.append(',');
            sb.append("isExternal:" + isExternal());
        }
        if (isGlobal()) {
            sb.append(',');
            sb.append("isGlobal:" + isGlobal());
        }
        if (isGroupUsageNational()) {
            sb.append(',');
            sb.append("groupUsageNational:" + isGroupUsageNational());
        }
        if (getMaxOccurs() > 0) {
            if (getMinOccurs() > -1) {
                sb.append(',');
                sb.append("minOccurs:" + getMinOccurs());
            }
            sb.append(',');
            sb.append("maxOccurs:" + getMaxOccurs());
            if (getDependingOn() != null) {
                sb.append(',');
                sb.append("dependingOn:" + getDependingOn());
            }
            if (getIndexes().size() > 0) {
                toStringList(sb, getIndexes(), "indexes");
            }
            if (getAscendingKeys().size() > 0) {
                toStringList(sb, getAscendingKeys(), "ascendingKeys");
            }
            if (getDescendingKeys().size() > 0) {
                toStringList(sb, getDescendingKeys(), "descendingKeys");
            }
        }
        if (isSign()) {
            sb.append(',');
            sb.append("isSign:" + isSign());
            sb.append(',');
            sb.append("isSignLeading:" + isSignLeading());
            sb.append(',');
            sb.append("isSignSeparate:" + isSignSeparate());
        }
        if (isSynchronized()) {
            sb.append(',');
            sb.append("isSynchronized:" + isSynchronized());
        }
        if (getUsage() != null) {
            sb.append(',');
            sb.append("usage:" + getUsage());
        }
        if (getChildren().size() == 0) {
            if (isJustifiedRight()) {
                sb.append(',');
                sb.append("isJustifiedRight:" + isJustifiedRight());
            }
            if (getPicture() != null) {
                sb.append(',');
                sb.append("picture:" + '\"' + getPicture() + '\"');
            }
        }
        if (getValue() != null && getValue().length() > 0) {
            sb.append(',');
            sb.append("value:" + getValue());
        }
        if (getDateFormat() != null) {
            sb.append(',');
            sb.append("dateFormat:" + getDateFormat());
        }
        if (getChildren().size() > 0) {
            toStringList(sb, getChildren(), "children");
        }
    }
1289371
@SneakyThrows
    public EncryptedAssertion encode(final Assertion samlObject,
                                     final SamlRegisteredService service,
                                     final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) {
        val encrypter = buildEncrypterForSamlObject(samlObject, service, adaptor);
        return encrypter.encrypt(samlObject);
    }
318447
protected void finalizeEncode(final RequestAbstractType authnRequest,
                                  final BaseSAML2MessageEncoder encoder,
                                  final T samlResponse,
                                  final String relayState) throws Exception {
        encoder.initialize();
        encoder.encode();
    }
195911
public static String escape(String string, Document.OutputSettings out) {
        if (string == null)
            return "";
        StringBuilder accum = StringUtil.borrowBuilder();
        try {
            escape(accum, string, out, false, false, false);
        } catch (IOException e) {
            throw new SerializationException(e); // doesn't happen
        }
        return StringUtil.releaseBuilder(accum);
    }
909784
public static void writeString(ByteBuffer buffer, String s) throws IOException {
    if(s == null) {
      s = ""; // Which will be written as Varint 0 = single byte 0.
    }
    ByteArrayUtil.STRING_SERIALIZER.toByteBuffer(buffer, s);
  }
943525
@Override
	public void writeBundleTo(String bundlePath, Writer writer) throws ResourceNotFoundException {

		Reader rd = null;

		try {

			// If debug mode is on, resources are retrieved one by one.
			if (config.isDebugModeOn()) {

				rd = resourceHandler.getResource(null, bundlePath);
			} else {

				for (String prefix : bundlePrefixes) {
					if (bundlePath.startsWith(prefix)) {
						bundlePath = bundlePath.substring(prefix.length());
						break;
					}
				}

				// Prefixes are used only in production mode
				String path = PathNormalizer.removeVariantPrefixFromPath(bundlePath);
				rd = resourceBundleHandler.getResourceBundleReader(path);
				if (liveProcessBundles.contains(path)) {
					rd = processInLive(rd);
				}
			}

			IOUtils.copy(rd, writer);
			writer.flush();
		} catch (IOException e) {
			throw new BundlingProcessException("Unexpected IOException writing bundle[" + bundlePath + "]", e);
		} finally {
			IOUtils.close(rd);
			IOUtils.close(writer);
		}
	}