writer.writeStartElement("fed", "TargetScope", WS_FEDERATION_NS);
writer.writeStartElement("wsa", "EndpointReference", WS_ADDRESSING_NS);
writer.writeStartElement("wsa", "Address", WS_ADDRESSING_NS);
if (protocol instanceof FederationProtocol) {
FederationProtocol fedprotocol = (FederationProtocol)protocol;
String realm = fedprotocol.getRealm();
if (!(realm == null || "".equals(realm))) {
writer.writeCharacters(realm);
}
}
// writer.writeCharacters("http://host:port/url from config");
writer.writeEndElement(); // Address
writer.writeEndElement(); // EndpointReference
writer.writeEndElement(); // TargetScope
// TODO loop over Context config and populate claims from there instead the dummy code below
if (protocol instanceof FederationProtocol) {
FederationProtocol fedprotocol = (FederationProtocol)protocol;
List<Claim> claims = fedprotocol.getClaimTypesRequested();
if (claims != null && claims.size() > 0) {
// create ClaimsType section
writer.writeStartElement("fed", "ClaimTypesRequested", WS_FEDERATION_NS);
for (Claim claim : claims) {
writer.writeStartElement("auth", "ClaimType", WS_FEDERATION_NS);
writer.writeAttribute("Uri", claim.getType());
if (claim.isOptional()) {
writer.writeAttribute("Optional", "true");
} else {
writer.writeAttribute("Optional", "false");
}
writer.writeEndElement(); // ClaimType
}
writer.writeEndElement(); // ClaimsTypeRequested
}
}
// create sign in endpoint section
writer.writeStartElement("fed", "PassiveRequestorEndpoint", WS_FEDERATION_NS);
writer.writeStartElement("wsa", "EndpointReference", WS_ADDRESSING_NS);
writer.writeStartElement("wsa", "Address", WS_ADDRESSING_NS);
if (protocol instanceof FederationProtocol) {
FederationProtocol fedprotocol = (FederationProtocol)protocol;
Object issuer = fedprotocol.getIssuer();
if (issuer instanceof String && !"".equals(issuer)) {
writer.writeCharacters((String)issuer);
}
}