2016-03-04 5 views
8

को विस्थापित करने के लिए मैं 2.6 opensaml से 3.1.1 opensaml के संकलन मैं कुछ त्रुटियाँकैसे से opensaml 2.6 3.1.1

1)

Element plaintextElement = getElementAssertion(inputBean); 
String xml = XMLHelper.prettyPrintXML(plaintextElement); 

मैं cant't प्राप्त एक वर्ग की ओर पलायन करने के लिए है नए संस्करण में क्लास XMLHelper खोजें।

2)

DefaultBootstrap.bootstrap(); 
builderFactory = Configuration.getBuilderFactory(); 
Configuration.getMarshallerFactory().getMarshaller(assertion).marshall(assertion); 

मैं कक्षा DefaultBootstrap लगता है can'f और मैं तरीकों getBuilderFactory(), getMarshallerFactory() के साथ एक वर्ग विन्यास

3)

BasicCredential credential = new BasicCredential(); 
नहीं मिल सकता है

अब रचनाकार नया मूलभूत() दिखाई नहीं दे रहा है।

मुझे बहिष्करण संकेत के साथ दस्तावेज नहीं मिला है। इस वर्ग को opensaml 3.1.1 संस्करण में पोर्ट करने के लिए मुझे क्या करना चाहिए?

क्या कोई मेरी मदद कर सकता है? अग्रिम धन्यवाद। मेरे खराब अंग्रेजी के लिए खेद है।

उत्तर

14

यह सुनिश्चित नहीं है कि आप पहले से ही opensaml 3 में अपग्रेड करने में कामयाब रहे हैं, लेकिन जब से मैं खुद को अपग्रेड करने का प्रयास करते हुए आया, तो मैंने सोचा कि मैं जो दस्तावेज प्राप्त करता हूं उसे दस्तावेज करने वाला हूं।

बहुत कम प्रलेखन के रूप में जाहिरा तौर पर यह एक प्राथमिकता उनके लिए पल (भी यहाँ उल्लेख किया: OpenSaml3 Documentation) पर नहीं है, सबसे अधिक उपयोगी (यहां तक ​​कि द्वारा अगर अब तक पूरा नहीं) पेज मैंने पाया यह एक है: https://wiki.shibboleth.net/confluence/display/OS30/Initialization+and+Configuration

1) वहाँ एक वर्ग SerializeSupport एक विधि prettyPrintXML साथ lib में net.shibboleth.utilities:java-support

2) प्रारंभ अब InitializationService जैसे माध्यम से किया जाता है

InitializationService.initialize(); 

आपको लगता है कि opensaml जावा सेवा प्रदाता एपीआई का उपयोग कर रहा है XMLObjectProviderRegistrySupport उदा .:

XMLObjectProviderRegistrySupport.getMarshallerFactory() 
XMLObjectProviderRegistrySupport.getBuilderFactory() 
XMLObjectProviderRegistrySupport.getUnmarshallerFactory() 

मन के माध्यम से बिल्डर/marshallers प्राप्त कर सकते हैं। मेरे मामले में, SAML- अभिकथन पार्स करने के लिए (OSGi बंडल org.apache.servicemix.bundles:org.apache.servicemix.bundles.opensaml उपयोग करते हुए) मैं एसपीआई config META-INF/services/org.opensaml.core.config.Initializer जोड़ा निम्नलिखित प्रविष्टियों युक्त

org.opensaml.core.xml.config.XMLObjectProviderInitializer 
org.opensaml.core.xml.config.GlobalParserPoolInitializer 
org.opensaml.saml.config.XMLObjectProviderInitializer 
org.opensaml.saml.config.SAMLConfigurationInitializer 
org.opensaml.xmlsec.config.XMLObjectProviderInitializer 

संपादित करें: ऊपर एक परीक्षण में काम किया लेकिन OSGi कंटेनर में नहीं चला । OSGi के लिए युक्ति: OpenSAML3 resource not found 'default-config.xml' in OSGi container

आप मानक पुस्तकालयों का उपयोग करते हैं (org.opensaml:opensaml-core, org.opensaml:opensaml-saml-api, org.opensaml:opensaml-saml-impl, ...) यदि आप किसी भी एसपीआई config जोड़ने के लिए के रूप में पहले से ही जार आरंभीकरण के लिए एक मानक विन्यास के साथ एसपीआई कॉन्फ़िगरेशन शामिल की जरूरत नहीं हो सकती है।

3) lib org.opensaml:opensaml-security-api में कक्षा BasicCredential है। मैं इनटाइलाइजेशन के दौरान एक कुंजी प्रदान करने का विकल्प नहीं देखता हूं।

+0

तो क्या कारण है जब मैं अभी भी कारखाने से (अन) marshaller की अशक्त बजाय हो सकता है? 'XMLObjectProviderRegistrySupport.getMarshallerFactory()। GetMarshaller (authnRequest.getElementQName())' – Gobliins

+0

क्या आपने 'प्रारंभिक सेवा' प्रारंभ करें(); '? –

+0

https://git.shibboleth.net/view/?p=java-opensaml.git;a=blob;f=opensaml-saml-impl/src/test/java/org/opensaml/ पर कुछ उपयोगी नमूना कोड है saml/SAML2/मेटाडाटा/MetadataTest.java; एचबी = HEAD। ध्यान दें कि कुछ प्रारंभिकरण 'org.opensaml.core.xml.XMLObjectBaseTestCase # initXMLObjectSupport' पर superclass में है जो बदले में' OpenSAMLInitBaseTestCase' से प्राप्त होता है ('प्रारंभिक सेवा' प्रारंभिक() 'के अलावा कुछ भी नहीं करता है)। –

0

मैं सीख रहा हूं कि विकास के लिए ओएस 3 का उपयोग कैसे करें। V3 संस्करण में SAMLObject के लिए बेस 64 नमूना अनुरोध को परिवर्तित करने के लिए यह एक उदाहरण है। उम्मीद है, यह आपकी मदद कर सके।

परियोजना को देखने के 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; 
     } 
    } 
} 
+0

यह मेरे लिए तब तक काम नहीं करेगा जब तक कि मैं '/ मेटा-आईएनएफ/सेवाएं/org.opensaml.core.config.Initializer' भी जोड़ूं जिसमें @Clauds द्वारा दिखाया गया कॉन्फ़िगरेशन शामिल है। –