Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54585

SamlSecurityRealm constructor error with argument binding with Groovy

    Details

    • Similar Issues:

      Description

      I'm trying to configure SamlPlugin with a groovy script.

      Argument `binding` in constructor was introduced with version 1.0.5 and I can't initialize my SamlSecurityRealm in Groovy, seams conflicting with a reserved word.

      Not works (In Jenkins Script console on Master), raise an "java.lang.ClassCastException: java.lang.String cannot be cast to groovy.lang.Binding" :

      import hudson.model.*
      import hudson.security.*
      import jenkins.security.s2m.*
      import hudson.tasks.Mailer
      import org.jenkinsci.plugins.saml.*;def instance = jenkins.model.Jenkins.instance
      def env = System.getenv()def idp_metadata_configuration = new IdpMetadataConfiguration(
      {{ xml=new File("${env.JENKINS_HOME}/init.groovy.d/files/saml-idp-metadata.xml").text,}}
      {{ url=null,}}
      {{ period=null}}
      )def securityRealm = new SamlSecurityRealm(
      {{ idpMetadataConfiguration=idp_metadata_configuration,}}
      {{ displayNameAttributeName="name",}}
      {{ groupsAttributeName="member",}}
      {{ maximumAuthenticationLifetime=Integer.valueOf(7200),}}
      {{ usernameAttributeName="name",}}
      {{ emailAttributeName="email",}}
      {{ logoutUrl="",}}
      {{ advancedConfiguration=null,}}
      {{ encryptionData=null,}}
      {{ usernameCaseConversion="none",}}
      {{ binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"}}
      )

      To fix, I need to remove binding= in constructor

        Attachments

          Activity

          Hide
          ifernandezcalvo Ivan Fernandez Calvo added a comment - - edited

          You can call the regular constructor

          def securityRealm = new SamlSecurityRealm(
          idp_metadata_configuration,
          "name",
          "member",
          Integer.valueOf(7200),
          "name",
          "email",
          "",
          null,
          null,
          "none",
          "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
          )
          
          Show
          ifernandezcalvo Ivan Fernandez Calvo added a comment - - edited You can call the regular constructor def securityRealm = new SamlSecurityRealm( idp_metadata_configuration, "name" , "member" , Integer .valueOf(7200), "name" , "email" , "", null , null , "none" , "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" )

            People

            • Assignee:
              ifernandezcalvo Ivan Fernandez Calvo
              Reporter:
              nelsg Nelson Goncalves
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: