public class SAMLUtil extends Object
Constructor and Description |
---|
SAMLUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
compare(byte[] hashID,
String entityId)
Helper method compares whether SHA-1 hash of the entityId equals the hashID.
|
static org.opensaml.saml2.metadata.ArtifactResolutionService |
getArtifactResolutionService(org.opensaml.saml2.metadata.IDPSSODescriptor idpssoDescriptor,
int endpointIndex) |
static List<String> |
getBase64EncodeCertificates(org.opensaml.xml.signature.KeyInfo keyInfo)
Parses list of all Base64 encoded certificates found inside the KeyInfo element.
|
static List<String> |
getBase64EncodedCertificates(org.opensaml.xml.signature.X509Data x509Data)
Parses list of Base64 encoded certificates present in the X509Data element.
|
static String |
getBindingForEndpoint(org.opensaml.saml2.metadata.Endpoint endpoint)
Method determines binding supported by the given endpoint.
|
static org.opensaml.saml2.metadata.AssertionConsumerService |
getConsumerService(org.opensaml.saml2.metadata.SPSSODescriptor ssoDescriptor,
Integer index)
Loads the assertionConsumerIndex designated by the index.
|
static <T extends org.opensaml.saml2.metadata.Endpoint> |
getEndpoint(List<T> endpoints,
String messageBinding,
org.opensaml.ws.transport.InTransport inTransport)
Method helps to identify which endpoint is used to process the current message.
|
static <T extends org.opensaml.saml2.metadata.Endpoint> |
getEndpoint(List<T> endpoints,
String messageBinding,
org.opensaml.ws.transport.InTransport inTransport,
org.opensaml.common.binding.decoding.URIComparator uriComparator)
Method helps to identify which endpoint is used to process the current message.
|
static HostnameVerifier |
getHostnameVerifier(String hostnameVerificationType)
Populates hostname verifier of the given type.
|
static org.opensaml.saml2.metadata.IDPSSODescriptor |
getIDPDescriptor(MetadataManager metadata,
String idpId)
Loads IDP descriptor for entity with the given entityID.
|
static org.opensaml.saml2.metadata.IDPSSODescriptor |
getIDPSSODescriptor(org.opensaml.saml2.metadata.EntityDescriptor idpEntityDescriptor) |
static String |
getLogoutBinding(org.opensaml.saml2.metadata.IDPSSODescriptor idp,
org.opensaml.saml2.metadata.SPSSODescriptor sp) |
static org.opensaml.saml2.metadata.SingleLogoutService |
getLogoutServiceForBinding(org.opensaml.saml2.metadata.SSODescriptor descriptor,
String binding)
Returns Single logout service for given binding of the IDP.
|
static String |
getMetadataAsString(MetadataManager metadataManager,
KeyManager keyManager,
org.opensaml.saml2.metadata.EntityDescriptor descriptor,
ExtendedMetadata extendedMetadata)
Method digitally signs the EntityDescriptor element (when configured with property sign metadata) and
serializes the result into a string.
|
static String |
getNCNameString(String value)
Method replaces all characters which are not allowed in xsd:NCName type with underscores.
|
static boolean |
isDateTimeSkewValid(int skewInSec,
org.joda.time.DateTime time)
Verifies that the current time is within skewInSec interval from the time value.
|
static boolean |
isDateTimeSkewValid(int skewInSec,
long forwardInterval,
org.joda.time.DateTime time)
Verifies that the current time fits into interval defined by time minus backwardInterval minus skew and time plus forward interval plus skew.
|
static boolean |
isECPRequest(HttpServletRequest request)
Analyzes the request headers in order to determine if it comes from an ECP-enabled
client and based on this decides whether ECP profile will be used.
|
static Element |
marshallAndSignMessage(org.opensaml.xml.signature.SignableXMLObject signableMessage,
org.opensaml.xml.security.credential.Credential signingCredential,
String signingAlgorithm,
String digestMethodAlgorithm,
String keyInfoGenerator)
Method digitally signs and marshals the object in case it is signable and the signing credential is provided.
|
static Element |
marshallMessage(org.opensaml.xml.XMLObject message)
Helper method that marshals the given message.
|
static boolean |
processFilter(String filterName,
HttpServletRequest request)
Determines whether filter with the given name should be invoked for the current request.
|
static void |
verifyAlias(String alias,
String entityId)
Verifies that the alias is valid.
|
public static String getBindingForEndpoint(org.opensaml.saml2.metadata.Endpoint endpoint)
endpoint
- endpointpublic static org.opensaml.saml2.metadata.SingleLogoutService getLogoutServiceForBinding(org.opensaml.saml2.metadata.SSODescriptor descriptor, String binding) throws org.opensaml.saml2.metadata.provider.MetadataProviderException
descriptor
- IDP to search for service inbinding
- binding supported by the serviceorg.opensaml.saml2.metadata.provider.MetadataProviderException
- if the service can't be determinedpublic static String getLogoutBinding(org.opensaml.saml2.metadata.IDPSSODescriptor idp, org.opensaml.saml2.metadata.SPSSODescriptor sp) throws org.opensaml.saml2.metadata.provider.MetadataProviderException
org.opensaml.saml2.metadata.provider.MetadataProviderException
public static org.opensaml.saml2.metadata.IDPSSODescriptor getIDPSSODescriptor(org.opensaml.saml2.metadata.EntityDescriptor idpEntityDescriptor) throws org.opensaml.ws.message.decoder.MessageDecodingException
org.opensaml.ws.message.decoder.MessageDecodingException
public static org.opensaml.saml2.metadata.AssertionConsumerService getConsumerService(org.opensaml.saml2.metadata.SPSSODescriptor ssoDescriptor, Integer index)
ssoDescriptor
- descriptorindex
- to load, can be nullorg.opensaml.common.SAMLRuntimeException
- in case assertionConsumerService with given index isn't foundpublic static org.opensaml.saml2.metadata.ArtifactResolutionService getArtifactResolutionService(org.opensaml.saml2.metadata.IDPSSODescriptor idpssoDescriptor, int endpointIndex) throws org.opensaml.ws.message.decoder.MessageDecodingException
org.opensaml.ws.message.decoder.MessageDecodingException
public static boolean processFilter(String filterName, HttpServletRequest request)
filterName
- name of the filter to search URI forrequest
- requestpublic static boolean compare(byte[] hashID, String entityId) throws org.opensaml.saml2.metadata.provider.MetadataProviderException
hashID
- hash id to compareentityId
- entity id to hash and verifyorg.opensaml.saml2.metadata.provider.MetadataProviderException
- in case SHA-1 hash can't be initializedpublic static void verifyAlias(String alias, String entityId) throws org.opensaml.saml2.metadata.provider.MetadataProviderException
alias
- alias to verifyentityId
- id of the entityorg.opensaml.saml2.metadata.provider.MetadataProviderException
- in case any validation problem is foundpublic static List<String> getBase64EncodeCertificates(org.opensaml.xml.signature.KeyInfo keyInfo)
keyInfo
- key info to parsepublic static List<String> getBase64EncodedCertificates(org.opensaml.xml.signature.X509Data x509Data)
x509Data
- data to parsepublic static boolean isECPRequest(HttpServletRequest request)
request
- request to analyzepublic static <T extends org.opensaml.saml2.metadata.Endpoint> T getEndpoint(List<T> endpoints, String messageBinding, org.opensaml.ws.transport.InTransport inTransport) throws org.opensaml.common.SAMLException
T
- type of the endpointendpoints
- endpoints to checkmessageBinding
- bindinginTransport
- transport which received the current messageorg.opensaml.common.SAMLException
- in case endpoint can't be foundpublic static <T extends org.opensaml.saml2.metadata.Endpoint> T getEndpoint(List<T> endpoints, String messageBinding, org.opensaml.ws.transport.InTransport inTransport, org.opensaml.common.binding.decoding.URIComparator uriComparator) throws org.opensaml.common.SAMLException
T
- type of the endpointendpoints
- endpoints to checkmessageBinding
- bindinginTransport
- transport which received the current messageuriComparator
- URI comparatororg.opensaml.common.SAMLException
- in case endpoint can't be foundpublic static org.opensaml.saml2.metadata.IDPSSODescriptor getIDPDescriptor(MetadataManager metadata, String idpId) throws org.opensaml.saml2.metadata.provider.MetadataProviderException
metadata
- metadata manageridpId
- entity IDorg.opensaml.saml2.metadata.provider.MetadataProviderException
- in case descriptor can't be foundpublic static Element marshallMessage(org.opensaml.xml.XMLObject message) throws org.opensaml.ws.message.encoder.MessageEncodingException
message
- message the marshall and serializeorg.opensaml.ws.message.encoder.MessageEncodingException
- thrown if the give message can not be marshaled into its DOM representationpublic static Element marshallAndSignMessage(org.opensaml.xml.signature.SignableXMLObject signableMessage, org.opensaml.xml.security.credential.Credential signingCredential, String signingAlgorithm, String digestMethodAlgorithm, String keyInfoGenerator) throws org.opensaml.ws.message.encoder.MessageEncodingException
signableMessage
- object to signsigningCredential
- credential to sign withsigningAlgorithm
- signing algorithm to use (optional). Leave null to use credential's default algorithmsigningAlgorithm
- digest method algorithm to use (optional). Leave null to use credential's default algorithmkeyInfoGenerator
- name of generator used to create KeyInfo elements with key dataorg.opensaml.ws.message.encoder.MessageEncodingException
- thrown if there is a problem marshalling or signing the messagepublic static boolean isDateTimeSkewValid(int skewInSec, org.joda.time.DateTime time)
skewInSec
- skew interval in secondstime
- time the current time must fit into with the given skewpublic static boolean isDateTimeSkewValid(int skewInSec, long forwardInterval, org.joda.time.DateTime time)
skewInSec
- skew interval in secondsforwardInterval
- forward interval in sectime
- time the current time must fit into with the given skewpublic static String getNCNameString(String value)
value
- value to cleanpublic static HostnameVerifier getHostnameVerifier(String hostnameVerificationType)
hostnameVerificationType
- typepublic static String getMetadataAsString(MetadataManager metadataManager, KeyManager keyManager, org.opensaml.saml2.metadata.EntityDescriptor descriptor, ExtendedMetadata extendedMetadata) throws org.opensaml.xml.io.MarshallingException
metadataManager
- metadata managerkeyManager
- key managerdescriptor
- descriptor to sign and serializeextendedMetadata
- information about metadata signing, looked up when nullorg.opensaml.xml.io.MarshallingException
- in case serialization fails