• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • PKI Training
  • OpenSSL
  • Keytool
  • PKI Tools
    • Apereo CAS
    • SAML
    • OpenID Connect
  • Get expert help

Apereo CAS Custom Metadata Resolver

December 3, 2024 by Mister PKI Leave a Comment

This article will demonstrate how to create an Apereo CAS Custom Metadata Resolver for individual services in your json service registry. In the event that you need to troubleshoot the resolution of a service providers metadata, you can quickly swap the default CAS resolver with a groovy resolver and catch exceptions, improve logging, etc.

Metadata Resolver with Groovy

import java.nio.charset.*
import java.text.*
import java.util.*
import org.ldaptive.auth.*
import org.apereo.cas.*
import org.apereo.cas.authentication.*
import org.apereo.cas.authentication.support.*
import org.apereo.cas.authentication.support.password.*
import org.apereo.cas.support.saml.*
def run(Object[] args) {
  def registeredService = args[0]
  def samlConfigBean = args[1]
  def samlIdPProperties = args[2]
  def logger = args[4]
  try {
    logger.debug("Downloading metadata...")
    def metadata = new URL("https://example.com/metadata.xml").getText([connectTimeout: 10000, readTimeout: 10000])
    logger.info("Downloaded metadata ${metadata}")
    def inputStream = new ByteArrayInputStream(metadata.getBytes(StandardCharsets.UTF_8))
    def resolver = new InMemoryResourceMetadataResolver(inputStream, samlConfigBean)
    resolver.setId("GroovyMetadataResolver")
    resolver.initialize()
    return resolver
  } catch (Exception e) {
    throw e;
  }
}

Dynamic metadata url

Add this section to your service config to create a location property that you can retrieve in the custom groovy script.

"properties" : {
    "@class" : "java.util.HashMap",
    "metadataLocation" : {      "@class" : "org.apereo.cas.services.DefaultRegisteredServiceProperty",
      "values" : [ "java.util.HashSet", [ "https://example.com/metadata.xml" ] ]
    }
  }

Then in the script do this:

def location = registeredService.getProperties().get("metadataLocation").getValues().iterator().next()
def metadata = new URL(location)

JSON Service Config

"metadataLocation": "file:/etc/cas/config/metadata/metadata.groovy"

Conclusion – Apereo CAS Custom Metadata Resolver

This article has demonstrated how to configure a custom metadata resolver in the CAS IDP (Identity Provider). Let us know in the comments if you have any questions. If you found this article helpful, check out our other articles on Apereo CAS.

Apereo CAS,  Identity Management,  saml

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Popular Posts

PKCS12

openssl s_client

Keytool

Keytool list

ECDSA vs RSA

OpenSSL

PKCS7

Certificate Decoder

PKI for DevOps Engineers – Free Training Series

PKI for DevOps Training Hub

Lesson 1 – How TLS and PKI Work

Lesson 2 – Understanding X.509 Certificates

Lesson 3 – Certificate Chains Explained

Lesson 4 – Debug TLS with OpenSSL

Lesson 5 – Verify Certificate Chains

Lesson 6 – Creating CSRs with OpenSSL

Lesson 7 – Working with PKCS12 Certificates

Lesson 8 – Java Keystores and keytool

Lesson 9 – Certificate Expiration Monitoring

Lesson 10 – Automating Certificate Renewal

Lesson 11 – Common TLS Errors

Lesson 12 – PKI Architecture for DevOps

Recent Posts

  • Apache mod_auth_cas: Protect Web Applications with Apereo CAS and Docker
  • Apache mod_auth_mellon: Configure SAML SSO & Docker
  • Configure OpenID Connect (OIDC) in Apereo CAS 7.3 and 8
  • Certificate Ownership Is an Operating Model Problem, Not a Tooling Problem
  • OpenSSL dgst: Create Checksums and Verify Digital Signatures

Footer

  • Twitter
  • YouTube
Mister PKI

Practical security engineering for the systems that establish trust.

Learn OpenSSL Keytool Free training
Work together PKI consulting CAS consulting Sponsored contributions
Site About Support Mister PKI Cookie policy Search
© 2026 Mister PKI Secure systems. Clear guidance.