CAS + Pac4j + Okta

96 views
Skip to first unread message

Adarsh

unread,
Jan 28, 2022, 8:01:52 AM1/28/22
to CAS Community
Hi, I am trying to setup a CAS (6.5.0-SNAPSHOT) server with PAC4j and Okta. When I try to start the server (boorRun / war in a tomcat webapp) I get the following error

[[33m2022-01-28 17:59:41,315 WARN [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext] - <Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'casServletWebServerFactory' defined in class path resource [org/apereo/cas/config/CasEmbeddedContainerTomcatConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory]: Factory method 'casServletWebServerFactory' threw exception; nested exception is java.lang.NullPointerException>^[[m

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'casServletWebServerFactory' defined in class path resource [org/apereo/cas/config/CasEmbeddedContainerTomcatConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory]: Factory method 'casServletWebServerFactory' threw exception; nested exception is java.lang.NullPointerException

I have no idea why this is happening, any help would be awesome as I am stuck,

My implementation
1) I downloaded the Cas Overlay
2) I add this implementation to my build.gradle file

implementation "org.apereo.cas:cas-server-support-json-service-registry"
implementation "org.apereo.cas:cas-server-support-pac4j-webflow"

3) Added the following properties to cas.properties

cas.authn.pac4j.saml[0].keystorePassword=<password>
cas.authn.pac4j.saml[0].privateKeyPassword=<password>
cas.authn.pac4j.saml[0].serviceProviderEntityId=https://localhost:8443
cas.authn.pac4j.saml[0].keystorePath=<path to samlKeystore.jks>
cas.authn.pac4j.saml[0].serviceProviderMetadataPath=<path to cas_metadata.xml>
cas.authn.pac4j.saml[0].identityProviderMetadataPath=<path to okta-metadata.xml>
cas.authn.pac4j.saml[0].clientName=<client name>
cas.authn.pac4j.saml[0].destinationBinding=urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST

4) this is my json configuration file

{

  "@class" : "org.apereo.cas.services.RegexRegisteredService",

  "serviceId" : "^(https?|imaps?|http?)://.*",

  "name" : "<application_name>",

  "id" : 1,

  "evaluationOrder" : 1,

  "logo" : "logo url",

  "accessStrategy" : {

    "@class" : "org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy",

    "delegatedAuthenticationPolicy" : {

      "@class" : "org.apereo.cas.services.DefaultRegisteredServiceDelegatedAuthenticationPolicy",

      "allowedProviders" : [ "java.util.ArrayList", [ "app-saml" ] ]

    }

  }

}


Adarsh

unread,
Feb 7, 2022, 8:59:01 AM2/7/22
to CAS Community, Adarsh
Add server.port=8443 to the cas.properties file to over come this error. Hopefully it will help someone some day as this is not mentioned in any documentation anywhere.
Reply all
Reply to author
Forward
0 new messages