Problems trying to migrate/build using OpenSAML3 (3.3.0) with Eclipse and Maven

o haya ohaya at yahoo.com
Mon Feb 25 04:26:46 EST 2019


Hi,

I am stuck at the part where I am signing and adding a signature to the Assertion.  Here's the current code I have:

        assertion.setSignature(signature); 	// From: "The Signature object is then added to the SAML object using the setSignature method."

        
        MarshallerFactory marshallerFactory = null;
        ParserPool parserPool1 = null;
        Element element1 = null;
        Marshaller marshaller1 = null;
        try {
        	marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
        	marshaller1 = marshallerFactory.getMarshaller(signature);
        	if(marshaller1 == null) {
        		System.out.println("Unable to locate marshaller for " + signature.getElementQName() + " can not perform marshalling operation");
               	System.exit(-1);
        	}
        } catch (Exception e) {
        	System.out.println("** ERROR ** -when creating signature, e=[" + e + "]");
        	//System.exit(-1);
        }

        try {
            element1 = marshaller1.marshall(signature);
        } catch (Exception e) {
        	//System.out.println("** ERROR ** -when marshalling, e=[" + e + "]");
        	//System.exit(-1);
        }
        
        

But, I am getting this when I run:

org.opensaml.xmlsec.signature.support.SignatureException: XMLObject does not have XMLSignature instance, unable to compute signature
** ERROR * - Exception: [java.lang.ClassCastException: org.opensaml.saml.saml2.core.impl.AssertionImpl cannot be cast to org.opensaml.saml.saml2.core.StatusResponseType]
	at org.opensaml.xmlsec.signature.support.provider.ApacheSantuarioSignerProviderImpl.signObject(ApacheSantuarioSignerProviderImpl.java:55)
	at org.opensaml.xmlsec.signature.support.Signer.signObject(Signer.java:73)
	at SAMLWriter.main(SAMLWriter.java:414)

Does anyone have any ideas/suggestions about what I am doing wrong (and how to fix the problem)?

Thanks,
Jim







