diff --git a/KeycloakSSO/KeycloakSSO/Deployments/sso.cdd b/KeycloakSSO/KeycloakSSO/Deployments/sso.cdd new file mode 100644 index 0000000..3c5a95d --- /dev/null +++ b/KeycloakSSO/KeycloakSSO/Deployments/sso.cdd @@ -0,0 +1,136 @@ + + + + 3 + yogita + 2024/04/18 15:35:18 + + + sso + UTF-8 + + + + + + 60 + 0 + 5 + 5 + 5 + 900 + -1 + 1 + + + + default + always_on + 1.0 + tracecontext + + + / + + + none + + + + + / + + + + + / + + + + + + + true + *:info + + true + logs + + 10 + 5000000 + true + + + + false + false + + + + false + + + + + + + + + /Rules/Token + + + + + + + 1024 + 900 + + + + 1024 + 10 + + + + + false + false + + + + + + + + + + + inference-class + + + + + logConfig + false + false + false + + + + + + + + + + + + + + + + + + + diff --git a/KeycloakSSO/KeycloakSSO/Events/Timer.time b/KeycloakSSO/KeycloakSSO/Events/Timer.time new file mode 100644 index 0000000..3639877 --- /dev/null +++ b/KeycloakSSO/KeycloakSSO/Events/Timer.time @@ -0,0 +1,2 @@ + + diff --git a/KeycloakSSO/KeycloakSSO/KeyclockSSO.conceptview b/KeycloakSSO/KeycloakSSO/KeyclockSSO.conceptview new file mode 100644 index 0000000..e69de29 diff --git a/KeycloakSSO/KeycloakSSO/KeyclockSSO.eventview b/KeycloakSSO/KeycloakSSO/KeyclockSSO.eventview new file mode 100644 index 0000000..e69de29 diff --git a/KeycloakSSO/KeycloakSSO/KeyclockSSO.projectview b/KeycloakSSO/KeycloakSSO/KeyclockSSO.projectview new file mode 100644 index 0000000..e69de29 diff --git a/KeycloakSSO/KeycloakSSO/Rules/Token.rule b/KeycloakSSO/KeycloakSSO/Rules/Token.rule new file mode 100644 index 0000000..f0976b1 --- /dev/null +++ b/KeycloakSSO/KeycloakSSO/Rules/Token.rule @@ -0,0 +1,24 @@ +/** + * @description + * @author yogita-ThinkPad-T14-Gen-2i + */ +rule Rules.Token { + attribute { + priority = 5; + forwardChain = true; + } + declare { + Events.Timer request; + } + when { + + } + then { + String output = Authentication.ssoAuthenticate("https://www.keycloak.org/app/#url=http://localhost:8080&realm=myrealm&client=myclient","myuser","YWRtaW4="); + if(output == null) + System.debugOut("Authentication Failed"); + else + System.debugOut("Authentication succeeded"); + System.debugOut("Keycloak Token:"+output); + } +} \ No newline at end of file diff --git a/KeycloakSSO/KeycloakSSO/pom.xml b/KeycloakSSO/KeycloakSSO/pom.xml new file mode 100644 index 0000000..58d9d43 --- /dev/null +++ b/KeycloakSSO/KeycloakSSO/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + com.tibco.cep + runtime + 6.3.1 + + com.tibco.be + KeyclockSSO + ear + + + + yogita + + + + /home/yogita/testing/be/6.3 + + 6.3.1 + + + + + com.tibco.be.maven.plugin + be-maven-plugin + ${project.parent.version} + true + + + false + ${projectVersion} + /home/yogita/631work/KeyclockSSO/Deployments/KeyclockSSO.ear + false + true + + + + + + diff --git a/KeycloakSSO/KeyclockSSO.ear b/KeycloakSSO/KeyclockSSO.ear new file mode 100644 index 0000000..176b2ba Binary files /dev/null and b/KeycloakSSO/KeyclockSSO.ear differ diff --git a/KeycloakSSO/Readme.html b/KeycloakSSO/Readme.html new file mode 100644 index 0000000..5cd03ab --- /dev/null +++ b/KeycloakSSO/Readme.html @@ -0,0 +1,89 @@ + + + + + + Keycloak SSO + + - TIBCO BusinessEvents® Examples + + + + + + + + + + +

Purpose of This Example

+ +

The KeycloakSSO example demonstrates how TIBCO BusinessEvents® uses the ssoAuthenticate function to retrieve + Keycloak token.

+ +

About the project

+ +

The project has a single agent class - inference

+ +

The inference agent has Token rule which triggers when a Timer event is generated.The rule retrives the token using + ssoAuthenticate function and logs the Authentication

+ +

Running the project

+ +
    + +
  1. +

    Make sure to run Keycloak with Docker following the URL + https://www.keycloak.org/getting-started/getting-started-docker.

    +
  2. + +
  3. +

    Add the below configuration to BE_HOME\mm\config\jaas-config.config file.

    + SSOAuthenticator { + com.tibco.cep.security.authen.sso.SSOLoginModule required debug=true; + }; +
  4. + +
  5. +

    Update the BE_HOME\mm\config\users.pwd with the user and password(MD5 Hash) created in step 1 as an MM_Administrator.For Example- myuser:21232f297a57a5a743894a0e4a801fc3:MM_ADMINISTRATOR; Now add the + property name="be.auth.file.location" and value="BE_HOME\mm\config\users.pwd" in "auth" property-group in the cdd.

    +
  6. + +
  7. +

    Open a command window. Start a inference agent instance.

    +
    +
    +BE_HOME/bin/be-engine --propFile BE_HOME\bin\be-engine.tra -u default -c Deployments/sso.cdd Deployments/KeyclockSSO.ear
    +
    +
  8. + +
+ +

Output

+ +

Once the engine is up and running the agent starts retrieving tokens periodically.

+ +

Sample output

+
+...
+2024 Apr 18 16:37:00:759 GMT +05 yogita-ThinkPad-T14-Gen-2i INFO [inference-class.HiResTimer] - [user] [inference-class] Authentication succeeded
+2024 Apr 18 16:37:00:759 GMT +05 yogita-ThinkPad-T14-Gen-2i INFO [inference-class.HiResTimer] - [user] [inference-class] Keycloak Token:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPFNTT1Rva2VuIElEPSI2ODg2
+ZjFmMS0yZmMzLTRmMzUtODMxOC00YzJlY2Y4NjkwYjYiPjxTdWJqZWN0Pm15dXNlcjwvU3ViamVj
+dD48SXNzdWVyPmh0dHBzOi8vd3d3LmtleWNsb2FrLm9yZy9hcHAvI3VybD1odHRwOi8vbG9jYWxo
+b3N0OjgwODAmYW1wO3JlYWxtPb3N0OjgwODAmYW1wO3JlYWxtPW15cmVhbG0mYW1wO2NsaWVudD1teWNsaWVudDwvSXNzdWVyPjxJ
+W15cmVhbG0mYW1wO2NsaWVudD1teWNsaWVudDwvSXNzdWVyPjxJ
+c3N1ZUluc3RhbnQ+VGh1IEFwciAxOCAxNjozNzowMCBJU1QgMjAyNDwvSXNzdWVJbnN0YW50Pjwv
+U1NPVG9rZW4+
+...
+
+ + + + + \ No newline at end of file