/** * Given a binding uri, get the IDP identity url * * @param idp * @param bindingURI * * @return */ public static String getIdentityURL(IDPSSODescriptorType idp, String bindingURI) { String identityURL = null; List<EndpointType> endpoints = idp.getSingleSignOnService(); for (EndpointType endpoint : endpoints) { if (endpoint.getBinding().toString().equals(bindingURI)) { identityURL = endpoint.getLocation().toString(); break; } } return identityURL; }
public SamlService(SamlProfile profile, List<EndpointType> endpoints) { this.profile = profile; for (EndpointType endpoint : endpoints) { Binding binding = null; if (endpoint.getBinding().endsWith("HTTP-Redirect")) { binding = Binding.HTTP_Redirect; } else if (endpoint.getBinding().endsWith("HTTP-POST")) { binding = Binding.HTTP_Post; } else { // ignore other bindings } if (binding != null) { SamlEndpoint samlEndpoint = new SamlEndpoint(this, binding, endpoint.getLocation(), endpoint .getResponseLocation()); serviceEndpoints.add(samlEndpoint); } } }
/** * Create an Endpoint (SingleSignOnEndpoint or SingleLogoutEndpoint) * * @param binding * @param location * @param responseLocation * @return */ public static EndpointType createEndpoint(String binding, String location, String responseLocation) { EndpointType endpoint = new EndpointType(URI.create(binding), URI.create(location)); endpoint.setResponseLocation(URI.create(responseLocation)); return endpoint; }
/** * Information from an endpoint * @param ept * @return */ public static String toString(EndpointType ept) { StringBuilder builder = new StringBuilder(); builder.append("[Location=").append(ept.getLocation()); builder.append(",ResponseLocation=").append(ept.getResponseLocation()); builder.append("]"); builder.append(LINE_SEPARATOR); return builder.toString(); } }
/** * Given a binding uri, get the IDP logout response url (used for global logouts) */ public static String getLogoutResponseLocation(IDPSSODescriptorType idp, String bindingURI) { String logoutResponseLocation = null; List<EndpointType> endpoints = idp.getSingleLogoutService(); for (EndpointType endpoint : endpoints) { if (endpoint.getBinding().toString().equals(bindingURI)) { if (endpoint.getResponseLocation() != null) { logoutResponseLocation = endpoint.getResponseLocation().toString(); } else { logoutResponseLocation = null; } break; } } return logoutResponseLocation; }
private String getParticipantURL(String destination, SAML2HandlerRequest request) { SPSSODescriptorType spMetadata = (SPSSODescriptorType) request.getOptions().get( GeneralConstants.SP_SSO_METADATA_DESCRIPTOR); // Metadata not found. We will use destination for registration to IdentityServer if (spMetadata == null) { return destination; } List<EndpointType> logoutEndpoints = spMetadata.getSingleLogoutService(); // If endpoint not found, we assume that SP doesn't support logout profile if (logoutEndpoints == null || logoutEndpoints.size() == 0) { return null; } // Use first endpoint for now (Maybe later we can find logoutType according to bindingType from SAMLRequest) EndpointType logoutEndpoint = logoutEndpoints.get(0); return logoutEndpoint.getLocation().toASCIIString(); }
private EndpointType getEndpointType(StartElement startElement) { Attribute bindingAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.BINDING.get())); String binding = StaxParserUtil.getAttributeValue(bindingAttr); Attribute locationAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.LOCATION.get())); String location = StaxParserUtil.getAttributeValue(locationAttr); EndpointType endpoint = new IndexedEndpointType(URI.create(binding), URI.create(location)); Attribute responseLocation = startElement.getAttributeByName(new QName(JBossSAMLConstants.RESPONSE_LOCATION.get())); if (responseLocation != null) { endpoint.setResponseLocation(URI.create(StaxParserUtil.getAttributeValue(responseLocation))); } return endpoint; }
/** * Information from an endpoint * * @param ept * @return */ public static String toString(EndpointType ept) { StringBuilder builder = new StringBuilder(); builder.append("[Location=").append(ept.getLocation()); builder.append(",ResponseLocation=").append(ept.getResponseLocation()); builder.append("]"); builder.append(LINE_SEPARATOR); return builder.toString(); } }
/** * Given a binding uri, get the IDP logout response url (used for global logouts) * */ public static String getLogoutResponseLocation(IDPSSODescriptorType idp, String bindingURI) { String logoutResponseLocation = null; List<EndpointType> endpoints = idp.getSingleLogoutService(); for (EndpointType endpoint : endpoints) { if (endpoint.getBinding().toString().equals(bindingURI)) { if(endpoint.getResponseLocation() != null) { logoutResponseLocation = endpoint.getResponseLocation().toString(); } else { logoutResponseLocation = null; } break; } } return logoutResponseLocation; }
private String getParticipantURL(String destination, SAML2HandlerRequest request) { SPSSODescriptorType spMetadata = (SPSSODescriptorType) request.getOptions().get( GeneralConstants.SP_SSO_METADATA_DESCRIPTOR); // Metadata not found. We will use destination for registration to IdentityServer if (spMetadata == null) { return destination; } List<EndpointType> logoutEndpoints = spMetadata.getSingleLogoutService(); // If endpoint not found, we assume that SP doesn't support logout profile if (logoutEndpoints == null || logoutEndpoints.size() == 0) { return null; } // Use first endpoint for now (Maybe later we can find logoutType according to bindingType from SAMLRequest) EndpointType logoutEndpoint = logoutEndpoints.get(0); return logoutEndpoint.getLocation().toASCIIString(); }
private EndpointType getEndpointType(StartElement startElement) { Attribute bindingAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.BINDING.get())); String binding = StaxParserUtil.getAttributeValue(bindingAttr); Attribute locationAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.LOCATION.get())); String location = StaxParserUtil.getAttributeValue(locationAttr); EndpointType endpoint = new IndexedEndpointType(URI.create(binding), URI.create(location)); Attribute responseLocation = startElement.getAttributeByName(new QName(JBossSAMLConstants.RESPONSE_LOCATION.get())); if (responseLocation != null) { endpoint.setResponseLocation(URI.create(StaxParserUtil.getAttributeValue(responseLocation))); } return endpoint; }
/** * Given a binding uri, get the IDP identity url * * @param idp * @param bindingURI * * @return */ public static String getLogoutURL(IDPSSODescriptorType idp, String bindingURI) { String logoutURL = null; List<EndpointType> endpoints = idp.getSingleLogoutService(); for (EndpointType endpoint : endpoints) { if (endpoint.getBinding().toString().equals(bindingURI)) { logoutURL = endpoint.getLocation().toString(); break; } } return logoutURL; }
private void writeEndpointType(EndpointType endpoint) throws ProcessingException { StaxUtil.writeAttribute(writer, JBossSAMLConstants.BINDING.get(), endpoint.getBinding().toString()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.LOCATION.get(), endpoint.getLocation().toString()); URI responseLocation = endpoint.getResponseLocation(); if (responseLocation != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.RESPONSE_LOCATION.get(), responseLocation.toString()); } }
/** * Information from an endpoint * * @param ept * * @return */ public static String toString(EndpointType ept) { StringBuilder builder = new StringBuilder(); builder.append("[Location=").append(ept.getLocation()); builder.append(",ResponseLocation=").append(ept.getResponseLocation()); builder.append("]"); builder.append(LINE_SEPARATOR); return builder.toString(); } }
/** * Given a binding uri, get the IDP logout response url (used for global logouts) */ public static String getLogoutResponseLocation(IDPSSODescriptorType idp, String bindingURI) { String logoutResponseLocation = null; List<EndpointType> endpoints = idp.getSingleLogoutService(); for (EndpointType endpoint : endpoints) { if (endpoint.getBinding().toString().equals(bindingURI)) { if (endpoint.getResponseLocation() != null) { logoutResponseLocation = endpoint.getResponseLocation().toString(); } else { logoutResponseLocation = null; } break; } } return logoutResponseLocation; }
/** * Create an Endpoint (SingleSignOnEndpoint or SingleLogoutEndpoint) * @param binding * @param location * @param responseLocation * @return */ public static EndpointType createEndpoint(String binding, String location, String responseLocation) { EndpointType endpoint = new EndpointType(URI.create(binding), URI.create(location)); endpoint.setResponseLocation(URI.create(responseLocation)); return endpoint; }
private String getParticipantURL(String destination, SAML2HandlerRequest request) { SPSSODescriptorType spMetadata = (SPSSODescriptorType) request.getOptions().get( GeneralConstants.SP_SSO_METADATA_DESCRIPTOR); // Metadata not found. We will use destination for registration to IdentityServer if (spMetadata == null) { return destination; } List<EndpointType> logoutEndpoints = spMetadata.getSingleLogoutService(); // If endpoint not found, we assume that SP doesn't support logout profile if (logoutEndpoints == null || logoutEndpoints.size() == 0) { return null; } // Use first endpoint for now (Maybe later we can find logoutType according to bindingType from SAMLRequest) EndpointType logoutEndpoint = logoutEndpoints.get(0); return logoutEndpoint.getLocation().toASCIIString(); } }
private EndpointType getEndpointType(StartElement startElement) { Attribute bindingAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.BINDING.get())); String binding = StaxParserUtil.getAttributeValue(bindingAttr); Attribute locationAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.LOCATION.get())); String location = StaxParserUtil.getAttributeValue(locationAttr); EndpointType endpoint = new IndexedEndpointType(URI.create(binding), URI.create(location)); Attribute responseLocation = startElement.getAttributeByName(new QName(JBossSAMLConstants.RESPONSE_LOCATION.get())); if (responseLocation != null) { endpoint.setResponseLocation(URI.create(StaxParserUtil.getAttributeValue(responseLocation))); } return endpoint; }
/** * Given a binding uri, get the IDP identity url * * @param idp * @param bindingURI * @return */ public static String getIdentityURL(IDPSSODescriptorType idp, String bindingURI) { String identityURL = null; List<EndpointType> endpoints = idp.getSingleSignOnService(); for (EndpointType endpoint : endpoints) { if (endpoint.getBinding().toString().equals(bindingURI)) { identityURL = endpoint.getLocation().toString(); break; } } return identityURL; }
private void writeEndpointType(EndpointType endpoint) throws ProcessingException { StaxUtil.writeAttribute(writer, JBossSAMLConstants.BINDING.get(), endpoint.getBinding().toString()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.LOCATION.get(), endpoint.getLocation().toString()); URI responseLocation = endpoint.getResponseLocation(); if (responseLocation != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.RESPONSE_LOCATION.get(), responseLocation.toString()); } }