Java Code Examples for javax.xml.stream.XMLStreamWriter#getPrefix()
The following examples show how to use
javax.xml.stream.XMLStreamWriter#getPrefix() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequiredParts.java From steady with Apache License 2.0 | 5 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:RequiredParts> writer.writeStartElement(prefix, localName, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); Header header; for (Iterator<Header> iterator = headers.iterator(); iterator.hasNext();) { header = iterator.next(); // <sp:Header Name=".." Namespace=".." /> writer.writeStartElement(prefix, SPConstants.HEADER, namespaceURI); // Name attribute is optional if (!StringUtils.isEmpty(header.getName())) { writer.writeAttribute("Name", header.getName()); } writer.writeAttribute("Namespace", header.getNamespace()); writer.writeEndElement(); } // </sp:RequiredParts> writer.writeEndElement(); }
Example 2
Source File: InitiatorEncryptionToken.java From steady with Apache License 2.0 | 5 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:InitiatorEncryptionToken> writer.writeStartElement(prefix, localName, namespaceURI); String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); Token token = getInitiatorEncryptionToken(); if (token == null) { throw new RuntimeException("InitiatorEncryptionToken doesn't contain any token assertions"); } token.serialize(writer); // </wsp:Policy> writer.writeEndElement(); // </sp:InitiatorToken> writer.writeEndElement(); }
Example 3
Source File: InitiatorToken.java From steady with Apache License 2.0 | 5 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:InitiatorToken> writer.writeStartElement(prefix, localName, namespaceURI); String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); Token token = getInitiatorToken(); if (token == null) { throw new RuntimeException("InitiatorToken doesn't contain any token assertions"); } token.serialize(writer); // </wsp:Policy> writer.writeEndElement(); // </sp:InitiatorToken> writer.writeEndElement(); }
Example 4
Source File: Layout.java From steady with Apache License 2.0 | 5 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:Layout> writer.writeStartElement(prefix, localName, namespaceURI); String wspPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (wspPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI()); // .. <sp:Strict /> | <sp:Lax /> | <sp:LaxTsFirst /> | <sp:LaxTsLast /> .. writer.writeEmptyElement(prefix, value.name(), namespaceURI); // </wsp:Policy> writer.writeEndElement(); // </sp:Layout> writer.writeEndElement(); }
Example 5
Source File: SignedEncryptedElements.java From steady with Apache License 2.0 | 5 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:SignedElements> | <sp:EncryptedElements> writer.writeStartElement(prefix, localName, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); if (xPathVersion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.XPATH_VERSION, xPathVersion); } String xpathExpression; for (Iterator<String> iterator = xPathExpressions.iterator(); iterator.hasNext();) { xpathExpression = iterator.next(); // <sp:XPath ..> writer.writeStartElement(prefix, SPConstants.XPATH_EXPR, namespaceURI); writer.writeCharacters(xpathExpression); writer.writeEndElement(); } // </sp:SignedElements> | </sp:EncryptedElements> writer.writeEndElement(); }
Example 6
Source File: SecureConversationToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:SecureConversationToken> writer.writeStartElement(prefix, localname, namespaceURI); if (writerPrefix == null) { // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); } String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (issuerEpr != null) { // <sp:Issuer> writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI); StaxUtils.copy(issuerEpr, writer); writer.writeEndElement(); } if (isDerivedKeys() || isRequireExternalUriRef() || isSc10SecurityContextToken() || isSc13SecurityContextToken() || bootstrapPolicy != null) { String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI(); String wspPrefix; String wspWriterPrefix = writer.getPrefix(wspNamespaceURI); if (wspWriterPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, wspNamespaceURI); } else { wspPrefix = wspWriterPrefix; } // <wsp:Policy> writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI); if (wspWriterPrefix == null) { // xmlns:wsp=".." writer.writeNamespace(wspPrefix, wspNamespaceURI); } if (isDerivedKeys()) { // <sp:RequireDerivedKeys /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); } if (isRequireExternalUriRef()) { // <sp:RequireExternalUriReference /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_EXTERNAL_URI_REFERENCE, namespaceURI); } if (isSc10SecurityContextToken()) { // <sp:SC10SecurityContextToken /> writer.writeEmptyElement(prefix, SPConstants.SC10_SECURITY_CONTEXT_TOKEN, namespaceURI); } if (isSc13SecurityContextToken()) { // <sp:SC13SecurityContextToken /> writer.writeEmptyElement(prefix, SPConstants.SC13_SECURITY_CONTEXT_TOKEN, namespaceURI); } if (bootstrapPolicy != null) { // <sp:BootstrapPolicy ..> writer.writeStartElement(prefix, SPConstants.BOOTSTRAP_POLICY, namespaceURI); bootstrapPolicy.serialize(writer); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); } // </sp:SecureConversationToken> writer.writeEndElement(); }
Example 7
Source File: Wss11.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:Wss11> writer.writeStartElement(prefix, localname, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); // <sp:MustSupportRefKeyIndentifier /> if (isMustSupportRefKeyIdentifier()) { writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefIssuerSerial()) { // <sp:MustSupportRefIssuerSerial /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefExternalURI()) { // <sp:MustSupportRefExternalURI /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefEmbeddedToken()) { // <sp:MustSupportRefEmbeddedToken /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefThumbprint()) { // <sp:MustSupportRefThumbprint /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_THUMBPRINT, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefEncryptedKey()) { // <sp:MustSupportRefEncryptedKey /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ENCRYPTED_KEY, namespaceURI); writer.writeEndElement(); } if (isRequireSignatureConfirmation()) { // <sp:RequireSignatureConfirmation /> writer.writeStartElement(prefix, SPConstants.REQUIRE_SIGNATURE_CONFIRMATION, namespaceURI); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); // </sp:Wss11> writer.writeEndElement(); }
Example 8
Source File: SamlToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { QName name = constants.getSamlToken(); String localname = name.getLocalPart(); String namespaceURI = name.getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = name.getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:SamlToken writer.writeStartElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (isUseSamlVersion11Profile10() || isUseSamlVersion11Profile11() || isUseSamlVersion20Profile11()) { String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); // CHECKME if (isUseSamlVersion11Profile10()) { // <sp:WssSamlV11Token10 /> writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_10, namespaceURI); } else if (isUseSamlVersion11Profile11()) { // <sp:WssSamlV11Token11 /> writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_11, namespaceURI); } else { // <sp:WssSamlV20Token11 /> writer.writeStartElement(prefix, SPConstants.SAML_20_TOKEN_11, namespaceURI); } if (isDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } else if (isExplicitDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_EXPLICIT_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } else if (isImpliedDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_IMPLIED_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } if (isRequireKeyIdentifierReference()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE, namespaceURI); writer.writeEndElement(); } writer.writeEndElement(); // </wsp:Policy> writer.writeEndElement(); } writer.writeEndElement(); // </sp:SamlToken> }
Example 9
Source File: SymmetricBinding.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:SymmetricBinding> writer.writeStartElement(prefix, localname, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); String policyLocalName = SPConstants.POLICY.getLocalPart(); String policyNamespaceURI = SPConstants.POLICY.getNamespaceURI(); String wspPrefix; String wspWriterPrefix = writer.getPrefix(policyNamespaceURI); if (wspWriterPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, policyNamespaceURI); } else { wspPrefix = wspWriterPrefix; } // <wsp:Policy> writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI); if (encryptionToken != null) { encryptionToken.serialize(writer); } else if (protectionToken != null) { protectionToken.serialize(writer); } else { throw new RuntimeException("Either EncryptionToken or ProtectionToken must be set"); } AlgorithmSuite algorithmSuite = getAlgorithmSuite(); if (algorithmSuite == null) { throw new RuntimeException("AlgorithmSuite must be set"); } // <sp:AlgorithmSuite /> algorithmSuite.serialize(writer); Layout layout = getLayout(); if (layout != null) { // <sp:Layout /> layout.serialize(writer); } if (isIncludeTimestamp()) { // <sp:IncludeTimestamp /> writer.writeStartElement(prefix, SPConstants.INCLUDE_TIMESTAMP, namespaceURI); writer.writeEndElement(); } if (SPConstants.ProtectionOrder.EncryptBeforeSigning == getProtectionOrder()) { // <sp:EncryptBeforeSigning /> writer.writeStartElement(prefix, SPConstants.ENCRYPT_BEFORE_SIGNING, namespaceURI); writer.writeEndElement(); } if (isSignatureProtection()) { // <sp:EncryptSignature /> writer.writeStartElement(prefix, SPConstants.ENCRYPT_SIGNATURE, namespaceURI); writer.writeEndElement(); } if (isEntireHeadersAndBodySignatures()) { writer.writeEmptyElement(prefix, SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY, namespaceURI); } // </wsp:Policy> writer.writeEndElement(); // </sp:SymmetricBinding> writer.writeEndElement(); }
Example 10
Source File: ContentEncryptedElements.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:ContentEncryptedElements> writer.writeStartElement(prefix, localName, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); if (writerPrefix == null) { // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); } if (xPathVersion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.XPATH_VERSION, xPathVersion); } String xpathExpression; for (Iterator<String> iterator = xPathExpressions.iterator(); iterator.hasNext();) { xpathExpression = iterator.next(); // <sp:XPath ..> writer.writeStartElement(prefix, SPConstants.XPATH_EXPR, namespaceURI); writer.writeCharacters(xpathExpression); writer.writeEndElement(); } // </sp:ContentEncryptedElements> writer.writeEndElement(); }
Example 11
Source File: SecureConversationToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:SecureConversationToken> writer.writeStartElement(prefix, localname, namespaceURI); if (writerPrefix == null) { // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); } String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (issuerEpr != null) { // <sp:Issuer> writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI); StaxUtils.copy(issuerEpr, writer); writer.writeEndElement(); } if (isDerivedKeys() || isRequireExternalUriRef() || isSc10SecurityContextToken() || isSc13SecurityContextToken() || bootstrapPolicy != null) { String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI(); String wspPrefix; String wspWriterPrefix = writer.getPrefix(wspNamespaceURI); if (wspWriterPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, wspNamespaceURI); } else { wspPrefix = wspWriterPrefix; } // <wsp:Policy> writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI); if (wspWriterPrefix == null) { // xmlns:wsp=".." writer.writeNamespace(wspPrefix, wspNamespaceURI); } if (isDerivedKeys()) { // <sp:RequireDerivedKeys /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); } if (isRequireExternalUriRef()) { // <sp:RequireExternalUriReference /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_EXTERNAL_URI_REFERENCE, namespaceURI); } if (isSc10SecurityContextToken()) { // <sp:SC10SecurityContextToken /> writer.writeEmptyElement(prefix, SPConstants.SC10_SECURITY_CONTEXT_TOKEN, namespaceURI); } if (isSc13SecurityContextToken()) { // <sp:SC13SecurityContextToken /> writer.writeEmptyElement(prefix, SPConstants.SC13_SECURITY_CONTEXT_TOKEN, namespaceURI); } if (bootstrapPolicy != null) { // <sp:BootstrapPolicy ..> writer.writeStartElement(prefix, SPConstants.BOOTSTRAP_POLICY, namespaceURI); bootstrapPolicy.serialize(writer); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); } // </sp:SecureConversationToken> writer.writeEndElement(); }
Example 12
Source File: RequiredElements.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:RequiredElements> writer.writeStartElement(prefix, localName, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); if (writerPrefix == null) { // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); } if (xPathVersion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.XPATH_VERSION, xPathVersion); } String xpathExpression; for (Iterator<String> iterator = xPathExpressions.iterator(); iterator.hasNext();) { xpathExpression = iterator.next(); // <sp:XPath ..> writer.writeStartElement(prefix, SPConstants.XPATH_EXPR, namespaceURI); writer.writeCharacters(xpathExpression); writer.writeEndElement(); } // </sp:RequiredElements> writer.writeEndElement(); }
Example 13
Source File: TransportBinding.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:TransportBinding> writer.writeStartElement(prefix, localName, namespaceURI); writer.writeNamespace(prefix, namespaceURI); String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); if (transportToken == null) { // TODO more meaningful exception throw new RuntimeException("no TransportToken found"); } // <sp:TransportToken> transportToken.serialize(writer); // </sp:TransportToken> AlgorithmSuite algorithmSuite = getAlgorithmSuite(); if (algorithmSuite == null) { throw new RuntimeException("no AlgorithmSuite found"); } // <sp:AlgorithmSuite> algorithmSuite.serialize(writer); // </sp:AlgorithmSuite> Layout layout = getLayout(); if (layout != null) { // <sp:Layout> layout.serialize(writer); // </sp:Layout> } if (isIncludeTimestamp()) { // <sp:IncludeTimestamp> writer.writeStartElement(prefix, SPConstants.INCLUDE_TIMESTAMP, namespaceURI); writer.writeEndElement(); // </sp:IncludeTimestamp> } // </wsp:Policy> writer.writeEndElement(); // </sp:TransportBinding> writer.writeEndElement(); }
Example 14
Source File: SamlToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { QName name = constants.getSamlToken(); String localname = name.getLocalPart(); String namespaceURI = name.getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = name.getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:SamlToken writer.writeStartElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (isUseSamlVersion11Profile10() || isUseSamlVersion11Profile11() || isUseSamlVersion20Profile11()) { String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); // CHECKME if (isUseSamlVersion11Profile10()) { // <sp:WssSamlV11Token10 /> writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_10, namespaceURI); } else if (isUseSamlVersion11Profile11()) { // <sp:WssSamlV11Token11 /> writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_11, namespaceURI); } else { // <sp:WssSamlV20Token11 /> writer.writeStartElement(prefix, SPConstants.SAML_20_TOKEN_11, namespaceURI); } if (isDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } else if (isExplicitDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_EXPLICIT_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } else if (isImpliedDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_IMPLIED_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } if (isRequireKeyIdentifierReference()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE, namespaceURI); writer.writeEndElement(); } writer.writeEndElement(); // </wsp:Policy> writer.writeEndElement(); } writer.writeEndElement(); // </sp:SamlToken> }
Example 15
Source File: HttpsToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:HttpsToken writer.writeStartElement(prefix, localname, namespaceURI); if (constants.getVersion() == SPConstants.Version.SP_V12) { if (isRequireClientCertificate() || isHttpBasicAuthentication() || isHttpDigestAuthentication()) { // <wsp:Policy> writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI()); /* * The ws policy 1.2 specification states that only one of those should be present, although a * web server (say tomcat) could be normally configured to require both a client certificate * and a http user/pwd authentication. Nevertheless stick to the specification. */ if (isHttpBasicAuthentication()) { writer.writeStartElement(prefix, SPConstants.HTTP_BASIC_AUTHENTICATION.getLocalPart(), namespaceURI); writer.writeEndElement(); } else if (isHttpDigestAuthentication()) { writer.writeStartElement(prefix, SPConstants.HTTP_DIGEST_AUTHENTICATION.getLocalPart(), namespaceURI); writer.writeEndElement(); } else if (isRequireClientCertificate()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_CLIENT_CERTIFICATE.getLocalPart(), namespaceURI); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); } } else { // RequireClientCertificate=".." writer.writeAttribute(SPConstants.REQUIRE_CLIENT_CERTIFICATE.getLocalPart(), Boolean .toString(isRequireClientCertificate())); } writer.writeEndElement(); // </sp:HttpsToken> }
Example 16
Source File: KeyValueToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { QName name = constants.getUserNameToken(); String localname = name.getLocalPart(); String namespaceURI = name.getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = name.getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:KeyValueToken writer.writeStartElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (forceRsaKeyValue) { String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); writer.writeEmptyElement(prefix, "RsaKeyValue", namespaceURI); // </wsp:Policy> writer.writeEndElement(); } writer.writeEndElement(); // </sp:KeyValueToken> }
Example 17
Source File: X509Token.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:X509Token> writer.writeStartElement(prefix, localName, namespaceURI); String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); if (isRequireKeyIdentifierReference()) { // <sp:RequireKeyIdentifierReference /> writer.writeStartElement(prefix, SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE, namespaceURI); writer.writeEndElement(); } if (isRequireIssuerSerialReference()) { // <sp:RequireIssuerSerialReference /> writer.writeStartElement(prefix, SPConstants.REQUIRE_ISSUER_SERIAL_REFERENCE, namespaceURI); writer.writeEndElement(); } if (isRequireEmbeddedTokenReference()) { // <sp:RequireEmbeddedTokenReference /> writer.writeStartElement(prefix, SPConstants.REQUIRE_EMBEDDED_TOKEN_REFERENCE, namespaceURI); writer.writeEndElement(); } if (isRequireThumbprintReference()) { // <sp:RequireThumbprintReference /> writer.writeStartElement(prefix, SPConstants.REQUIRE_THUMBPRINT_REFERENCE, namespaceURI); writer.writeEndElement(); } if (tokenVersionAndType != null) { // <sp:WssX509V1Token10 /> | .. writer.writeStartElement(prefix, tokenVersionAndType, namespaceURI); writer.writeEndElement(); } if (isDerivedKeys()) { // <sp:RequireDerivedKeys/> writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); // </sp:X509Token> writer.writeEndElement(); }
Example 18
Source File: Trust10.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:Trust10> writer.writeStartElement(prefix, localname, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); String wspPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (wspPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI()); if (isMustSupportClientChallenge()) { // <sp:MustSupportClientChallenge /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_CLIENT_CHALLENGE, namespaceURI); writer.writeEndElement(); } if (isMustSupportServerChallenge()) { // <sp:MustSupportServerChallenge /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_SERVER_CHALLENGE, namespaceURI); writer.writeEndElement(); } if (isRequireClientEntropy()) { // <sp:RequireClientEntropy /> writer.writeStartElement(prefix, SPConstants.REQUIRE_CLIENT_ENTROPY, namespaceURI); writer.writeEndElement(); } if (isRequireServerEntropy()) { // <sp:RequireServerEntropy /> writer.writeStartElement(prefix, SPConstants.REQUIRE_SERVER_ENTROPY, namespaceURI); writer.writeEndElement(); } if (isMustSupportIssuedTokens()) { // <sp:MustSupportIssuedTokens /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_ISSUED_TOKENS, namespaceURI); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); // </sp:Trust10> writer.writeEndElement(); }
Example 19
Source File: Wss10.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:Wss10> writer.writeStartElement(prefix, localname, namespaceURI); // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); if (isMustSupportRefKeyIdentifier()) { // <sp:MustSupportRefKeyIdentifier /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefIssuerSerial()) { // <sp:MustSupportRefIssuerSerial /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefExternalURI()) { // <sp:MustSupportRefExternalURI /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI, namespaceURI); writer.writeEndElement(); } if (isMustSupportRefEmbeddedToken()) { // <sp:MustSupportRefEmbeddedToken /> writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN, namespaceURI); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); // </sp:Wss10> writer.writeEndElement(); }
Example 20
Source File: SecureConversationToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localname = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:SecureConversationToken> writer.writeStartElement(prefix, localname, namespaceURI); if (writerPrefix == null) { // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); } String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (issuerEpr != null) { // <sp:Issuer> writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI); StaxUtils.copy(issuerEpr, writer); writer.writeEndElement(); } if (isDerivedKeys() || isRequireExternalUriRef() || isSc10SecurityContextToken() || isSc13SecurityContextToken() || bootstrapPolicy != null) { String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI(); String wspPrefix; String wspWriterPrefix = writer.getPrefix(wspNamespaceURI); if (wspWriterPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, wspNamespaceURI); } else { wspPrefix = wspWriterPrefix; } // <wsp:Policy> writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI); if (wspWriterPrefix == null) { // xmlns:wsp=".." writer.writeNamespace(wspPrefix, wspNamespaceURI); } if (isDerivedKeys()) { // <sp:RequireDerivedKeys /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); } if (isRequireExternalUriRef()) { // <sp:RequireExternalUriReference /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_EXTERNAL_URI_REFERENCE, namespaceURI); } if (isSc10SecurityContextToken()) { // <sp:SC10SecurityContextToken /> writer.writeEmptyElement(prefix, SPConstants.SC10_SECURITY_CONTEXT_TOKEN, namespaceURI); } if (isSc13SecurityContextToken()) { // <sp:SC13SecurityContextToken /> writer.writeEmptyElement(prefix, SPConstants.SC13_SECURITY_CONTEXT_TOKEN, namespaceURI); } if (bootstrapPolicy != null) { // <sp:BootstrapPolicy ..> writer.writeStartElement(prefix, SPConstants.BOOTSTRAP_POLICY, namespaceURI); bootstrapPolicy.serialize(writer); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); } // </sp:SecureConversationToken> writer.writeEndElement(); }