I use the JSON service registry to set up the service name:
In build.gradle: compile "org.apereo.cas:cas-server-support-json-service-registry:${casServerVersion}"
Then in /etc/cas/services i created a file wildflyApplication-100.json with the content:
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"serviceId" : "https://mywebserver\\.com*",
"name" : "wildflyApplication",
"id" : 100,
"evaluationOrder" : 1
}
I modified /etc/cas/application.properties and added these lines:
cas.authn.attributeRepository.jdbc[0].attributes.role=personRole
cas.authn.attributeRepository.jdbc[0].singleRow=false
cas.authn.attributeRepository.jdbc[0].columnMappings.attribute=value
cas.authn.attributeRepository.jdbc[0].sql=SELECT * FROM Users left join User_roles on Users.userid=User_roles.userid WHERE Users.{0}
cas.authn.attributeRepository.jdbc[0].username=userid
cas.authn.attributeRepository.jdbc[0].driverClass=com.mysql.jdbc.Driver
cas.authn.attributeRepository.jdbc[0].user=*******
cas.authn.attributeRepository.jdbc[0].password=*****
cas.authn.attributeRepository.jdbc[0].url=jdbc:mysql://localhost:3306/cas_auth1
cas.authn.attributeRepository.jdbc[0].attributes.firstname=firstName
cas.authn.attributeRepository.jdbc[0].attributes.lastname=lastName
cas.authn.attributeRepository.jdbc[0].attributes.group=value
cas.authn.attributeRepository.defaultAttributesToRelease=personRole,firstname,lastname,group
First i do a post to casUrlPrefix +"/v1/tickets" + "?format=json", and i set the header to addHeader("Accept", "application/json") which makes sure i will get a json formatted response from CAS.
I extract the TGT ticket with EntityUtils and proceed to a new post.
This new post is build like this casUrlPrefix +"/v1/tickets" + "?format=json" and has 3 url parameters: username, password and service. They are posted to CAS and the response is a json formatted ST- ID
After that i set validateUrl=casUrlPrefix + "/p3/serviceValidate?service="
and i do a GET to HttpGet(validateUrl+serviceURL+"&ticket="+STid+"&format=json")
This gives me all the user attributes JSON formatted as stated in application.properties with the cas.authn.attributeRepository.jdbc[0] lines.
Benefit of this that i can now "see" to which groups the user belongs