--------------------------------------------
On Sun, 2/24/19, o haya <ohaya at yahoo.com> wrote:

 Subject: Re: Problems trying to migrate/build using OpenSAML3 (3.3.0) with Eclipse and Maven
 To: "Shib Dev" <dev at shibboleth.net>, "o haya" <ohaya at yahoo.com>
 Date: Sunday, February 24, 2019, 8:08 PM
 
 
         Hi,
 EarlieI had added the xmltooling to
 the dependencies, which got rid of 
 I am going crazy because I am seeing
 a bunch of duplicate classes/methods, and am going
 round-and-round trying to figure out which ones to
 use.
 Then, I found
 this:
 SAML
 Assertion Validation using OpenSAML 3
 
 SAML Assertion Validation using
 OpenSAML 3I
 was trying to validate SAMLResponse assertions using
 OpenSAML 3.  Link:
 http://shibboleth.net/pipermail/dev/20...
 where it says:
 "You'll want to
 remove the xmltooling dependency from your POM. It is 
 effectively an OpenSAML 2.0 library, and it causes conflicts
 like the 
 one you're receiving.".
 So now I am really puzzled.  If I
 don't include the xmltooling in the dependencies, I get
 a bunch of unresolved types like "Configuration",
 but, if I DO include xmltooling in the dependencies, that
 causes a bunch of duplicate classes and
 methods.
 So I guess I
 SHOULD NOT include the xmltooling, BUT if I don't
 include xmltooling, how are all of those unresolved
 references (Configuration, Credential,
 SecurityConfiguration, SecurityHelper, and Signature)
 supposed to get resolved?
 FYI, right now, I have the following
 dependencies:
 opensaml-coreopensaml-messaging-api
 and -impl
 opensaml-saml-api
 and
 -implopensaml-profile-api
 and
 -implopensaml-security-api
 and
 -implopensaml-xmlsec-api
 and -impl
 Sorry for all the questions, but
 this has been super confusing for me :(...
 Thanks,Jim
 
 
 
 
 
 
 
 
 
 
 
 
         
         
             
                 
                 
                     On Sunday, February 24, 2019, 2:41:01 PM
 EST, o haya <ohaya at yahoo.com> wrote:
                 
                 
 
                 
 
                 Hi,
 
 I was able to get by that
 problem. 
 
 Instead of:
 
 builderFactory =
 
 Configuration.getBuilderFactory();          
 
 I had to use:
 
 builderFactory =
 XMLObjectProviderRegistrySupport.getBuilderFactory();
 
 Also, I had to move the
 initialize() method around. 
 
 That allowed
 the SAMLWriter.java to get past the part where it constructs
 the Assertion, but then now, it is blowing up with another
 NullPointerException, in the part where it is setting up to
 do the signing/signature :(...
 
 Jim
 
 
 
 
 --------------------------------------------
 On Sun, 2/24/19, o haya
 <ohaya at yahoo.com>
 wrote:
 
  Subject: Re: Problems
 trying to migrate/build using OpenSAML3 (3.3.0) with Eclipse
 and Maven
  To:
 "Shib Dev" <dev at shibboleth.net>
  Cc: "Ohaya"
 <ohaya at yahoo.com>
  Date: Sunday, February
 24, 2019, 12:12 PM
  
  
          Hi,
  Sorry
  to bother you all, but I
 have been struggling with this
  point now (trying to migrate my Java+OpenSAML app
 to 3.x),
  and I have
 been stuck with this current
  problem.
  I
 cannot seem
  to find
 the correct imports for "Configuration"
  and for
 "SecurityConfiguration".
  If I include the
 xmltooling in the
 
 dependencies, Eclipse suggests/lets me add:
  import
 
 org.opensaml.xml.Configurationimport
 
 org.opensaml.xml.security.SecurityConfiguration
  but, if I do that, then I
 get a
  different
 error:
  Description  
  Resource  
 
  Path    Location    Type
  Type
 
 mismatch: cannot convert from
  org.opensaml.xml.XMLObjectBuilderFactory to
 
 org.opensaml.core.xml.XMLObjectBuilderFactory  
   SAMLWriter.java  
  /SAMLWriter/src/main/java    line
  459    Java Problem
  
  That error is happening
 on this
  line:
     
  private static
 XMLObjectBuilderFactory builderFactory;
  
      public static
  XMLObjectBuilderFactory
 getSAMLBuilder() throws
  ConfigurationException{
  
         
 if(builderFactory == null) {
                builderFactory =
 
 Configuration.getBuilderFactory();                  
  // <<<<<
 ERROR IS HERE...
 
         }
 
        
  return
 builderFactory;
     
 }
  
  
  I think
  that I am either
 importing the wrong classes for
  Configuration and SecurityConfiguration (like I
 should be
  importing
 and using some classes from org.opensaml.core.xml
  instead of from
 org.opensaml.xml?), or maybe for OpenSAML
  3.x, I should be using
 some other class/method to create the
  builderFactory?
  
  If anyone can point me to
 how to get
  past this
 it would be appreciated!!
  Thanks,Jim
 
 
  
  
  
          
          
              
                 
 
              
    
            
          On Saturday, February 23, 2019, 8:26:46
  PM EST, o haya <ohaya at yahoo.com>
 wrote:
          
        
        
          
  
                 
 
  
                 
 Hi Brent,
  
  Thanks for all the
 info,
  esp. the links
 for the Javadocs - I had been looking for
  those, but wasn't
 able to find them earlier.  I'll
  try to resolve what I can
 and post back here on the ones
  that I can't find.
  
  Thanks,
  Jim
  
 
 --------------------------------------------
  On Sat, 2/23/19, Brent
  Putman <putmanb at georgetown.edu>
  wrote:
  
   Subject: Re:
 Problems
  trying to
 migrate/build using OpenSAML3 (3.3.0) with Eclipse
  and Maven
   To: dev at shibboleth.net
   Date: Saturday,
 February
  23, 2019,
 4:53 PM
   
   
       
   
       
       On 2/23/19
   12:59 PM, o haya
  wrote:
   
       
       
         Hi,
   
   I am trying to
 migrate
  the
 application that I had written (a
   modified version of
  SAMLWriter.java) earlier using OpenSAML
   2.6.6, now, to
 OpenSAML
  3.3.0 using
 Eclipse and Maven.
   
    
     
   
   
       
       Well, as I
 said
  before you
 don't have to use
   Maven, nor Eclipse. 
         Use what you
 are comfortable with.
   
      
 
       
   
       
       
         
   
   I am not that
 familiar
  with Maven,
 but anyway, I added
  
 dependencies in the pom.xml:
       
   
    
   
       
       The use of
  dependencyManagement is a
 little overkill
   for
 a single
        
 project like
  this, but
 it's not wrong. I don't
   see any other
         obvious
  problems.
  
 
       
       
   
       
         
   But, when I do Run
 As
  ==> Maven Build
 ==> clean
   install
 -U, I am getting some errors that I
  haven't been
   able
  to resolve so far:
   
   - Configuration cannot
 be
  resolved
   
   -
 IdentifierGenerator
 
 cannot be resolved to a type
   
   -
 
 SecureRandomIdentifierGenerator cannot be resolved to a
   type
   
   -
 SecurityConfiguration
 
 cannot be resolved to a type
   
   -
  SecurityHelper cannot be
 resolved
   
   - The
  constructor
 BasicX509Credential() is undefined
   
   - XMLHelper cannot
 be
  resolved
   
       
       
   
       
       3.x is not
 2.x. 
  At the very
 least all the package
   names changed,
         so any existing 'import'
  statements are
  
  wrong.  In many cases
 the
         code
 itself was refactored or rewritten,
  so classes
   and
  methods
        
  don't exist anymore,
 or have different names, or
        
 
 method/constructor arguments are different, etc.
       Some of the
  "cannot be
 resolved" ones are
   likely simply package
         changes. 
 Some
  of those classes
 don't exist
  
 anymore however, like
 
        XMLHelper, SecurityHelper, they were
  replaced by other
  
  things.
   
       
       The Javadocs
 are
  your friend:
       https://wiki.shibboleth.net/confluence/display/OS30/APIDocumentation
   
       
       For usage
 examples,
  the best
 thing is to look at the
   unit tests
         in the various projects.
   
       
       
   
       
       
         
   
   
   For the
  BasicX509Credential()
 error, this is the line that
   it is flagging in my
  code:
   
                 
  
             
       BasicX509Credential
   credential = new
  BasicX509Credential();
       
   
  
   
   
       
       IIRC there is
 no
  longer a no-arg
 ctor for that
  
 class.  It takes a
   
      mandatory X509Certificate and optional
  PrivateKey. 
  
  That's a good
     
     example of the kind
 of things that changed.
   
      
 
       
   
       
       
         
   
   
   
   As I said, I am not
 that
  familiar with
 Maven, so I am not
  
 sure if I need to add some other dependencies in
  the pom, or
   do I need
  to modify code that uses
 those types that are
  
 getting the errors?
   
    
       
   
       
       Yes,
 definitely
  many types
 have been
  
  added/removed/modified,
 so
         the
 corresponding 2.x code definitely
  must change.
       Wrt
 
 dependencies, you definitely need java-support
   from our
         projects,
  although if you're
 using Maven that will
   be resolved as
         a transitive
  dependency, as will all
 the other deps. 
   If
 not using
        
 Maven then
  you'd
 have to manually include all the
   right jars in
         your project.
   
       
       
   
       
       
         
   
   
   Also, as I said I
 have
  the dependencies
 configured for
  
 opensaml version 3.3.0, but is there not a 3.4.2
  in Maven?
   
   
       
       
   
       
       Yes, 3.4.2 is
 the
  latest.
   
       
       
   
       
       
   
     -- 
   To unsubscribe from
 this
  list send an
 email to
  
  dev-unsubscribe at shibboleth.net
   -----Inline
 Attachment
 
 Follows-----
   
   
              
          
             
         


More information about the dev mailing list