how to migrate from opensaml 2.6 to 3.1.1

后端 未结 2 1400
灰色年华
灰色年华 2021-02-04 05:39

I have to migrate a class from opensaml 2.6 to opensaml 3.1.1 Compiling I obtain some errors

1)

Element plaintextElement = getElementAssertion(inputBean)         


        
2条回答
  •  清歌不尽
    2021-02-04 05:57

    I am learning how to use the OS3 for development. This is one example to convert base 64 saml request to SAMLObject in V3 version. Hope it can help you.

    The project see the github repository

    public class SAMLToolkit {
    
        public static SAMLObject convertBase64ToSaml(String base64Str) {
            byte[] decodedBytes = new byte[0];
            try {
                decodedBytes = Base64.decode(base64Str);
            } catch (Base64DecodingException e) {
                e.printStackTrace();
                return null;
            }
    
            InputStream is = new ByteArrayInputStream(decodedBytes);
            //is = new InflaterInputStream(is, new Inflater(true));
            try {
    
                InitializationService.initialize();
                Document messageDoc;
                BasicParserPool basicParserPool = new BasicParserPool();
                basicParserPool.initialize();
                messageDoc = basicParserPool.parse(is);
                Element messageElem = messageDoc.getDocumentElement();
                Unmarshaller unmarshaller = XMLObjectProviderRegistrySupport.getUnmarshallerFactory().getUnmarshaller(messageElem);
    
                assert unmarshaller != null;
                return(SAMLObject) unmarshaller.unmarshall(messageElem);
            } catch (InitializationException e) {
                e.printStackTrace();
                return null;
            } catch (XMLParserException e) {
                e.printStackTrace();
                return null;
            } catch (UnmarshallingException e) {
                e.printStackTrace();
                return null;
            } catch (ComponentInitializationException e) {
                e.printStackTrace();
                return null;
            }
        }
    }
    

提交回复
热议问题