From fa8bb3388d5b46ab369c7f9c391f12846a142ee1 Mon Sep 17 00:00:00 2001 From: jjaferson Date: Mon, 6 Apr 2020 09:52:42 +0100 Subject: [PATCH 1/9] maven project structure --- .classpath | 27 +++++++++++++ .project | 23 +++++++++++ .settings/org.eclipse.jdt.core.prefs | 6 +++ .settings/org.eclipse.m2e.core.prefs | 4 ++ pom.xml | 18 +++++++++ .../java/org/keycloak/plugin/rhmi/App.java | 13 ++++++ .../org/keycloak/plugin/rhmi/AppTest.java | 38 ++++++++++++++++++ .../org/keycloak/plugin/rhmi/App.class | Bin 0 -> 563 bytes .../org/keycloak/plugin/rhmi/AppTest.class | Bin 0 -> 635 bytes 9 files changed, 129 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml create mode 100644 src/main/java/org/keycloak/plugin/rhmi/App.java create mode 100644 src/test/java/org/keycloak/plugin/rhmi/AppTest.java create mode 100644 target/classes/org/keycloak/plugin/rhmi/App.class create mode 100644 target/test-classes/org/keycloak/plugin/rhmi/AppTest.class diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..ebde520 --- /dev/null +++ b/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..7afa608 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + authdelay + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..71ac301 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cc35c82 --- /dev/null +++ b/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + org.keycloak.plugin.rhmi + authdelay + jar + 1.0-SNAPSHOT + authdelay + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/src/main/java/org/keycloak/plugin/rhmi/App.java b/src/main/java/org/keycloak/plugin/rhmi/App.java new file mode 100644 index 0000000..c221efa --- /dev/null +++ b/src/main/java/org/keycloak/plugin/rhmi/App.java @@ -0,0 +1,13 @@ +package org.keycloak.plugin.rhmi; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/src/test/java/org/keycloak/plugin/rhmi/AppTest.java b/src/test/java/org/keycloak/plugin/rhmi/AppTest.java new file mode 100644 index 0000000..2cb3e1a --- /dev/null +++ b/src/test/java/org/keycloak/plugin/rhmi/AppTest.java @@ -0,0 +1,38 @@ +package org.keycloak.plugin.rhmi; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/target/classes/org/keycloak/plugin/rhmi/App.class b/target/classes/org/keycloak/plugin/rhmi/App.class new file mode 100644 index 0000000000000000000000000000000000000000..c12c39e933f11763a3257d8e8ada6259123b89c7 GIT binary patch literal 563 zcmaKpO;5r=5Qg97tF%@@5d1;~PvF7ElLw56F)Ko`@Z|^^!w-Y3&0tU4I~&UI`o{On0A%sLuaHWo(!C@?@Q-uG%}E4 z$Pf4ncN7mi=e{!#-H0J`Ap;p*G9>GbHbd%K_k@KcOdDxr7;>%*#NEX2i13kjlwc^h zy319Yhcd4JnyIKS#|($=e+*6X_qhxh%JpY=!P1IC8F>Jo)D9&zM7TBoZfWa8W9*U?+ z^;J*=%|nkKS6so&V72rl?1~#1?$J4FpR+2T0Htt&*Zal|z|PPM>@r`#Kw2 z6yq`Iz#2t+et_~iRVFr&qfRV7pP5nb4f#U(9XksHi$)-MmShVP6NfmWK0}pa0<~W= C>v<&r literal 0 HcmV?d00001 diff --git a/target/test-classes/org/keycloak/plugin/rhmi/AppTest.class b/target/test-classes/org/keycloak/plugin/rhmi/AppTest.class new file mode 100644 index 0000000000000000000000000000000000000000..bc08dc49e95edfea2586eecf7f7678db79875339 GIT binary patch literal 635 zcmaixQE$>v6vzJu3LUk|WPspMw`EJpme?2{F(ig$PYo{+lKFPQE8J09a@%VBR{Auf zi66iZWjwd^!6?bn|14E Date: Mon, 6 Apr 2020 15:47:20 +0100 Subject: [PATCH 2/9] add maven web project structure --- .classpath | 8 +++ pom.xml | 32 ++++++++- .../authenticator/DelayAuthentication.java | 41 +++++++++++ src/main/webapp/WEB-INF/web.xml | 7 ++ src/main/webapp/index.jsp | 5 ++ .../WEB-INF/classes/AuthenticationDelay.java | 4 ++ target/authdelay/WEB-INF/web.xml | 7 ++ target/authdelay/index.jsp | 5 ++ .../authenticator/DelayAuthentication.java | 41 +++++++++++ .../org/keycloak/plugin/rhmi/App.class | Bin 563 -> 563 bytes target/maven-archiver/pom.properties | 5 ++ .../compile/default-compile/createdFiles.lst | 0 .../compile/default-compile/inputFiles.lst | 1 + .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 + .../TEST-org.keycloak.plugin.rhmi.AppTest.xml | 65 ++++++++++++++++++ .../org.keycloak.plugin.rhmi.AppTest.txt | 4 ++ .../org/keycloak/plugin/rhmi/AppTest.class | Bin 635 -> 627 bytes 18 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/authenticator/DelayAuthentication.java create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/index.jsp create mode 100644 target/authdelay/WEB-INF/classes/AuthenticationDelay.java create mode 100644 target/authdelay/WEB-INF/web.xml create mode 100644 target/authdelay/index.jsp create mode 100644 target/classes/authenticator/DelayAuthentication.java create mode 100644 target/maven-archiver/pom.properties create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml create mode 100644 target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt diff --git a/.classpath b/.classpath index ebde520..d18db64 100644 --- a/.classpath +++ b/.classpath @@ -6,6 +6,14 @@ +<<<<<<< HEAD +======= + + + + + +>>>>>>> add maven web project structure diff --git a/pom.xml b/pom.xml index cc35c82..8516787 100644 --- a/pom.xml +++ b/pom.xml @@ -3,9 +3,9 @@ 4.0.0 org.keycloak.plugin.rhmi authdelay - jar - 1.0-SNAPSHOT - authdelay + war + 0.0.1-SNAPSHOT + authdelay Maven Webapp http://maven.apache.org @@ -14,5 +14,31 @@ 3.8.1 test + + org.keycloak + keycloak-server-spi + provided + 9.0.2 + + + org.keycloak + keycloak-server-spi-private + 9.0.2 + provided + + + org.keycloak + keycloak-services + 9.0.2 + + + com.google.guava + guava + + + + + authdelay + diff --git a/src/main/resources/authenticator/DelayAuthentication.java b/src/main/resources/authenticator/DelayAuthentication.java new file mode 100644 index 0000000..b167a6c --- /dev/null +++ b/src/main/resources/authenticator/DelayAuthentication.java @@ -0,0 +1,41 @@ +package authenticator; + +import org.keycloak.authentication.AuthenticationFlowContext; +import org.keycloak.authentication.Authenticator; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.RealmModel; +import org.keycloak.models.UserModel; + +public class DelayAuthentication implements Authenticator { + + public void close() { + // TODO Auto-generated method stub + + } + + public void authenticate(AuthenticationFlowContext context) { + // TODO Auto-generated method stub + + } + + public void action(AuthenticationFlowContext context) { + // TODO Auto-generated method stub + + } + + public boolean requiresUser() { + // TODO Auto-generated method stub + return false; + } + + public boolean configuredFor(KeycloakSession session, RealmModel realm, UserModel user) { + // TODO Auto-generated method stub + return false; + } + + public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..9f88c1f --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ + + + + Archetype Created Web Application + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..c38169b --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + diff --git a/target/authdelay/WEB-INF/classes/AuthenticationDelay.java b/target/authdelay/WEB-INF/classes/AuthenticationDelay.java new file mode 100644 index 0000000..9cdaffb --- /dev/null +++ b/target/authdelay/WEB-INF/classes/AuthenticationDelay.java @@ -0,0 +1,4 @@ + +public class AuthenticationDelay { + +} diff --git a/target/authdelay/WEB-INF/web.xml b/target/authdelay/WEB-INF/web.xml new file mode 100644 index 0000000..9f88c1f --- /dev/null +++ b/target/authdelay/WEB-INF/web.xml @@ -0,0 +1,7 @@ + + + + Archetype Created Web Application + diff --git a/target/authdelay/index.jsp b/target/authdelay/index.jsp new file mode 100644 index 0000000..c38169b --- /dev/null +++ b/target/authdelay/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + diff --git a/target/classes/authenticator/DelayAuthentication.java b/target/classes/authenticator/DelayAuthentication.java new file mode 100644 index 0000000..b167a6c --- /dev/null +++ b/target/classes/authenticator/DelayAuthentication.java @@ -0,0 +1,41 @@ +package authenticator; + +import org.keycloak.authentication.AuthenticationFlowContext; +import org.keycloak.authentication.Authenticator; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.RealmModel; +import org.keycloak.models.UserModel; + +public class DelayAuthentication implements Authenticator { + + public void close() { + // TODO Auto-generated method stub + + } + + public void authenticate(AuthenticationFlowContext context) { + // TODO Auto-generated method stub + + } + + public void action(AuthenticationFlowContext context) { + // TODO Auto-generated method stub + + } + + public boolean requiresUser() { + // TODO Auto-generated method stub + return false; + } + + public boolean configuredFor(KeycloakSession session, RealmModel realm, UserModel user) { + // TODO Auto-generated method stub + return false; + } + + public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { + // TODO Auto-generated method stub + + } + +} diff --git a/target/classes/org/keycloak/plugin/rhmi/App.class b/target/classes/org/keycloak/plugin/rhmi/App.class index c12c39e933f11763a3257d8e8ada6259123b89c7..2c69532a032c4467fd6c7cca7ce627b6a733ec75 100644 GIT binary patch delta 244 zcmW-b%Syvw5QV=<)21mAdolIiHbKOS5L}2Z#EmXo3I$z98YPnEhcpO2M#!63sNh0y z>)ZGO;-Ajq9L_fba~9^py!iS1`~pt#TQu0Pap^bNY_Y|*#g4_U(724#IKL8VN8@|J zyjIhwcvR(+oERAjOMtH^Aun62v`z3r0gCtC!gUQ=G zk7mX1pfB`RI99=37N_|n&!TWv-iUvQM_qTS#z3k+T5X*I?V`PY{DG9;a^hC>e02r( WJ4Uy*#4HWNUvJaVJE5!9p!W~S3Mz2` delta 283 zcmZvXJxjx26osFgq?&tUO3)rKtuwJBVE1a?`ey4hzWJz%%*jw9|f^({e zaUC1iqe69jsGnRGXepXP<0g8D!ZgaR!@=WS5sy3;@r_mA7lMC2lM@|YUoN?<`JJ-Mi9xIt=Qpu%=iQTK^b4*4Yr$?Q}+(3FWi2$FKXF1ei_c2e3?Jjx(rC o78(}Am7Nc2<+tqm)9S&j3*0vv&GtLXrDgT!J9LdE^bA@Af31l%eE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt new file mode 100644 index 0000000..95ba176 --- /dev/null +++ b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: org.keycloak.plugin.rhmi.AppTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec diff --git a/target/test-classes/org/keycloak/plugin/rhmi/AppTest.class b/target/test-classes/org/keycloak/plugin/rhmi/AppTest.class index bc08dc49e95edfea2586eecf7f7678db79875339..be1875bf7a5ca99e08ab20c1fba5442cb8ca094e 100644 GIT binary patch delta 262 zcmXX=Jxc>Y6r8uWcbhDi<`PX#qhc(K5yTKH3nc_BENm1ZO^YpRKlWiQ1MVjPqIqDqGA?{bs``&JG&5!+t8YaOU`h$w4h!GiR Y5))L{XL@AshWZnsyH*`jqf*%T2N)_Pwg3PC delta 266 zcmXYr%}T>y5Jk@n(o$y?p?OZ236lf$X?GUfGvs(cU!%m-!kMs>RidHtOY) zgg1tOW$Ug8jp+Izc}}{6e?5jG((ST~aKVh!?l;cZl$1~Wx6Wj$dp)pq1!B|vBA!K3d ZplX%1*}5aGwp;ODSuf9>*l$j$)<23~CNBU0 From d4bb81edcdf74ff906c89e6dd3b647e50ff259a3 Mon Sep 17 00:00:00 2001 From: Oleg Matskiv Date: Mon, 6 Apr 2020 18:51:06 +0300 Subject: [PATCH 3/9] Adding Web Content, etc. --- .classpath | 15 ++----- .gitignore | 3 ++ .project | 14 ++++++ .settings/.jsdtscope | 12 +++++ .settings/org.eclipse.jdt.core.prefs | 16 +++++-- .settings/org.eclipse.wst.common.component | 9 ++++ ....eclipse.wst.common.project.facet.core.xml | 6 +++ ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + WebContent/META-INF/MANIFEST.MF | 3 ++ WebContent/WEB-INF/web.xml | 12 +++++ WebContent/index.jsp | 12 +++++ .../java/org/keycloak/plugin/rhmi/App.java | 13 ------ .../plugin/rhmi}/DelayAuthentication.java | 2 +- .../authenticator/DelayAuthentication.java | 41 ------------------ src/main/webapp/WEB-INF/web.xml | 7 --- src/main/webapp/index.jsp | 5 --- target/classes/.gitignore | 1 + .../org/keycloak/plugin/rhmi/App.class | Bin 563 -> 0 bytes target/m2e-wtp/web-resources/.gitignore | 1 + .../org/keycloak/plugin/rhmi/AppTest.class | Bin 627 -> 0 bytes 21 files changed, 93 insertions(+), 81 deletions(-) create mode 100644 .settings/.jsdtscope create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 WebContent/META-INF/MANIFEST.MF create mode 100644 WebContent/WEB-INF/web.xml create mode 100644 WebContent/index.jsp delete mode 100644 src/main/java/org/keycloak/plugin/rhmi/App.java rename {target/classes/authenticator => src/main/java/org/keycloak/plugin/rhmi}/DelayAuthentication.java (96%) delete mode 100644 src/main/resources/authenticator/DelayAuthentication.java delete mode 100644 src/main/webapp/WEB-INF/web.xml delete mode 100644 src/main/webapp/index.jsp create mode 100644 target/classes/.gitignore delete mode 100644 target/classes/org/keycloak/plugin/rhmi/App.class create mode 100644 target/m2e-wtp/web-resources/.gitignore delete mode 100644 target/test-classes/org/keycloak/plugin/rhmi/AppTest.class diff --git a/.classpath b/.classpath index d18db64..4c4dda1 100644 --- a/.classpath +++ b/.classpath @@ -2,26 +2,17 @@ - -<<<<<<< HEAD -======= - - - - - ->>>>>>> add maven web project structure + - - + @@ -31,5 +22,7 @@
+ + diff --git a/.gitignore b/.gitignore index a1c2a23..329059c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# MacOS files +.DS_Store \ No newline at end of file diff --git a/.project b/.project index 7afa608..8a6b712 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -15,9 +20,18 @@ + + org.eclipse.wst.validation.validationbuilder + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..92e666d --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 71ac301..3a0745f 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,16 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..830e5f1 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..30a7082 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/WebContent/META-INF/MANIFEST.MF b/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e94951 --- /dev/null +++ b/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000..9d23c1b --- /dev/null +++ b/WebContent/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + authdelay + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + \ No newline at end of file diff --git a/WebContent/index.jsp b/WebContent/index.jsp new file mode 100644 index 0000000..ce046b5 --- /dev/null +++ b/WebContent/index.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + + + + \ No newline at end of file diff --git a/src/main/java/org/keycloak/plugin/rhmi/App.java b/src/main/java/org/keycloak/plugin/rhmi/App.java deleted file mode 100644 index c221efa..0000000 --- a/src/main/java/org/keycloak/plugin/rhmi/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.keycloak.plugin.rhmi; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/target/classes/authenticator/DelayAuthentication.java b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java similarity index 96% rename from target/classes/authenticator/DelayAuthentication.java rename to src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java index b167a6c..aaa8269 100644 --- a/target/classes/authenticator/DelayAuthentication.java +++ b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java @@ -1,4 +1,4 @@ -package authenticator; +package org.keycloak.plugin.rhmi; import org.keycloak.authentication.AuthenticationFlowContext; import org.keycloak.authentication.Authenticator; diff --git a/src/main/resources/authenticator/DelayAuthentication.java b/src/main/resources/authenticator/DelayAuthentication.java deleted file mode 100644 index b167a6c..0000000 --- a/src/main/resources/authenticator/DelayAuthentication.java +++ /dev/null @@ -1,41 +0,0 @@ -package authenticator; - -import org.keycloak.authentication.AuthenticationFlowContext; -import org.keycloak.authentication.Authenticator; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.models.UserModel; - -public class DelayAuthentication implements Authenticator { - - public void close() { - // TODO Auto-generated method stub - - } - - public void authenticate(AuthenticationFlowContext context) { - // TODO Auto-generated method stub - - } - - public void action(AuthenticationFlowContext context) { - // TODO Auto-generated method stub - - } - - public boolean requiresUser() { - // TODO Auto-generated method stub - return false; - } - - public boolean configuredFor(KeycloakSession session, RealmModel realm, UserModel user) { - // TODO Auto-generated method stub - return false; - } - - public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { - // TODO Auto-generated method stub - - } - -} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 9f88c1f..0000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Archetype Created Web Application - diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp deleted file mode 100644 index c38169b..0000000 --- a/src/main/webapp/index.jsp +++ /dev/null @@ -1,5 +0,0 @@ - - -

Hello World!

- - diff --git a/target/classes/.gitignore b/target/classes/.gitignore new file mode 100644 index 0000000..cf1db2e --- /dev/null +++ b/target/classes/.gitignore @@ -0,0 +1 @@ +/org/ diff --git a/target/classes/org/keycloak/plugin/rhmi/App.class b/target/classes/org/keycloak/plugin/rhmi/App.class deleted file mode 100644 index 2c69532a032c4467fd6c7cca7ce627b6a733ec75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 563 zcmaJ;O;5r=5Pi#6ORa(+_=O0b(1VR94;T|;VmuHv!QjEu0-Lh1?UGVV_*r_;#DhP; zA7z{t6GB4V!_3Z`nYV9tzJETy0G#2-LIzt|lu$OYZD9wy2KEf>Gh{BLFT+cQWaGHQ zkh<1=!H{c7U))W-t_U7^R}oTZ=^j@d9>^&E15@EZP8g~!9k|X&%z8@mkuz3PSNcvc z@T7A!9yf{ACZn}ounpV3oFl;+Z< zb{mLllZYi$O-5#D+Xc~=D9Wiq_+WQ*VUG%2`Yhx=_Vh3eCx9`{7VP;o=qbq3yJ z#}E0y8Tm<91di+tg>ya{wY(^;l%hhVl?I+~Yxs!x`2<5;@ zDNIE{j0~BoGHW%%M0UIjp$yuo)RE%0VIs${HjSt`(b@UWv*IY**u)l@nnu*%5$P`f z++@S&Q8ZqpMTIBhmP`nvSFdYr?9v$wx)3NcWsu?wb!T)Vjk0lY_yYD!l?IEVx*f2L zEQ*+=sx(2t#vFBo$2{_5js+~HTovM0kM$1is*rhs{zM(EilRXoC{rw8DaD^qR@1Eh YitKOcJ?PjUOWPArDosC4pJ*t40~@1(_y7O^ From a1b9d35e4563e1523841db49cd4e957e787d911f Mon Sep 17 00:00:00 2001 From: jjaferson Date: Mon, 6 Apr 2020 15:47:20 +0100 Subject: [PATCH 4/9] add maven web project structure --- .classpath | 6 +++ .gitignore | 6 ++- .settings/.jsdtscope | 5 +++ .settings/org.eclipse.jdt.core.prefs | 9 ++++ .settings/org.eclipse.wst.common.component | 7 +++ ....eclipse.wst.common.project.facet.core.xml | 6 +++ .settings/org.eclipse.wst.validation.prefs | 2 + src/main/webapp/WEB-INF/web.xml | 7 +++ src/main/webapp/index.jsp | 5 +++ .../web-resources/META-INF/MANIFEST.MF | 5 +++ .../authdelay/pom.properties | 7 +++ .../authdelay/pom.xml | 44 +++++++++++++++++++ 12 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .settings/org.eclipse.wst.validation.prefs create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/index.jsp create mode 100644 target/m2e-wtp/web-resources/META-INF/MANIFEST.MF create mode 100644 target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties create mode 100644 target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml diff --git a/.classpath b/.classpath index 4c4dda1..ccdc887 100644 --- a/.classpath +++ b/.classpath @@ -5,6 +5,11 @@
+ + + + + @@ -20,6 +25,7 @@ + diff --git a/.gitignore b/.gitignore index 329059c..e540645 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,10 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +<<<<<<< HEAD # MacOS files -.DS_Store \ No newline at end of file +.DS_Store +======= +/target/ +>>>>>>> add maven web project structure diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope index 92e666d..0102067 100644 --- a/.settings/.jsdtscope +++ b/.settings/.jsdtscope @@ -1,6 +1,11 @@ +<<<<<<< HEAD +======= + + +>>>>>>> add maven web project structure diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 3a0745f..a27a619 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +<<<<<<< HEAD org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve @@ -7,10 +8,18 @@ org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +======= +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +>>>>>>> add maven web project structure org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +<<<<<<< HEAD org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +======= +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +>>>>>>> add maven web project structure org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 830e5f1..7d02191 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,7 +1,14 @@ +<<<<<<< HEAD +======= + + + + +>>>>>>> add maven web project structure diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 30a7082..2d7b456 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,12 @@ +<<<<<<< HEAD +======= + + + +>>>>>>> add maven web project structure diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..9f88c1f --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ + + + + Archetype Created Web Application + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..c38169b --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + diff --git a/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF b/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..fb1c398 --- /dev/null +++ b/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: jose.silva +Build-Jdk: 1.8.0_242 +Created-By: Maven Integration for Eclipse + diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties new file mode 100644 index 0000000..a0c4443 --- /dev/null +++ b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Mon Apr 06 16:39:43 IST 2020 +version=0.0.1-SNAPSHOT +groupId=org.keycloak.plugin.rhmi +m2e.projectName=authdelay +m2e.projectLocation=/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay +artifactId=authdelay diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml new file mode 100644 index 0000000..8516787 --- /dev/null +++ b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + org.keycloak.plugin.rhmi + authdelay + war + 0.0.1-SNAPSHOT + authdelay Maven Webapp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + org.keycloak + keycloak-server-spi + provided + 9.0.2 + + + org.keycloak + keycloak-server-spi-private + 9.0.2 + provided + + + org.keycloak + keycloak-services + 9.0.2 + + + com.google.guava + guava + + + + + + authdelay + + From e120982a873bf3f6821c92c76328a6b2c6cb1779 Mon Sep 17 00:00:00 2001 From: jjaferson Date: Mon, 6 Apr 2020 22:44:08 +0100 Subject: [PATCH 5/9] Add Authenticator and FactoryAuthenticator classes and some cleaning up --- .settings/org.eclipse.wst.common.component | 17 +--- WebContent/META-INF/MANIFEST.MF | 3 - WebContent/WEB-INF/web.xml | 12 --- WebContent/index.jsp | 12 --- pom.xml | 20 ++++- ...layAuthenticationAuthenticatorFactory.java | 83 +++++++++++++++++++ ...ycloak.authentication.AuthenticatorFactory | 18 ++++ src/main/webapp/index.jsp | 11 ++- target/classes/.gitignore | 1 - .../authdelay/pom.properties | 2 +- .../compile/default-compile/inputFiles.lst | 3 +- .../TEST-org.keycloak.plugin.rhmi.AppTest.xml | 17 ++-- .../org.keycloak.plugin.rhmi.AppTest.txt | 2 +- 13 files changed, 139 insertions(+), 62 deletions(-) delete mode 100644 WebContent/META-INF/MANIFEST.MF delete mode 100644 WebContent/WEB-INF/web.xml delete mode 100644 WebContent/index.jsp create mode 100644 src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java create mode 100644 src/main/resources/META-INF/services/org.keycloak.authentication.AuthenticatorFactory delete mode 100644 target/classes/.gitignore diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 7d02191..bcc91bc 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,16 +1 @@ - - -<<<<<<< HEAD - - -======= - - - - ->>>>>>> add maven web project structure - - - - - + diff --git a/WebContent/META-INF/MANIFEST.MF b/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 5e94951..0000000 --- a/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml deleted file mode 100644 index 9d23c1b..0000000 --- a/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - authdelay - - index.html - index.htm - index.jsp - default.html - default.htm - default.jsp - - \ No newline at end of file diff --git a/WebContent/index.jsp b/WebContent/index.jsp deleted file mode 100644 index ce046b5..0000000 --- a/WebContent/index.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - - - - -Insert title here - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8516787..fec64c6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,10 +3,10 @@ 4.0.0 org.keycloak.plugin.rhmi authdelay - war - 0.0.1-SNAPSHOT - authdelay Maven Webapp - http://maven.apache.org + jar + 0.0.1-SNAPSHOT + authdelay Maven Webapp + junit @@ -40,5 +40,17 @@ authdelay + + + maven-war-plugin + 2.4 + + false + + + + + + diff --git a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java new file mode 100644 index 0000000..def8ee0 --- /dev/null +++ b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java @@ -0,0 +1,83 @@ +package org.keycloak.plugin.rhmi; + +import java.util.List; + +import org.keycloak.Config.Scope; +import org.keycloak.authentication.Authenticator; +import org.keycloak.authentication.AuthenticatorFactory; +import org.keycloak.models.AuthenticationExecutionModel; +import org.keycloak.models.AuthenticationExecutionModel.Requirement; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.KeycloakSessionFactory; +import org.keycloak.provider.ProviderConfigProperty; + +public class DelayAuthenticationAuthenticatorFactory implements AuthenticatorFactory { + + + private static final DelayAuthentication SINGLETON = new DelayAuthentication(); + + public Authenticator create(KeycloakSession session) { + return SINGLETON; + } + + public void init(Scope config) { + // TODO Auto-generated method stub + + } + + public void postInit(KeycloakSessionFactory factory) { + // TODO Auto-generated method stub + + } + + public void close() { + // TODO Auto-generated method stub + + } + + public String getId() { + // TODO Auto-generated method stub + return "delay-authentication"; + } + + public String getDisplayType() { + // TODO Auto-generated method stub + return "Delay Authentication"; + } + + public String getReferenceCategory() { + // TODO Auto-generated method stub + return "Delay Authentication"; + } + + /** + * Delay needs to be mandatory + */ + public boolean isConfigurable() { + return false; + } + + public Requirement[] getRequirementChoices() { + // TODO Auto-generated method stub + Requirement[] req = { + AuthenticationExecutionModel.Requirement.REQUIRED + }; + return req; + } + + public boolean isUserSetupAllowed() { + // TODO Auto-generated method stub + return false; + } + + public String getHelpText() { + // TODO Auto-generated method stub + return "Delay authentication until user is created on 3scale by the rhmi operator"; + } + + public List getConfigProperties() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/resources/META-INF/services/org.keycloak.authentication.AuthenticatorFactory b/src/main/resources/META-INF/services/org.keycloak.authentication.AuthenticatorFactory new file mode 100644 index 0000000..5b9e96f --- /dev/null +++ b/src/main/resources/META-INF/services/org.keycloak.authentication.AuthenticatorFactory @@ -0,0 +1,18 @@ +# +# Copyright 2016 Red Hat, Inc. and/or its affiliates +# and other contributors as indicated by the @author tags. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +org.keycloak.plugin.rhmi.DelayAuthenticationAuthenticatorFactory \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index c38169b..ce046b5 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,5 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + +Insert title here + -

Hello World!

+ - + \ No newline at end of file diff --git a/target/classes/.gitignore b/target/classes/.gitignore deleted file mode 100644 index cf1db2e..0000000 --- a/target/classes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/org/ diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties index a0c4443..c8641d8 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties +++ b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Mon Apr 06 16:39:43 IST 2020 +#Mon Apr 06 17:00:20 IST 2020 version=0.0.1-SNAPSHOT groupId=org.keycloak.plugin.rhmi m2e.projectName=authdelay diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 01bed05..6014135 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1 +1,2 @@ -/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay/src/main/java/org/keycloak/plugin/rhmi/App.java +/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java +/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java diff --git a/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml b/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml index b82d434..f1abe79 100644 --- a/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml +++ b/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml @@ -1,5 +1,5 @@ - + @@ -25,26 +25,24 @@ "/> - + - - - + - + - + @@ -54,12 +52,13 @@ - + + - + \ No newline at end of file diff --git a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt index 95ba176..1ab31de 100644 --- a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt +++ b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.keycloak.plugin.rhmi.AppTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec From d421f5e71cfc8029d0e52e432ec88aafc60cf31d Mon Sep 17 00:00:00 2001 From: jjaferson Date: Wed, 8 Apr 2020 17:08:03 +0100 Subject: [PATCH 6/9] added authenticate and action logic --- .../plugin/rhmi/DelayAuthentication.java | 143 ++++++++++++++++-- target/authdelay/index.jsp | 11 +- .../authdelay/pom.properties | 2 +- .../authdelay/pom.xml | 20 ++- target/maven-archiver/pom.properties | 2 +- .../TEST-org.keycloak.plugin.rhmi.AppTest.xml | 6 +- .../org.keycloak.plugin.rhmi.AppTest.txt | 2 +- 7 files changed, 163 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java index aaa8269..c5c6482 100644 --- a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java +++ b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java @@ -1,41 +1,162 @@ package org.keycloak.plugin.rhmi; import org.keycloak.authentication.AuthenticationFlowContext; +import org.keycloak.authentication.AuthenticationFlowError; import org.keycloak.authentication.Authenticator; +import org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator; +import org.keycloak.authentication.authenticators.broker.util.PostBrokerLoginConstants; +import org.keycloak.authentication.authenticators.broker.util.SerializedBrokeredIdentityContext; +import org.keycloak.broker.provider.BrokeredIdentityContext; +import org.keycloak.models.ClientModel; +import org.keycloak.models.FederatedIdentityModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.UserModel; +import org.keycloak.services.Urls; +import org.keycloak.sessions.AuthenticationSessionModel; +import org.jboss.logging.Logger; -public class DelayAuthentication implements Authenticator { - public void close() { - // TODO Auto-generated method stub +import java.net.URI; +import java.util.List; +import java.util.Locale; - } +import javax.ws.rs.core.Response; +import org.keycloak.utils.MediaType; - public void authenticate(AuthenticationFlowContext context) { - // TODO Auto-generated method stub +public class DelayAuthentication extends AbstractIdpAuthenticator implements Authenticator { + private final String USER_CREATED_ATTRIBUTE = "3scale_user_created"; + private final String USER_CREATED_VALUE = "true"; + private static final Logger logger = Logger.getLogger(DelayAuthentication.class); + + + public void close() { } + + /** + * checks whether user has been created in other products + * and received the created attribute set to true + * @param user + * @return + */ + private boolean isUserCreated(UserModel user) { - public void action(AuthenticationFlowContext context) { - // TODO Auto-generated method stub + if (user == null) { + logger.info("user model is null"); + return false; + } + String userCreatedAtt = user.getFirstAttribute(this.USER_CREATED_ATTRIBUTE); + if (userCreatedAtt == null) { + logger.info("user created attribute is null"); + return false; + } + + if (!userCreatedAtt.equals(this.USER_CREATED_VALUE)) { + logger.infof("user created attribute value is different than %s", this.USER_CREATED_VALUE); + return false; + } + + return true; } + + public boolean requiresUser() { - // TODO Auto-generated method stub return false; } public boolean configuredFor(KeycloakSession session, RealmModel realm, UserModel user) { - // TODO Auto-generated method stub return false; } public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) { - // TODO Auto-generated method stub + } + + + @Override + protected void authenticateImpl(AuthenticationFlowContext context, SerializedBrokeredIdentityContext serializedCtx, + BrokeredIdentityContext brokerContext) { + if (isUserCreated(context.getUser())) { + redirectToAfterFirstBrokerLoginSuccess(context, brokerContext); + } else { + redirectToAction(context); + } + } + + @Override + protected void actionImpl(AuthenticationFlowContext context, SerializedBrokeredIdentityContext serializedCtx, + BrokeredIdentityContext brokerContext) { + + // get user by federated identity - IdentityBrokerService method authenticated + KeycloakSession session = context.getSession(); + FederatedIdentityModel federatedIdentityModel = new FederatedIdentityModel(brokerContext.getIdpConfig().getAlias(), brokerContext.getId(), + brokerContext.getUsername(), brokerContext.getToken()); + + RealmModel realm = context.getRealm(); + + UserModel federatedUser = session.users().getUserByFederatedIdentity(federatedIdentityModel, realm); + context.setUser(federatedUser); + + if (isUserCreated(context.getUser())) { + redirectToAfterFirstBrokerLoginSuccess(context, brokerContext); + } else { + redirectToAction(context); + } + } + + private void redirectToAction(AuthenticationFlowContext context) { + String accessCode = context.generateAccessCode(); + URI action = context.getActionUrl(accessCode); + String templatedHTML = getTemplateHTML(action); + + Response challengeResponse = Response + .status(Response.Status.OK) + .type(MediaType.TEXT_HTML_UTF_8) + .language(Locale.ENGLISH) + .entity(templatedHTML) + .build(); + context.challenge(challengeResponse); + } + + /** + * redirects user + * @param context + * @param brokerContext + */ + private void redirectToAfterFirstBrokerLoginSuccess(AuthenticationFlowContext context, BrokeredIdentityContext brokerContext) { + + AuthenticationSessionModel authSession = context.getAuthenticationSession(); + + SerializedBrokeredIdentityContext serializedCtx = SerializedBrokeredIdentityContext.serialize(brokerContext); + serializedCtx.saveToAuthenticationSession(authSession, PostBrokerLoginConstants.PBL_BROKERED_IDENTITY_CONTEXT); + + // sets AFTER_FIRST_BROKER_LOGIN to true + authSession.setAuthNote(PostBrokerLoginConstants.PBL_AFTER_FIRST_BROKER_LOGIN, String.valueOf(true)); + + String authStateNoteKey = PostBrokerLoginConstants.PBL_AUTH_STATE_PREFIX + brokerContext.getIdpConfig().getAlias(); + authSession.setAuthNote(authStateNoteKey, "true"); + + RealmModel realm = context.getRealm(); + ClientModel authSessionClientModel = authSession.getClient(); + URI baseUri = context.getUriInfo().getBaseUri(); + + URI redirect = Urls.identityProviderAfterPostBrokerLogin(baseUri, realm.getName(), context.generateAccessCode(), authSessionClientModel.getClientId(), authSession.getTabId()); + Response challengeResponse = Response.status(302) + .location(redirect) + .build(); + context.challenge(challengeResponse); + } + + private String getTemplateHTML(URI actionURI) { + return "" + + "" + + "Red Hat Managed Integrations" + + "" + + "

Your account is being provisioned

" + + "

Please wait for a moment...

"; } } diff --git a/target/authdelay/index.jsp b/target/authdelay/index.jsp index c38169b..ce046b5 100644 --- a/target/authdelay/index.jsp +++ b/target/authdelay/index.jsp @@ -1,5 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + +Insert title here + -

Hello World!

+ - + \ No newline at end of file diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties index c8641d8..0c3cfb0 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties +++ b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Mon Apr 06 17:00:20 IST 2020 +#Tue Apr 07 12:44:04 IST 2020 version=0.0.1-SNAPSHOT groupId=org.keycloak.plugin.rhmi m2e.projectName=authdelay diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml index 8516787..71e0802 100644 --- a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml +++ b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml @@ -3,10 +3,10 @@ 4.0.0 org.keycloak.plugin.rhmi authdelay - war - 0.0.1-SNAPSHOT - authdelay Maven Webapp - http://maven.apache.org + war + 0.0.1-SNAPSHOT + authdelay Maven Webapp + junit @@ -40,5 +40,17 @@ authdelay + + + maven-war-plugin + 2.4 + + false + + + + + + diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index 1c568b3..3ce15c3 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Mon Apr 06 15:49:33 IST 2020 +#Tue Apr 07 12:44:24 IST 2020 version=0.0.1-SNAPSHOT groupId=org.keycloak.plugin.rhmi artifactId=authdelay diff --git a/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml b/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml index f1abe79..02d3942 100644 --- a/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml +++ b/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml @@ -1,5 +1,5 @@ - + @@ -25,7 +25,7 @@ "/> - + @@ -60,5 +60,5 @@ - + \ No newline at end of file diff --git a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt index 1ab31de..fc5e816 100644 --- a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt +++ b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.keycloak.plugin.rhmi.AppTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec From 2c522beac55df24085ee561e44d4278a8474b5db Mon Sep 17 00:00:00 2001 From: jjaferson Date: Thu, 9 Apr 2020 12:10:45 +0100 Subject: [PATCH 7/9] add readme --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..eba5806 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# KeyCloak Delay Authentication Flow + +Plugin to delay authentication of users until they get created in Keycloak and added in 3scale by RHMI operator. + +# System Requirements + +You need to have Keycloak 3.2.0.Final running. + +All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.1.1 or later. + +# Build and Deploy + +### Build the plugin + +To build the plugin you need to first intall the dependencies: + +`$ mvn install` + +and then gerenate the `.jar` file: + +`$ mvn package` + +Once the plugin is built you should be able to find the .jar file in `./target/.jar`. + +### Install Keycloak locally using Docker Compose + +There is a `docker-compose.yaml` file available in the root of the project that can be used to install Keycloak locally with Maria DB and deploy the plugin. + +Steps to install Keycloak locally: + +1) Open the terminal and navigate to the root of the project. +2) Run ```docker-compose up```. +3) When keycloak finishes the install open http://0.0.0.0:8080/ in a browser and it you should be able to see keycloak login screen. +4) Admin credentials for Keycloak are set in the docker-compose.yaml file `KEYCLOAK_USER=admin-test` and `KEYCLOAK_PASSWORD=admin-test`. + +### Deploy the plugin + +To deploy the plugin you need to copy the `.jar` file to `/opt/jboss/keycloak/providers` in Keycloak. + +PS.: this directory is mapped in the docker-compose.yaml file available in the repo, just create a `./plugin` directory in the root of the project and add the `.jar` file there. From a2a138ac1e2008441042244f5a1d5279ce7a7eb5 Mon Sep 17 00:00:00 2001 From: jjaferson Date: Thu, 9 Apr 2020 12:29:33 +0100 Subject: [PATCH 8/9] code refactoring and clean up --- .../plugin/rhmi/DelayAuthentication.java | 19 +++--- .../org/keycloak/plugin/rhmi/AppTest.java | 38 ----------- .../TEST-org.keycloak.plugin.rhmi.AppTest.xml | 64 ------------------- .../org.keycloak.plugin.rhmi.AppTest.txt | 4 -- 4 files changed, 11 insertions(+), 114 deletions(-) delete mode 100644 src/test/java/org/keycloak/plugin/rhmi/AppTest.java delete mode 100644 target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml delete mode 100644 target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt diff --git a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java index c5c6482..7675c33 100644 --- a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java +++ b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java @@ -26,8 +26,8 @@ public class DelayAuthentication extends AbstractIdpAuthenticator implements Authenticator { - private final String USER_CREATED_ATTRIBUTE = "3scale_user_created"; - private final String USER_CREATED_VALUE = "true"; + private static final String USER_CREATED_ATTRIBUTE = "3scale_user_created"; + private static final String USER_CREATED_VALUE = "true"; private static final Logger logger = Logger.getLogger(DelayAuthentication.class); @@ -35,7 +35,7 @@ public void close() { } /** - * checks whether user has been created in other products + * checks whether user has been created in keycloak and received creation attribute * and received the created attribute set to true * @param user * @return @@ -43,18 +43,21 @@ public void close() { private boolean isUserCreated(UserModel user) { if (user == null) { - logger.info("user model is null"); + logger.debug("User is null"); return false; } - String userCreatedAtt = user.getFirstAttribute(this.USER_CREATED_ATTRIBUTE); + String userCreatedAtt = user.getFirstAttribute(DelayAuthentication.USER_CREATED_ATTRIBUTE); if (userCreatedAtt == null) { - logger.info("user created attribute is null"); + logger.debugf("User is created but %s attribute in keycloak is null", DelayAuthentication.USER_CREATED_ATTRIBUTE); return false; } - if (!userCreatedAtt.equals(this.USER_CREATED_VALUE)) { - logger.infof("user created attribute value is different than %s", this.USER_CREATED_VALUE); + if (!userCreatedAtt.equals(DelayAuthentication.USER_CREATED_VALUE)) { + logger.debugf("%s attribute value in keycloak is not equals to %s", + DelayAuthentication.USER_CREATED_ATTRIBUTE, + DelayAuthentication.USER_CREATED_VALUE + ); return false; } diff --git a/src/test/java/org/keycloak/plugin/rhmi/AppTest.java b/src/test/java/org/keycloak/plugin/rhmi/AppTest.java deleted file mode 100644 index 2cb3e1a..0000000 --- a/src/test/java/org/keycloak/plugin/rhmi/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.keycloak.plugin.rhmi; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml b/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml deleted file mode 100644 index 02d3942..0000000 --- a/target/surefire-reports/TEST-org.keycloak.plugin.rhmi.AppTest.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt b/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt deleted file mode 100644 index fc5e816..0000000 --- a/target/surefire-reports/org.keycloak.plugin.rhmi.AppTest.txt +++ /dev/null @@ -1,4 +0,0 @@ -------------------------------------------------------------------------------- -Test set: org.keycloak.plugin.rhmi.AppTest -------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec From 42d12113bf1822a7959beb50ee0fbdf706094148 Mon Sep 17 00:00:00 2001 From: jjaferson Date: Thu, 9 Apr 2020 12:31:30 +0100 Subject: [PATCH 9/9] add fixes from PR review --- .classpath | 7 --- .gitignore | 9 +-- .project | 37 ------------ .settings/.jsdtscope | 17 ------ .settings/org.eclipse.jdt.core.prefs | 25 --------- .settings/org.eclipse.m2e.core.prefs | 4 -- .settings/org.eclipse.wst.common.component | 1 - ....eclipse.wst.common.project.facet.core.xml | 12 ---- ...rg.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - .settings/org.eclipse.wst.validation.prefs | 2 - README.md | 6 +- docker-compose.yaml | 36 ++++++++++++ pom.xml | 15 ++--- .../plugin/rhmi/DelayAuthentication.java | 6 +- ...layAuthenticationAuthenticatorFactory.java | 15 +---- src/main/webapp/WEB-INF/web.xml | 7 --- src/main/webapp/index.jsp | 12 ---- .../WEB-INF/classes/AuthenticationDelay.java | 4 -- target/authdelay/WEB-INF/web.xml | 7 --- target/authdelay/index.jsp | 12 ---- target/m2e-wtp/web-resources/.gitignore | 1 - .../web-resources/META-INF/MANIFEST.MF | 5 -- .../authdelay/pom.properties | 7 --- .../authdelay/pom.xml | 56 ------------------- target/maven-archiver/pom.properties | 5 -- .../compile/default-compile/createdFiles.lst | 0 .../compile/default-compile/inputFiles.lst | 2 - .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 - 30 files changed, 56 insertions(+), 257 deletions(-) delete mode 100644 .project delete mode 100644 .settings/.jsdtscope delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.m2e.core.prefs delete mode 100644 .settings/org.eclipse.wst.common.component delete mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 .settings/org.eclipse.wst.validation.prefs create mode 100644 docker-compose.yaml delete mode 100644 src/main/webapp/WEB-INF/web.xml delete mode 100644 src/main/webapp/index.jsp delete mode 100644 target/authdelay/WEB-INF/classes/AuthenticationDelay.java delete mode 100644 target/authdelay/WEB-INF/web.xml delete mode 100644 target/authdelay/index.jsp delete mode 100644 target/m2e-wtp/web-resources/.gitignore delete mode 100644 target/m2e-wtp/web-resources/META-INF/MANIFEST.MF delete mode 100644 target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties delete mode 100644 target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml delete mode 100644 target/maven-archiver/pom.properties delete mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst delete mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/.classpath b/.classpath index ccdc887..644a6fe 100644 --- a/.classpath +++ b/.classpath @@ -10,13 +10,6 @@
- - - - - - - diff --git a/.gitignore b/.gitignore index e540645..2d79ada 100644 --- a/.gitignore +++ b/.gitignore @@ -21,10 +21,11 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* -<<<<<<< HEAD # MacOS files .DS_Store -======= -/target/ ->>>>>>> add maven web project structure + +/target/* +/plugin/* +.settings/* +.project \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index 8a6b712..0000000 --- a/.project +++ /dev/null @@ -1,37 +0,0 @@ - - - authdelay - - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope deleted file mode 100644 index 0102067..0000000 --- a/.settings/.jsdtscope +++ /dev/null @@ -1,17 +0,0 @@ - - -<<<<<<< HEAD - -======= - - ->>>>>>> add maven web project structure - - - - - - - - - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a27a619..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,25 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -<<<<<<< HEAD -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -======= -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 ->>>>>>> add maven web project structure -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -<<<<<<< HEAD -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -======= -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore ->>>>>>> add maven web project structure -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component deleted file mode 100644 index bcc91bc..0000000 --- a/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 2d7b456..0000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,12 +0,0 @@ - - -<<<<<<< HEAD - - -======= - - - ->>>>>>> add maven web project structure - - diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a..0000000 --- a/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b..0000000 --- a/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 04cad8c..0000000 --- a/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,2 +0,0 @@ -disabled=06target -eclipse.preferences.version=1 diff --git a/README.md b/README.md index eba5806..da18f8e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Plugin to delay authentication of users until they get created in Keycloak and a # System Requirements -You need to have Keycloak 3.2.0.Final running. +You need to have Keycloak 9.0.2 running. All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.1.1 or later. @@ -20,7 +20,7 @@ and then gerenate the `.jar` file: `$ mvn package` -Once the plugin is built you should be able to find the .jar file in `./target/.jar`. +Once the plugin is built you should be able to find the .jar file in `./plugins/.jar`. ### Install Keycloak locally using Docker Compose @@ -37,4 +37,4 @@ Steps to install Keycloak locally: To deploy the plugin you need to copy the `.jar` file to `/opt/jboss/keycloak/providers` in Keycloak. -PS.: this directory is mapped in the docker-compose.yaml file available in the repo, just create a `./plugin` directory in the root of the project and add the `.jar` file there. +PS.: this directory is mapped in the docker-compose.yaml file available in the repo. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..e7f50f9 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,36 @@ +version: '3.7' +services: + keycloak: + image: 'jboss/keycloak' + ports: + - "8080:8080" + environment: + - KEYCLOAK_USER=admin-test + - KEYCLOAK_PASSWORD=admin-test + - JDBC_PARAMS='connectTimeout=30' + - DB_VENDOR=mariadb + - DB_ADDR=mariadb + - DB_DATABASE=keycloak + - DB_USER=keycloak + - DB_PASSWORD=password + - JGROUPS_DISCOVERY_PROTOCOL=JDBC_PING + - JGROUPS_DISCOVERY_PROPERTIES=datasource_jndi_name=java:jboss/datasources/KeycloakDS,info_writer_sleep_time=500 + volumes: + - ./plugins:/opt/jboss/keycloak/providers + depends_on: + - mariadb + mariadb: + image: mariadb + volumes: + - data:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: keycloak + MYSQL_USER: keycloak + MYSQL_PASSWORD: password + # Copy-pasted from https://github.com/docker-library/mariadb/issues/94 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "--silent"] +volumes: + data: + driver: local \ No newline at end of file diff --git a/pom.xml b/pom.xml index fec64c6..40798d3 100644 --- a/pom.xml +++ b/pom.xml @@ -41,13 +41,14 @@ authdelay - - maven-war-plugin - 2.4 - - false - - + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + ./plugins/ + + diff --git a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java index 7675c33..c95157c 100644 --- a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java +++ b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java @@ -85,7 +85,7 @@ protected void authenticateImpl(AuthenticationFlowContext context, SerializedBro if (isUserCreated(context.getUser())) { redirectToAfterFirstBrokerLoginSuccess(context, brokerContext); } else { - redirectToAction(context); + showAccountProvisioningPage(context); } } @@ -106,11 +106,11 @@ protected void actionImpl(AuthenticationFlowContext context, SerializedBrokeredI if (isUserCreated(context.getUser())) { redirectToAfterFirstBrokerLoginSuccess(context, brokerContext); } else { - redirectToAction(context); + showAccountProvisioningPage(context); } } - private void redirectToAction(AuthenticationFlowContext context) { + private void showAccountProvisioningPage(AuthenticationFlowContext context) { String accessCode = context.generateAccessCode(); URI action = context.getActionUrl(accessCode); String templatedHTML = getTemplateHTML(action); diff --git a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java index def8ee0..b4db2f0 100644 --- a/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java +++ b/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java @@ -20,33 +20,24 @@ public Authenticator create(KeycloakSession session) { return SINGLETON; } - public void init(Scope config) { - // TODO Auto-generated method stub - + public void init(Scope config) { } public void postInit(KeycloakSessionFactory factory) { - // TODO Auto-generated method stub - } public void close() { - // TODO Auto-generated method stub - } public String getId() { - // TODO Auto-generated method stub return "delay-authentication"; } public String getDisplayType() { - // TODO Auto-generated method stub return "Delay Authentication"; } public String getReferenceCategory() { - // TODO Auto-generated method stub return "Delay Authentication"; } @@ -58,7 +49,6 @@ public boolean isConfigurable() { } public Requirement[] getRequirementChoices() { - // TODO Auto-generated method stub Requirement[] req = { AuthenticationExecutionModel.Requirement.REQUIRED }; @@ -66,17 +56,14 @@ public Requirement[] getRequirementChoices() { } public boolean isUserSetupAllowed() { - // TODO Auto-generated method stub return false; } public String getHelpText() { - // TODO Auto-generated method stub return "Delay authentication until user is created on 3scale by the rhmi operator"; } public List getConfigProperties() { - // TODO Auto-generated method stub return null; } diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 9f88c1f..0000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Archetype Created Web Application - diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp deleted file mode 100644 index ce046b5..0000000 --- a/src/main/webapp/index.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - - - - -Insert title here - - - - - \ No newline at end of file diff --git a/target/authdelay/WEB-INF/classes/AuthenticationDelay.java b/target/authdelay/WEB-INF/classes/AuthenticationDelay.java deleted file mode 100644 index 9cdaffb..0000000 --- a/target/authdelay/WEB-INF/classes/AuthenticationDelay.java +++ /dev/null @@ -1,4 +0,0 @@ - -public class AuthenticationDelay { - -} diff --git a/target/authdelay/WEB-INF/web.xml b/target/authdelay/WEB-INF/web.xml deleted file mode 100644 index 9f88c1f..0000000 --- a/target/authdelay/WEB-INF/web.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Archetype Created Web Application - diff --git a/target/authdelay/index.jsp b/target/authdelay/index.jsp deleted file mode 100644 index ce046b5..0000000 --- a/target/authdelay/index.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - - - - -Insert title here - - - - - \ No newline at end of file diff --git a/target/m2e-wtp/web-resources/.gitignore b/target/m2e-wtp/web-resources/.gitignore deleted file mode 100644 index 3385916..0000000 --- a/target/m2e-wtp/web-resources/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/META-INF/ diff --git a/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF b/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF deleted file mode 100644 index fb1c398..0000000 --- a/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Built-By: jose.silva -Build-Jdk: 1.8.0_242 -Created-By: Maven Integration for Eclipse - diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties deleted file mode 100644 index 0c3cfb0..0000000 --- a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Generated by Maven Integration for Eclipse -#Tue Apr 07 12:44:04 IST 2020 -version=0.0.1-SNAPSHOT -groupId=org.keycloak.plugin.rhmi -m2e.projectName=authdelay -m2e.projectLocation=/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay -artifactId=authdelay diff --git a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml b/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml deleted file mode 100644 index 71e0802..0000000 --- a/target/m2e-wtp/web-resources/META-INF/maven/org.keycloak.plugin.rhmi/authdelay/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - 4.0.0 - org.keycloak.plugin.rhmi - authdelay - war - 0.0.1-SNAPSHOT - authdelay Maven Webapp - - - - junit - junit - 3.8.1 - test - - - org.keycloak - keycloak-server-spi - provided - 9.0.2 - - - org.keycloak - keycloak-server-spi-private - 9.0.2 - provided - - - org.keycloak - keycloak-services - 9.0.2 - - - com.google.guava - guava - - - - - - authdelay - - - maven-war-plugin - 2.4 - - false - - - - - - - - diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties deleted file mode 100644 index 3ce15c3..0000000 --- a/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Tue Apr 07 12:44:24 IST 2020 -version=0.0.1-SNAPSHOT -groupId=org.keycloak.plugin.rhmi -artifactId=authdelay diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index e69de29..0000000 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 6014135..0000000 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,2 +0,0 @@ -/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay/src/main/java/org/keycloak/plugin/rhmi/DelayAuthenticationAuthenticatorFactory.java -/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay/src/main/java/org/keycloak/plugin/rhmi/DelayAuthentication.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst deleted file mode 100644 index e69de29..0000000 diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index 713d376..0000000 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ /dev/null @@ -1 +0,0 @@ -/home/jose.silva/go/src/github.com/integr8ly/authentication-delay-plugin/authdelay/authdelay/src/test/java/org/keycloak/plugin/rhmi/AppTest.java