Skip to content

Commit

Permalink
feat(jans-keycloak-integration): add kc scheduler service #8343 (#8436)
Browse files Browse the repository at this point in the history
* fix(jans-linux-setup): improper scim configuration for jans kc #8210
* updated the keycloak configuration file to reflect the  configuration for the storage-spi

Signed-off-by: Rolain Djeumen <uprightech@gmail.com>

* chore(jans-keycloak-integration): bump kc version to 24.0.0 #8315

Signed-off-by: Rolain Djeumen <uprightech@gmail.com>

* feat(jans-keycloak-integration): add kc scheduler service #8343
* changed the application into a single run application suitable for cron

Signed-off-by: Rolain Djeumen <uprightech@gmail.com>

---------

Signed-off-by: Rolain Djeumen <uprightech@gmail.com>
  • Loading branch information
uprightech committed May 2, 2024
1 parent a94fa91 commit 0bab357
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class App {
private static KeycloakApiFactory keycloakApiFactory = null;

private static boolean running = false;
private static boolean isCronJob = true;
/*
* Entry point
*/
Expand All @@ -69,23 +70,24 @@ public static void main(String[] args) throws InterruptedException, ParserCreate
log.debug("Initialization additional application objects");
SAXUtils.init();

log.debug("Initializing scheduler ");
jobScheduler = createJobScheduler(config);
startJobScheduler(jobScheduler);

log.debug("Starting jans trust relationship sync job");
startJansTrustRelationshipSyncJob(config);



log.debug("Performing post-startup operations");
performPostStartupOperations();

log.debug("Application startup successful");
while(running) {
Thread.sleep(1000);
if(isCronJob) {
log.debug("Running as cron, skiping scheduler initialization");
runCronJobs();
log.debug("Jobs run to completion.");
}else {
log.debug("Not running as cron job. Initializing scheduler");
jobScheduler = createJobScheduler(config);
startJobScheduler(jobScheduler);
log.debug("Starting jans trust relationship sync job");
startJansTrustRelationshipSyncJob(config);
log.debug("Performing post-startup operations");
performPostStartupOperations();
log.debug("Application startup successful");
while(running) {
Thread.sleep(1000);
}
}
log.debug("Application shutting down");
log.info("Application shutthing down");
}catch(StartupError e) {
log.error("Application startup failed",e);
if(jobScheduler != null) {
Expand Down Expand Up @@ -159,6 +161,14 @@ private static final JobScheduler createQuartzJobSchedulerFromConfiguration(AppC
}
}

private static final void runCronJobs() {

log.debug("Running trust relationship sync cron job");
TrustRelationshipSyncJob trsyncjob = new TrustRelationshipSyncJob();
trsyncjob.run(null);
log.debug("Trust relationship sync cron job complete");
}

private static final void performPostStartupOperations() {

running = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public TrustRelationshipSyncJob() {
@Override
public void run(ExecutionContext context) {

try {
performSyncTasks();
}


private void performSyncTasks() {

try {
log.debug("Performing Saml client housekeeping");
performSamlClientsHousekeeping();
log.debug("Saml client housekeeping complete");
Expand Down
1 change: 0 additions & 1 deletion jans-keycloak-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<module>authenticator</module>
<module>storage-spi</module>
<module>job-scheduler</module>
<module>protocol-mapper</module>
</modules>

<repositories>
Expand Down

0 comments on commit 0bab357

Please sign in to comment.