Generate a Metadata Object from string in OpenSAML3

DD K ddk05361 at gmail.com
Thu Sep 5 05:12:30 EDT 2019


+ @Shib Dev <dev at shibboleth.net>

On Thu, Sep 5, 2019 at 2:40 PM DD K <ddk05361 at gmail.com> wrote:

> Hi Brent,
>
> Yeah, as you said doing it in the way I've did previously was the fix.
> Attaching the code snippet for future references:
>
> private EntityDescriptor generateMetadataObjectFromString(String metadataString) {
>         EntityDescriptor entityDescriptor = null;
>         InputStream inputStream;
>         try {
>             doBootstrap();
>             inputStream = new ByteArrayInputStream(metadataString.trim().getBytes(StandardCharsets.UTF_8));
>             entityDescriptor = (EntityDescriptor) XMLObjectSupport.unmarshallFromInputStream(
>                     XMLObjectProviderRegistrySupport.getParserPool(), inputStream);
>         } catch ( UnmarshallingException | XMLParserException e) {
>             log.error("Error While reading Service Provider metadata xml", e);
>         }
>         return entityDescriptor;
>     }
>
>
> Thanks All for the answers,
> Deshan Koswatte
> On Thu, Aug 15, 2019 at 2:02 AM Brent Putman <putmanb at georgetown.edu>
> wrote:
>
>>
>> On 8/14/19 4:29 AM, DD K wrote:
>>
>> Hi All,
>>
>> What I'm currently trying is to migrate from OpenSAML2.x to OpenSAML3.x.
>> Currently on OpenSAML2.x the code is as below:
>>
>> Well that wasn't correct in the first place.  At least not if you're just
>> trying to turn some XML you already have into an XMLObject tree. If you
>> have the XML for an existing EntityDescriptor or EntitiesDescriptor element
>> and just want to parse that into OpenSAML representation, then you just
>> parse and unmarshall.  Exactly like what you were doing in the earlier
>> thread you posted for (I think) AuthnRequest.  Given that you were using
>> the DOMMetadataProvider, you were doing sort of doing that, but in a very
>> roundabout and unnecessary fashion.
>>
>>
>>
>> But I've struggled to find a resource on how to generate a
>> EntityDescriptor to return from the method cause now there is no method
>> such as *generateMetadata()* in *DOMMetadataResolver*, keeping this
>> apart
>>
>>
>> Right, the entire design and API of metadata providers changed in 3.x.
>> In 3.x it's entirely EntityDescirptor-centric (no more EntitiesDescriptors
>> are surfaced) and the API is about searching for and returning 1 or more
>> EntityDescriptors.
>>
>>
>> there is a method called *resolveSingle()* but it needs a *CriteriaSet(which
>> i do not know what to include)*.
>>
>> Right, in the new model you would supply criteria for the
>> EntityDescriptor(s) you want.  In the common SSO use case, you usually want
>> just 1, based usually on entityID criteria.
>>
>> If you want to see how that works, take a look at the relevant unit
>> tests, there's plenty of examples there.
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20190905/fc67fda9/attachment-0001.html>


More information about the dev mailing list