Skip to content

Commit

Permalink
feat(jans-keycloak-integration): enhancements to job-scheduler #8614
Browse files Browse the repository at this point in the history
* added support for new protocol mapper in job scheduler
* fixed typo in application shutdown log message

Signed-off-by: Rolain Djeumen <uprightech@gmail.com>
  • Loading branch information
uprightech committed Jun 18, 2024
1 parent c006ad2 commit 6e99863
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ public SamlUserAttributeMapperBuilder attributeNameFormatUnspecified() {
return this;
}

public SamlUserAttributeMapperBuilder jansAttributeName(final String attributename) {

config.put("jans.attribute.name",attributename);
return this;
}

public ProtocolMapper build() {

return this.mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static void main(String[] args) throws InterruptedException, ParserCreate
Thread.sleep(1000);
}
}
log.info("Application shutthing down");
log.info("Application shutting down");
}catch(StartupError e) {
log.error("Application startup failed",e);
if(jobScheduler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,19 @@ private void addReleasedAttributesToManagedSamlClient(ManagedSamlClient client,

List<ProtocolMapper> protmappers = releasedattributes.stream().map((r)-> {
log.debug("Preparing to add released attribute {} to managed saml client with clientId {}",r.getName(),client.clientId());
return ProtocolMapper
/*return ProtocolMapper
.samlUserAttributeMapper(samlUserAttributeMapperId)
.name(generateKeycloakUniqueProtocolMapperName(r))
.userAttribute(r.getName())
.friendlyName(r.getDisplayName()!=null?r.getDisplayName():r.getName())
.attributeName(r.getSaml2Uri())
.attributeNameFormatUriReference()
.build();
.build(); */
return ProtocolMapper
.samlUserAttributeMapper(samlUserAttributeMapperId)
.name(generateKeycloakUniqueProtocolMapperName(r))
.jansAttributeName(r.getName())
.build();
}).toList();

keycloakApi.addProtocolMappersToManagedSamlClient(realm, client, protmappers);
Expand All @@ -228,12 +233,16 @@ private void addReleasedAttributesToManagedSamlClient(ManagedSamlClient client,
private void updateManagedSamlClientProtocolMapper(ManagedSamlClient client, ProtocolMapper mapper, JansAttributeRepresentation releasedattribute) {

log.debug("Updating managed client released attribute. Client id: {} / Attribute name: {}",client.clientId(),releasedattribute.getName());
ProtocolMapper newmapper = ProtocolMapper
/*ProtocolMapper newmapper = ProtocolMapper
.samlUserAttributeMapper(mapper)
.userAttribute(releasedattribute.getName())
.friendlyName(releasedattribute.getDisplayName()!=null?releasedattribute.getDisplayName():releasedattribute.getName())
.attributeName(releasedattribute.getSaml2Uri())
.attributeNameFormatUriReference()
.build(); */
ProtocolMapper newmapper = ProtocolMapper
.samlUserAttributeMapper(mapper)
.jansAttributeName(releasedattribute.getName())
.build();
keycloakApi.updateManagedSamlClientProtocolMapper(realm, client,newmapper);
}
Expand Down

0 comments on commit 6e99863

Please sign in to comment.