From 6761e9a945f7d3b34016e7f041e2004d92168e34 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 4 Sep 2014 18:03:19 -0400 Subject: [PATCH 1/5] Starting to rework the oauth2 filter --- .../java/example/ExampleRestfulServlet.java | 31 +- .../main/java/example/ServletExamples.java | 37 ++ hapi-fhir-base/pom.xml | 1 - .../java/ca/uhn/fhir/util/PortUtil.java} | 7 +- hapi-fhir-base/src/site/resources/hapi.css | 4 +- .../resources/images/github-logo-mini.png | Bin 0 -> 1242 bytes .../site/resources/images/maven-logo-mini.png | Bin 0 -> 2069 bytes hapi-fhir-base/src/site/site.xml | 8 +- hapi-fhir-base/src/site/xdoc/doc_logging.xml | 10 + .../site/xdoc/doc_rest_server_interceptor.xml | 15 + .../rest/client/ClientIntegrationTest.java | 4 +- .../uhn/fhir/rest/client/InterceptorTest.java | 4 +- .../ca/uhn/fhir/rest/server/BinaryTest.java | 4 +- .../rest/server/CompositeParameterTest.java | 4 +- .../uhn/fhir/rest/server/CompressionTest.java | 4 +- .../ca/uhn/fhir/rest/server/CorsTest.java | 4 +- .../ca/uhn/fhir/rest/server/CreateTest.java | 4 +- .../uhn/fhir/rest/server/CustomTypeTest.java | 4 +- .../uhn/fhir/rest/server/ExceptionTest.java | 4 +- .../ca/uhn/fhir/rest/server/HistoryTest.java | 4 +- .../ca/uhn/fhir/rest/server/IncludeTest.java | 4 +- .../uhn/fhir/rest/server/InterceptorTest.java | 4 +- .../fhir/rest/server/MethodPriorityTest.java | 4 +- .../ca/uhn/fhir/rest/server/PagingTest.java | 4 +- .../fhir/rest/server/PlainProviderTest.java | 4 +- .../ca/uhn/fhir/rest/server/ReadTest.java | 4 +- .../rest/server/ReferenceParameterTest.java | 4 +- .../rest/server/ResfulServerMethodTest.java | 4 +- .../server/ResfulServerSelfReferenceTest.java | 6 +- .../ResourceProviderWithNoMethodsTest.java | 6 +- .../ca/uhn/fhir/rest/server/SearchTest.java | 4 +- .../uhn/fhir/rest/server/ServerBaseTest.java | 8 +- .../server/ServerExtraParametersTest.java | 4 +- .../fhir/rest/server/ServerFeaturesTest.java | 4 +- .../ca/uhn/fhir/rest/server/SortTest.java | 4 +- .../fhir/rest/server/StringParameterTest.java | 4 +- .../uhn/fhir/rest/server/TagsServerTest.java | 4 +- .../uhn/fhir/rest/server/TransactionTest.java | 4 +- .../TransactionWithBundleParamTest.java | 4 +- .../ca/uhn/fhir/rest/server/UpdateTest.java | 4 +- .../interceptor/LoggingInterceptorTest.java | 4 +- .../src/test/resources/logback-test.xml | 3 + hapi-fhir-jpaserver-base/pom.xml | 2 +- .../ca/uhn/fhirtest/TestRestfulServer.java | 2 +- hapi-fhir-mitreid-integration/pom.xml | 528 ------------------ .../.classpath | 1 + .../.gitignore | 0 .../.project | 2 +- .../org.eclipse.core.resources.prefs | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 hapi-fhir-oauth2/pom.xml | 151 +++++ ...IdConnectBearerTokenServerInterceptor.java | 50 +- .../server/security/DummyOpenIdServlet.java | 34 ++ ...TokenServerInterceptorIntegrationTest.java | 159 ++++++ ...nnectBearerTokenServerInterceptorTest.java | 43 +- .../RestAuthenticationEntryPoint.java | 0 .../src/test/resources/logback-test.xml | 24 + .../src/test/resources/svr_keystore.jwks | 0 .../java/ca/uhn/fhir/to/TesterConfig.java | 19 +- pom.xml | 9 +- restful-server-example-test/pom.xml | 2 +- .../test/java/ca/uhn/example/ExampleTest.java | 11 +- restful-server-example/pom.xml | 4 +- 64 files changed, 630 insertions(+), 659 deletions(-) create mode 100644 hapi-fhir-base/examples/src/main/java/example/ServletExamples.java rename hapi-fhir-base/src/{test/java/ca/uhn/fhir/testutil/RandomServerPortProvider.java => main/java/ca/uhn/fhir/util/PortUtil.java} (73%) create mode 100644 hapi-fhir-base/src/site/resources/images/github-logo-mini.png create mode 100644 hapi-fhir-base/src/site/resources/images/maven-logo-mini.png delete mode 100644 hapi-fhir-mitreid-integration/pom.xml rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/.classpath (94%) rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/.gitignore (100%) rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/.project (92%) rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/.settings/org.eclipse.core.resources.prefs (100%) rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/.settings/org.eclipse.jdt.core.prefs (100%) rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/.settings/org.eclipse.m2e.core.prefs (100%) create mode 100644 hapi-fhir-oauth2/pom.xml rename hapi-fhir-mitreid-integration/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManager.java => hapi-fhir-oauth2/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptor.java (79%) create mode 100644 hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/DummyOpenIdServlet.java create mode 100644 hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorIntegrationTest.java rename hapi-fhir-mitreid-integration/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManagerTest.java => hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorTest.java (64%) rename {hapi-fhir-mitreid-integration => hapi-fhir-oauth2}/src/test/java/ca/uhn/fhir/rest/server/security/RestAuthenticationEntryPoint.java (100%) create mode 100644 hapi-fhir-oauth2/src/test/resources/logback-test.xml rename {hapi-fhir-base => hapi-fhir-oauth2}/src/test/resources/svr_keystore.jwks (100%) diff --git a/hapi-fhir-base/examples/src/main/java/example/ExampleRestfulServlet.java b/hapi-fhir-base/examples/src/main/java/example/ExampleRestfulServlet.java index a2d94a4e103..34bd915a86d 100644 --- a/hapi-fhir-base/examples/src/main/java/example/ExampleRestfulServlet.java +++ b/hapi-fhir-base/examples/src/main/java/example/ExampleRestfulServlet.java @@ -3,6 +3,7 @@ package example; import java.util.ArrayList; import java.util.List; +import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import ca.uhn.fhir.rest.server.IResourceProvider; @@ -20,19 +21,25 @@ public class ExampleRestfulServlet extends RestfulServer { private static final long serialVersionUID = 1L; /** - * Constructor + * The initialize method is automatically called when the servlet is starting up, so it can + * be used to configure the servlet to define resource providers, or set up + * configuration, interceptors, etc. */ - public ExampleRestfulServlet() { - /* - * The servlet defines any number of resource providers, and - * configures itself to use them by calling - * setResourceProviders() - */ - List resourceProviders = new ArrayList(); - resourceProviders.add(new RestfulPatientResourceProvider()); - resourceProviders.add(new RestfulObservationResourceProvider()); - setResourceProviders(resourceProviders); - } + @Override + protected void initialize() throws ServletException { + /* + * The servlet defines any number of resource providers, and + * configures itself to use them by calling + * setResourceProviders() + */ + List resourceProviders = new ArrayList(); + resourceProviders.add(new RestfulPatientResourceProvider()); + resourceProviders.add(new RestfulObservationResourceProvider()); + setResourceProviders(resourceProviders); + } } //END SNIPPET: servlet + + + diff --git a/hapi-fhir-base/examples/src/main/java/example/ServletExamples.java b/hapi-fhir-base/examples/src/main/java/example/ServletExamples.java new file mode 100644 index 00000000000..2c30ff66a6a --- /dev/null +++ b/hapi-fhir-base/examples/src/main/java/example/ServletExamples.java @@ -0,0 +1,37 @@ +package example; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; + +import ca.uhn.fhir.rest.server.RestfulServer; +import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; + +@SuppressWarnings("serial") +public class ServletExamples { + + // START SNIPPET: loggingInterceptor + @WebServlet(urlPatterns = { "/fhir/*" }, displayName = "FHIR Server") + public class RestfulServerWithLogging extends RestfulServer { + + @Override + protected void initialize() throws ServletException { + + // ... define your resource providers here ... + + // Now register the logging interceptor + LoggingInterceptor loggingInterceptor = new LoggingInterceptor(); + registerInterceptor(loggingInterceptor); + + // The SLF4j logger "test.accesslog" will receive the logging events + loggingInterceptor.setLoggerName("test.accesslog"); + + // This is the format for each line. A number of substitution variables may + // be used here. See the JavaDoc for LoggingInterceptor for information on + // what is available. + loggingInterceptor.setMessageFormat("Source[${remoteAddr}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}]"); + + } + + } + // END SNIPPET: loggingInterceptor +} diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index c1fafffc7f9..b6fcf2be5e3 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -521,7 +521,6 @@ maven-site-plugin - ${maven_site_plugin_version} stage-for-scm-publish diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/testutil/RandomServerPortProvider.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java similarity index 73% rename from hapi-fhir-base/src/test/java/ca/uhn/fhir/testutil/RandomServerPortProvider.java rename to hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java index 7c9f8ceec55..b35bf434741 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/testutil/RandomServerPortProvider.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.testutil; +package ca.uhn.fhir.util; import java.io.IOException; import java.net.ServerSocket; @@ -8,10 +8,13 @@ import java.util.List; /** * Provides server ports */ -public class RandomServerPortProvider { +public class PortUtil { private static List ourPorts = new ArrayList(); + /** + * This is really only used for unit tests but is included in the library so it can be reused across modules. Use with caution. + */ public static int findFreePort() { ServerSocket server; try { diff --git a/hapi-fhir-base/src/site/resources/hapi.css b/hapi-fhir-base/src/site/resources/hapi.css index 8d397cbb201..6965ce9238a 100644 --- a/hapi-fhir-base/src/site/resources/hapi.css +++ b/hapi-fhir-base/src/site/resources/hapi.css @@ -86,12 +86,12 @@ } tt { - margin-left: 10px; white-space: pre; color: #448; - padding: 4px; margin-bottom: 5px; margin-top: 10px; + padding: 2px; + border: 1px solid #AAA; } h1,h2,h3,h4,h5 { diff --git a/hapi-fhir-base/src/site/resources/images/github-logo-mini.png b/hapi-fhir-base/src/site/resources/images/github-logo-mini.png new file mode 100644 index 0000000000000000000000000000000000000000..815160af4cbc5b561b9179a22b6597de94e42297 GIT binary patch literal 1242 zcmV<01SR{4P)D(dyODKoHZ6A zO0=jzY?nW>1!tpl8EDrj=1 zJ-EQF$mn#RzVzG)LTIAfR42PHt=FMjMvX=dc7yL7RF1ABqBC3uI;=TSw2BGNH!oR# z=my`7BrW3o)aE^pSZTnsNksowgf3JCx~(bDD{h5|e$U%zI4$%-MU|MWG#c{9v0N0@ zC=sJqKd4Y47C4ZW$%yZ%QIk3ce5=!7R_Lrm^@UIWp-1O>!FYil*Qv4GqC|eWcCkIK zE~>zCwJWjOOs6W9m-D7I(NCf2iE^i2BI;Ea zU6|9YT9XQNt8$&2ipVsgL}_XtSmk;_LTd7;OwG{(rX-T-n!z_kR^={ARvA;=qSCFQ znnd(-;^<+Q7)k^FkY`49XmFHF&NAy*5`F|6G@vpmqsz62N>jxMfywHN%uhPx_-6f@ zoezGq!GK@%sQr(m3h4KujsCRAJ*rV{X=pf6mK~FeHf?T92>xi5uB=EhkRhipO>vdF ze@U>%bH2t`&bA!P4fU!-p*He9G9+XEaYZGzMw>#DT~*i&ZO9apj^LrtRws*eM45DdBr0)gHAlGtlhS!OI&RZ- z8gi-yiDY*u=P9jf5IE1d2E@Xo(8tD4`jugtSL~FtTK=d}+wa$8y+VT?b2N=%SK}o+ zbeU}~81!L?cRb*J6B1XW$IV!^_@!OW1hdVy*P{lHmNo-EuozUPuf)iFU-U$Gd(nI-hl~ z9|DrHth2yE%}!RP-(DTI_)IVAtx$nJugPUaWSnEARugpF>PdN5sT0e4+pcuXG`mzF z@SE54q284in##GCD9aIxsUWFf=+aFwBBa{r~^~07*qoM6N<$ Ef+CbTng9R* literal 0 HcmV?d00001 diff --git a/hapi-fhir-base/src/site/resources/images/maven-logo-mini.png b/hapi-fhir-base/src/site/resources/images/maven-logo-mini.png new file mode 100644 index 0000000000000000000000000000000000000000..aa47bd5226e750263b0ac8dcb0957aaf2519b9f9 GIT binary patch literal 2069 zcmV+w2004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x2P{cMK~!ko?b>UMT~!qa@ZX)zbXo=}1%W~-^d%Hqe4z$o z&{#B@5Rnf}@D-I}NYNN2#3x^TMH59tjj_=f6HPV5NYth(!Qg{n5DY49p%3T?6BEyj76g@0iqMzg+sSb}qL93H{F*#EyVU4!Ys3Ah>Cvg6yBhc9D? zAi+5HU@cyn?mY`P2(pafF!tfsf+P*55xtBQOYvu%o}If%M2^e4^l#&f_yxX;i;gnx z&#)Q?D>tv{e_mhT`rddCP4NGLUXtQstjFx^+&;{io5uy)6 zc!@|k{UXYY;As(cwANOL(N`P)$Ry8xK7EHo+8h#5@M%2t9Ama>W46=plhQZ`McSS0 z-HsX0!=0uL=Lo%!V-Eg~Taw}4BhpNP1?ku!Qbil@#c8!M=F3Qd8F(MwfrTOs<)qk$ zt@t@^Zm;P-n20e0*WiLQ&Jo;*yKC<~fKT8xsXZ=IVcu^AR^iPe{T-K{{TTj;@27XD zkNa7?BDD|UYw5dJ54bXY*Z|JNCAB_V@Il;_ox7&i zr|z+HaIMm~b(|qY?c3Au8w3H4;B34*>wBk8Qe1@Vlu_}YsZC84y&}b6_Mrv#;!8?n9u^*u;}E`~N{Gj5 zeMUt{&T(ck*nL9K?oR#Y;`KtDw!{QpiFMc|Jo2CEZ$aRtwXu&E6J8KvFTNtu+)R81 zpH@~`JB5}S5uRQU^;P&BKA_Y?3sj@varh{n#lJZGV>{5{8eAQHV zH`b(YgbgAJ%}ecrUW9d;UXfz4ss|jxrdpqF#JN{hVV|TlXo2lw0t!O3aFO=thw+9q z=4>G%36ISUzb74edpLW}X*eaF|BzB#9ukwjJ+&{$t`)Yu4xh}<_0``0NE(MA{POJD zVf;`@2qKaWW$oQM)9IAaD^e`0J!_w+C~_>(Nu0VmpD#jvjx8oiwswow<@l!3n}~dV zAoUxnJ?8;cO>zMDixQgf@-xIFU8N+{ZTM++-|K`1C@@oXlDlC<83|8T)h|!tFSY(l zRY|d3r=FTJdO?alL5du^l{vh?xk_&)h*K}Oo`X28#rT4f5c@@`xLydtwh)3>WMgbL zb9}7!oXtwHIhfx6ok|_@lqePVW%n$qjq!W2RDU$I@n|}T>LMrd!$Mrs>Hb%FU#7$!{?QTn}=6s*AHW(u>oZiM?{JP z!t+~rzp5AiL{tSggQxPB75oG2niksi-e>KKCTBUyW*oEH;7WOzzDXs)*h-2J0Ug;T&S#!?ibOg z?x7FV+LsHBF__+cmZ+RoiYRlv>gsM?WNuW|QzzGKv^Uvt+R=+haaQ`E0&QW~9H;6e z&Q>p+I3u;|mnc)m`65!}qsd~hyPOn<1Q$W^5=4m=t2IgLfIVU|atz|HS$j-%`Ikroo0KJBF>a1~MA>+?@Vpr!z1)T$ zi`B%O6u0VccjS)rt{cSKLxDs1j?QS5-*c0Qf~!QznJ2Wss1T>aVz1{eQEnF)5c?rT z_41HTk@<|+t10kHp^2s)z1SrkR3+aLvFMVoG7co;6=;{1+A$wk!RaH*Np`03~!qSaf7z zbY(hYa%Ew3WdJfTF*GeOIV~_WR53C-Fg7|fFfA}NIxsK`Q%Xhv001R)MObuXVRU6W zZEs|0W_bWIFflYOFgYzSG*mG%IxsdmGBqtQG&(Ra HAPI images/hapi_fhir_banner.png - http://hl7api.sourceforge.net/hapi-fhir/ + http://jamesagnew.github.io/hapi-fhir/ FHIR images/hapi_fhir_banner_right.png - http://hl7api.sourceforge.net/hapi-fhir/ + http://jamesagnew.github.io/hapi-fhir/ - - + + diff --git a/hapi-fhir-base/src/site/xdoc/doc_logging.xml b/hapi-fhir-base/src/site/xdoc/doc_logging.xml index 99e23a85981..386b3e8f84e 100644 --- a/hapi-fhir-base/src/site/xdoc/doc_logging.xml +++ b/hapi-fhir-base/src/site/xdoc/doc_logging.xml @@ -108,6 +108,16 @@

+ +
+ +

+ To enable detailed logging of server requests and responses, + an interceptor may be added to the server which logs each transaction. See + Logging Server Requests for more information. +

+ +
diff --git a/hapi-fhir-base/src/site/xdoc/doc_rest_server_interceptor.xml b/hapi-fhir-base/src/site/xdoc/doc_rest_server_interceptor.xml index b2ff564dd7c..ad7b55e023c 100644 --- a/hapi-fhir-base/src/site/xdoc/doc_rest_server_interceptor.xml +++ b/hapi-fhir-base/src/site/xdoc/doc_rest_server_interceptor.xml @@ -110,6 +110,21 @@ of detail about each incoming request.

+

+ The following example shows how to register a logging interceptor within + a FHIR RESTful server. +

+ + + + + +

+ This interceptor will then produce output similar to the following: +

+ + diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java index e396efd46bf..48cc25202ed 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java @@ -27,7 +27,7 @@ import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.client.api.IBasicClient; import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; public class ClientIntegrationTest { @@ -37,7 +37,7 @@ public class ClientIntegrationTest { @Before public void before() { - myPort = RandomServerPortProvider.findFreePort(); + myPort = PortUtil.findFreePort(); myServer = new Server(myPort); myPatientProvider = new MyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/InterceptorTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/InterceptorTest.java index 457eb426b95..be8a339007a 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/InterceptorTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/client/InterceptorTest.java @@ -25,7 +25,7 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.ResourceBinding; import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.core.Appender; @@ -80,7 +80,7 @@ public class InterceptorTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyProvider patientProvider = new DummyProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java index c85a8bf260f..8d53a9a31d4 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.ResourceParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -122,7 +122,7 @@ public class BinaryTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); ResourceProvider patientProvider = new ResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java index 49ad18a1e67..151f9135600 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java @@ -32,7 +32,7 @@ import ca.uhn.fhir.rest.param.CompositeOrListParam; import ca.uhn.fhir.rest.param.CompositeParam; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.StringParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -100,7 +100,7 @@ public class CompositeParameterTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyObservationResourceProvider patientProvider = new DummyObservationResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java index 9a9cce08331..c90f86cc7bd 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java @@ -30,7 +30,7 @@ import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -101,7 +101,7 @@ public class CompressionTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyProvider patientProvider = new DummyProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java index 2085cb713a7..f2220d4039e 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java @@ -30,7 +30,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.rest.server.ResfulServerSelfReferenceTest.DummyPatientResourceProvider; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -42,7 +42,7 @@ public class CorsTest { @Test public void testContextWithSpace() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); Server server = new Server(port); RestfulServer restServer = new RestfulServer(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java index d0f5ea9479a..0b54a85be29 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -146,7 +146,7 @@ public class CreateTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); PatientProvider patientProvider = new PatientProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java index c7137f350d7..1518b272159 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java @@ -30,7 +30,7 @@ import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.rest.annotation.OptionalParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.param.StringParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -134,7 +134,7 @@ public class CustomTypeTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java index 01a3711ec99..799cf3b9518 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java @@ -33,7 +33,7 @@ import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -131,7 +131,7 @@ public class ExceptionTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java index 9cc4c080974..4f847eeb106 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java @@ -29,7 +29,7 @@ import ca.uhn.fhir.rest.annotation.History; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.Since; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -119,7 +119,7 @@ public class HistoryTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPlainProvider plainProvider = new DummyPlainProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java index 60dff56092a..c2d32b4d800 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java @@ -36,8 +36,8 @@ import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.annotation.IncludeParam; import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.testutil.RandomServerPortProvider; import ca.uhn.fhir.util.ElementUtil; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -225,7 +225,7 @@ public class IncludeTest { public static void beforeClass() throws Exception { ourCtx = new FhirContext(); - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java index 25b6ee5a649..98fd750b3c4 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java @@ -40,7 +40,7 @@ import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.method.RequestDetails; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -95,7 +95,7 @@ public class InterceptorTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java index f67cd305c78..92b5b180f51 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java @@ -28,7 +28,7 @@ import ca.uhn.fhir.rest.annotation.OptionalParam; import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.param.StringParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -68,7 +68,7 @@ public class MethodPriorityTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); ServletHandler proxyHandler = new ServletHandler(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java index 3972043fc1c..014cde64b33 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java @@ -27,7 +27,7 @@ import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -167,7 +167,7 @@ public class PagingTest { public static void beforeClass() throws Exception { ourContext = new FhirContext(); - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java index 05943f75700..26bc6116b23 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java @@ -43,7 +43,7 @@ import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.annotation.Since; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; public class PlainProviderTest { @@ -56,7 +56,7 @@ public class PlainProviderTest { @Before public void before() throws Exception { - myPort = RandomServerPortProvider.findFreePort(); + myPort = PortUtil.findFreePort(); myServer = new Server(myPort); myCtx = new FhirContext(Patient.class); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java index 7694c0ce6ac..e23fb826df5 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java @@ -26,7 +26,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -116,7 +116,7 @@ public class ReadTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyProvider patientProvider = new DummyProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java index 2d06a4706b0..73d6dcfec25 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java @@ -37,7 +37,7 @@ import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -229,7 +229,7 @@ public class ReferenceParameterTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java index 49fbe8dfd4e..5d1cacb7f9f 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java @@ -72,7 +72,7 @@ import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.provider.ServerProfileProvider; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -1001,7 +1001,7 @@ public class ResfulServerMethodTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); ourCtx = new FhirContext(Patient.class); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerSelfReferenceTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerSelfReferenceTest.java index 1c790230741..cefba40d599 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerSelfReferenceTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerSelfReferenceTest.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.server.provider.ServerProfileProvider; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -59,7 +59,7 @@ public class ResfulServerSelfReferenceTest { @Test public void testContextWithSpace() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); Server server = new Server(port); RestfulServer restServer = new RestfulServer(); @@ -102,7 +102,7 @@ public class ResfulServerSelfReferenceTest { @Test public void testSearchByParamIdentifier() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); Server hServer = new Server(port); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java index fc9c3bded75..18a0b82d6bf 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java @@ -15,7 +15,7 @@ import ca.uhn.fhir.model.dstu.resource.Binary; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; public class ResourceProviderWithNoMethodsTest { @@ -28,7 +28,7 @@ public class ResourceProviderWithNoMethodsTest { @Test public void testNoAnnotatedMethods() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); ourServer = new Server(port); ResourceProvider patientProvider = new ResourceProvider(); @@ -50,7 +50,7 @@ public class ResourceProviderWithNoMethodsTest { @Test public void testNonPublicMethod() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); ourServer = new Server(port); NonPublicMethodProvider patientProvider = new NonPublicMethodProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java index dedc3ec6e1d..c79e34559e2 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java @@ -41,7 +41,7 @@ import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.TokenOrListParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -199,7 +199,7 @@ public class SearchTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java index 97d501d7452..1e98cb7b04a 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java @@ -25,7 +25,7 @@ import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -51,7 +51,7 @@ public class ServerBaseTest { @Test public void testWithContextPath() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); myServer = new Server(port); DummyProvider patientProvider = new DummyProvider(); @@ -85,7 +85,7 @@ public class ServerBaseTest { @Test public void testWithContextAndServletPath() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); myServer = new Server(port); DummyProvider patientProvider = new DummyProvider(); @@ -118,7 +118,7 @@ public class ServerBaseTest { @Test public void testWithNoPath() throws Exception { - int port = RandomServerPortProvider.findFreePort(); + int port = PortUtil.findFreePort(); myServer = new Server(port); DummyProvider patientProvider = new DummyProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java index 60136772d6b..ae0d9f27a97 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java @@ -27,7 +27,7 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.gclient.StringClientParam; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; public class ServerExtraParametersTest { @@ -37,7 +37,7 @@ public class ServerExtraParametersTest { @Before public void before() { - myPort = RandomServerPortProvider.findFreePort(); + myPort = PortUtil.findFreePort(); myServer = new Server(myPort); ServletHandler proxyHandler = new ServletHandler(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java index 711228a66e6..b8cd559dd57 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -251,7 +251,7 @@ public class ServerFeaturesTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SortTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SortTest.java index acd35aad358..fe49b53e367 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SortTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/SortTest.java @@ -28,7 +28,7 @@ import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.annotation.Sort; import ca.uhn.fhir.rest.api.SortSpec; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -130,7 +130,7 @@ public class SortTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java index 32bfadc4a03..eeeb582c0c1 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java @@ -26,7 +26,7 @@ import ca.uhn.fhir.rest.annotation.OptionalParam; import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.param.StringParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -148,7 +148,7 @@ public class StringParameterTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java index d2c9278ad03..4dd44808f91 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java @@ -34,7 +34,7 @@ import ca.uhn.fhir.rest.annotation.GetTags; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.TagListParam; import ca.uhn.fhir.rest.annotation.VersionIdParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -238,7 +238,7 @@ public class TagsServerTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); ourCtx = new FhirContext(Patient.class); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java index 665535cb0f1..67e82345bdf 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java @@ -32,7 +32,7 @@ import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.rest.annotation.Transaction; import ca.uhn.fhir.rest.annotation.TransactionParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -224,7 +224,7 @@ public class TransactionTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyProvider patientProvider = new DummyProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java index a9e966301f9..a13c5333fd0 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java @@ -32,7 +32,7 @@ import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.rest.annotation.Transaction; import ca.uhn.fhir.rest.annotation.TransactionParam; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -173,7 +173,7 @@ public class TransactionWithBundleParamTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyProvider patientProvider = new DummyProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java index ca3e11f2e29..4d599b5d02b 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.ResourceParam; import ca.uhn.fhir.rest.annotation.Update; import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -286,7 +286,7 @@ public class UpdateTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); PatientProvider patientProvider = new PatientProvider(); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java index 1c8d6953419..e9d63086887 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.rest.annotation.RequiredParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.testutil.RandomServerPortProvider; +import ca.uhn.fhir.util.PortUtil; /** * Created by dsotnikov on 2/25/2014. @@ -124,7 +124,7 @@ public class LoggingInterceptorTest { @BeforeClass public static void beforeClass() throws Exception { - ourPort = RandomServerPortProvider.findFreePort(); + ourPort = PortUtil.findFreePort(); ourServer = new Server(ourPort); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); diff --git a/hapi-fhir-base/src/test/resources/logback-test.xml b/hapi-fhir-base/src/test/resources/logback-test.xml index 57a4105e2ac..6870f30204a 100644 --- a/hapi-fhir-base/src/test/resources/logback-test.xml +++ b/hapi-fhir-base/src/test/resources/logback-test.xml @@ -10,6 +10,9 @@ + + + - - org.mitre - openid-connect-client - ${mitreid-connect-version} - - - org.springframework.security.oauth - spring-security-oauth2 - 2.0.2.RELEASE - - - - - javax.servlet - javax.servlet-api - 3.1.0 - provided - - - - - junit - junit - ${junit_version} - test - - - xmlunit - xmlunit - 1.5 - test - - - org.eclipse.jetty - jetty-servlets - 9.1.1.v20140108 - test - - - org.eclipse.jetty - jetty-servlet - 9.1.1.v20140108 - test - - - org.eclipse.jetty - jetty-server - 9.1.1.v20140108 - test - - - org.eclipse.jetty - jetty-servlet - 9.1.1.v20140108 - test - - - org.eclipse.jetty - jetty-util - 9.1.1.v20140108 - test - - - org.eclipse.jetty - jetty-webapp - 9.1.1.v20140108 - test - - - - - org.mockito - mockito-all - 1.9.5 - test - - - org.hamcrest - hamcrest-all - ${hamcrest_version} - test - - - - - - - - - - org.apache.maven.plugins - maven-changes-plugin - 2.10 - false - - - - changes-report - - - - - atom_1.0 - - http://sourceforge.net/support/tracker.php?aid=%ISSUE% - https://sourceforge.net/p/hl7api/bugs/%ISSUE%/ - https://sourceforge.net/p/hl7api/feature-requests/%ISSUE%/ - - false - - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.16 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - - - default - - javadoc - - - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.5.3 - - - org.apache.maven.plugins - maven-jxr-plugin - 2.4 - - - normal - - jxr - - - - restful-server-example - - jxr - - - ../restful-server-example/src/main/java - ${project.reporting.outputDirectory}/rse-xref - tmp - rse-xref - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.7 - - - - project-team - issue-tracking - license - scm - - - - - - - - - - UTF-8 - ${user.home}/sites/hapi-fhir - ${user.home}/sites/scm/hapi-fhir - - - - - - - maven-site-plugin - - false - true - - - - org.apache.maven.wagon - wagon-scm - 2.2 - - - org.apache.maven.scm - maven-scm-manager-plexus - 1.9 - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.9 - - - org.apache.maven.scm - maven-scm-api - 1.9 - - - - - - - - maven-antrun-plugin - 1.7 - - - addSyntaxHighlighter - site - - run - - - - Adding Syntax Highlighter - - - ]]> - - var elements = document.getElementsByClassName("source"); - for (var i=0; i < elements.length; i++) { - var pres = elements[i].getElementsByTagName("pre"); - for (var j = 0; j < pres.length; j++) { - var pre = pres[j]; - if (pre.innerHTML.match(/\/\*/)) { - pre.className = 'brush: java'; - } else if (pre.innerHTML.match(/^\/\//)) { - pre.className = 'brush: java'; - } else if (pre.innerHTML.match(/^\{/)) { - pre.className = 'brush: jscript'; - } else if (pre.innerHTML.match(/^\#/)) { - pre.className = 'brush: bash'; - } else if (pre.innerHTML.match(/\<\;\//)) { - pre.className = 'brush: xml'; - } else { - pre.className = 'brush: java'; - } - } - } - - SyntaxHighlighter.all(); - - - ]]> - - - - - - addAnalytics - post-site - - - Adding Google analytics in target/site for <body> - - - - - ]]> - - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-1395874-5', 'auto'); - ga('require', 'displayfeatures'); - ga('require', 'linkid', 'linkid.js'); - ga('send', 'pageview'); - - - - ]]> - - Adding Google analytics in target/site for <BODY> - - - ]]> - - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-1395874-5', 'auto'); - ga('require', 'displayfeatures'); - ga('require', 'linkid', 'linkid.js'); - ga('send', 'pageview'); - - - - ]]> - - Adding social plugins for HAPI - - - - -
-
- - -

- - -

- - ]]>
-
- - -
-
- - run - -
-
-
- - maven-site-plugin - - - stage-for-scm-publish - post-site - - stage - - - ${siteMainDirectory} - - - - - - org.apache.maven.plugins - maven-scm-publish-plugin - 1.1 - - ${scmPubCheckoutDirectory} - \${siteMainDirectory} - true - gh-pages - scm:git:git@github.com:jamesagnew/hapi-fhir.git - - - - scm-publish - site-deploy - - publish-scm - - - - -
- - - src/main/resources - true - - - -
- - - - DIST - - - - org.apache.maven.plugins - maven-javadoc-plugin - true - - 128m - 1g - true - false - false - - - - package - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - - - package - - jar-no-fork - - - - - - maven-assembly-plugin - 2.4 - - - package - - single - - - false - - ${project.basedir}/src/assembly/hapi-fhir-all.xml - - - - - - - - org.codehaus.mojo - license-maven-plugin - - - first - - update-file-header - - process-sources - - apache_v2 - true - true - - src/main/java - - - - - - - - - - - diff --git a/hapi-fhir-mitreid-integration/.classpath b/hapi-fhir-oauth2/.classpath similarity index 94% rename from hapi-fhir-mitreid-integration/.classpath rename to hapi-fhir-oauth2/.classpath index fd7ad7fbda7..afcbba556d2 100644 --- a/hapi-fhir-mitreid-integration/.classpath +++ b/hapi-fhir-oauth2/.classpath @@ -12,6 +12,7 @@ + diff --git a/hapi-fhir-mitreid-integration/.gitignore b/hapi-fhir-oauth2/.gitignore similarity index 100% rename from hapi-fhir-mitreid-integration/.gitignore rename to hapi-fhir-oauth2/.gitignore diff --git a/hapi-fhir-mitreid-integration/.project b/hapi-fhir-oauth2/.project similarity index 92% rename from hapi-fhir-mitreid-integration/.project rename to hapi-fhir-oauth2/.project index cda5bf3d6e4..0545006b46a 100644 --- a/hapi-fhir-mitreid-integration/.project +++ b/hapi-fhir-oauth2/.project @@ -1,6 +1,6 @@ - hapi-fhir-mitreid-integration + hapi-fhir-oauth2 diff --git a/hapi-fhir-mitreid-integration/.settings/org.eclipse.core.resources.prefs b/hapi-fhir-oauth2/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from hapi-fhir-mitreid-integration/.settings/org.eclipse.core.resources.prefs rename to hapi-fhir-oauth2/.settings/org.eclipse.core.resources.prefs diff --git a/hapi-fhir-mitreid-integration/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-oauth2/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from hapi-fhir-mitreid-integration/.settings/org.eclipse.jdt.core.prefs rename to hapi-fhir-oauth2/.settings/org.eclipse.jdt.core.prefs diff --git a/hapi-fhir-mitreid-integration/.settings/org.eclipse.m2e.core.prefs b/hapi-fhir-oauth2/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from hapi-fhir-mitreid-integration/.settings/org.eclipse.m2e.core.prefs rename to hapi-fhir-oauth2/.settings/org.eclipse.m2e.core.prefs diff --git a/hapi-fhir-oauth2/pom.xml b/hapi-fhir-oauth2/pom.xml new file mode 100644 index 00000000000..4f94b7b97ef --- /dev/null +++ b/hapi-fhir-oauth2/pom.xml @@ -0,0 +1,151 @@ + + 4.0.0 + + + ca.uhn.hapi.fhir + hapi-fhir + 0.6-SNAPSHOT + ../pom.xml + + + hapi-fhir-oauth2 + jar + HAPI FHIR - OAUTH2 Support + + + + + ca.uhn.hapi.fhir + hapi-fhir-base + 0.6-SNAPSHOT + + + + + org.mitre + openid-connect-client + ${mitreid-connect-version} + + + org.springframework.security.oauth + spring-security-oauth2 + 2.0.2.RELEASE + + + + + javax.servlet + javax.servlet-api + ${servlet_api_version} + provided + + + + + junit + junit + ${junit_version} + test + + + ch.qos.logback + logback-classic + ${logback_version} + test + + + + xmlunit + xmlunit + 1.5 + test + + + org.eclipse.jetty + jetty-servlets + ${jetty_version} + test + + + org.eclipse.jetty + jetty-servlet + ${jetty_version} + test + + + org.eclipse.jetty + jetty-server + ${jetty_version} + test + + + org.eclipse.jetty + jetty-servlet + ${jetty_version} + test + + + org.eclipse.jetty + jetty-util + ${jetty_version} + test + + + org.eclipse.jetty + jetty-webapp + ${jetty_version} + test + + + + + org.mockito + mockito-all + ${mockito_version} + test + + + org.hamcrest + hamcrest-all + ${hamcrest_version} + test + + + + + + + + + + + + + + + src/main/resources + true + + + + + diff --git a/hapi-fhir-mitreid-integration/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManager.java b/hapi-fhir-oauth2/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptor.java similarity index 79% rename from hapi-fhir-mitreid-integration/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManager.java rename to hapi-fhir-oauth2/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptor.java index 110fefe1700..c7b22f4717c 100644 --- a/hapi-fhir-mitreid-integration/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManager.java +++ b/hapi-fhir-oauth2/src/main/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptor.java @@ -24,6 +24,7 @@ import java.text.ParseException; import java.util.Date; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.mitre.jwt.signer.service.JwtSigningAndValidationService; import org.mitre.jwt.signer.service.impl.JWKSetCacheService; @@ -34,18 +35,22 @@ import org.mitre.openid.connect.client.service.ServerConfigurationService; import org.mitre.openid.connect.config.ServerConfiguration; import org.springframework.beans.factory.annotation.Autowired; +import ca.uhn.fhir.rest.method.OtherOperationTypeEnum; +import ca.uhn.fhir.rest.method.RequestDetails; import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; +import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jwt.ReadOnlyJWTClaimsSet; import com.nimbusds.jwt.SignedJWT; -public class OpenIdConnectBearerTokenSecurityManager implements IResourceSecurity { +public class OpenIdConnectBearerTokenServerInterceptor extends InterceptorAdapter { private static final String BEARER_PREFIX = "Bearer "; - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(OpenIdConnectBearerTokenSecurityManager.class); + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(OpenIdConnectBearerTokenServerInterceptor.class); + @Autowired private ClientConfigurationService myClientConfigurationService; @@ -54,16 +59,32 @@ public class OpenIdConnectBearerTokenSecurityManager implements IResourceSecurit private int myTimeSkewAllowance = 300; - private SymmetricCacheService symmetricCacheService; - private JWKSetCacheService validationServices; + private SymmetricCacheService mySymmetricCacheService; + private JWKSetCacheService myValidationServices; - public OpenIdConnectBearerTokenSecurityManager() { - symmetricCacheService = new SymmetricCacheService(); - validationServices = new JWKSetCacheService(); + public OpenIdConnectBearerTokenServerInterceptor() { + mySymmetricCacheService = new SymmetricCacheService(); + myValidationServices = new JWKSetCacheService(); } + + + @Override - public ISecurityOutcome authenticate(HttpServletRequest theRequest) throws AuthenticationException { + public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException { + if (theRequestDetails.getOtherOperationType() == OtherOperationTypeEnum.METADATA) { + return true; + } + + authenticate(theRequest); + + return true; + } + + + + + public void authenticate(HttpServletRequest theRequest) throws AuthenticationException { String token = theRequest.getHeader(Constants.HEADER_AUTHORIZATION); if (token == null) { throw new AuthenticationException("Not authorized (no authorization header found in request)"); @@ -110,10 +131,10 @@ public class OpenIdConnectBearerTokenSecurityManager implements IResourceSecurit if (alg.equals(JWSAlgorithm.HS256) || alg.equals(JWSAlgorithm.HS384) || alg.equals(JWSAlgorithm.HS512)) { // generate one based on client secret - jwtValidator = symmetricCacheService.getSymmetricValidtor(clientConfig.getClient()); + jwtValidator = mySymmetricCacheService.getSymmetricValidtor(clientConfig.getClient()); } else { // otherwise load from the server's public key - jwtValidator = validationServices.getValidator(serverConfig.getJwksUri()); + jwtValidator = myValidationServices.getValidator(serverConfig.getJwksUri()); } if (jwtValidator != null) { @@ -130,8 +151,9 @@ public class OpenIdConnectBearerTokenSecurityManager implements IResourceSecurit throw new AuthenticationException("Id Token does not have required expiration claim"); } else { // it's not null, see if it's expired - Date now = new Date(System.currentTimeMillis() - (myTimeSkewAllowance * 1000)); - if (now.after(idClaims.getExpirationTime())) { + Date minAllowableExpirationTime = new Date(System.currentTimeMillis() - (myTimeSkewAllowance * 1000L)); + Date expirationTime = idClaims.getExpirationTime(); + if (!expirationTime.after(minAllowableExpirationTime)) { throw new AuthenticationException("Id Token is expired: " + idClaims.getExpirationTime()); } } @@ -155,8 +177,6 @@ public class OpenIdConnectBearerTokenSecurityManager implements IResourceSecurit } } - return new ISecurityOutcome() { - }; } public int getTimeSkewAllowance() { @@ -176,7 +196,7 @@ public class OpenIdConnectBearerTokenSecurityManager implements IResourceSecurit } public void setValidationServices(JWKSetCacheService theValidationServices) { - validationServices = theValidationServices; + myValidationServices = theValidationServices; } } diff --git a/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/DummyOpenIdServlet.java b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/DummyOpenIdServlet.java new file mode 100644 index 00000000000..9e2d2fae7a4 --- /dev/null +++ b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/DummyOpenIdServlet.java @@ -0,0 +1,34 @@ +package ca.uhn.fhir.rest.server.security; + +import java.io.IOException; +import java.io.InputStream; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.io.IOUtils; + +public class DummyOpenIdServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DummyOpenIdServlet.class); + + @Override + protected void doGet(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException { + ourLog.info("Request: {}", theReq.getRequestURI()); + + if (theReq.getRequestURI().equals("/openid/jwk")) { + + theResp.setStatus(200); + InputStream is = DummyOpenIdServlet.class.getResourceAsStream("/svr_keystore.jwks"); + IOUtils.copy(is, theResp.getOutputStream()); + IOUtils.closeQuietly(theResp.getOutputStream()); + return; + } + + + super.doGet(theReq, theResp); + } + +} diff --git a/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorIntegrationTest.java b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorIntegrationTest.java new file mode 100644 index 00000000000..68a7175efb6 --- /dev/null +++ b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorIntegrationTest.java @@ -0,0 +1,159 @@ +package ca.uhn.fhir.rest.server.security; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mitre.oauth2.model.RegisteredClient; +import org.mitre.openid.connect.client.service.impl.StaticClientConfigurationService; +import org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService; +import org.mitre.openid.connect.config.ServerConfiguration; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.model.api.IResource; +import ca.uhn.fhir.model.dstu.resource.Observation; +import ca.uhn.fhir.rest.annotation.Search; +import ca.uhn.fhir.rest.server.IResourceProvider; +import ca.uhn.fhir.rest.server.RestfulServer; +import ca.uhn.fhir.util.PortUtil; + +/** + * Created by dsotnikov on 2/25/2014. + */ +public class OpenIdConnectBearerTokenServerInterceptorIntegrationTest { + + private static CloseableHttpClient ourClient; + private static FhirContext ourCtx = new FhirContext(); + private static int ourPort; + + private static Server ourServer; + private static OpenIdConnectBearerTokenServerInterceptor myInterceptor; + + @Test + public void testSearchWithoutToken() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Observation?"); + + HttpResponse status = ourClient.execute(httpGet); + IOUtils.closeQuietly(status.getEntity().getContent()); + assertEquals(401, status.getStatusLine().getStatusCode()); + + } + + @Test + public void testSearchWithExpiredToken() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Observation?"); + httpGet.addHeader( + "Authorization", + "Bearer " + + "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE0MDY4NDE4NTgsImF1ZCI6WyJjbGllbnQiXSwiaXNzIjoiaHR0cDpcL1wvbG9jYWxob3N0Ojg4ODhcL3Vobi1vcGVuaWQtY29ubmVjdFwvIiwianRpIjoiOTNiMzRjOTUtNTNiMC00YzZmLTkwYjEtYWVjODRjZTc3OGFhIiwiaWF0IjoxNDA2ODM4MjU4fQ.fYtwehPUulUYnDG_10bN6TNf7uw2FNUh_E40YagpITrVfXsV06pjU2YpNgy8nbSFmxY9IBH44UXTmMH9PLFiRn88WsPMSrUQbFCcvGIYwhqkRjGm_J1Y6oWIafUzCwZBCvk4Ne44p3DJRR6FSZRnnC850p55901DGQmNLe-rZJk3t0MHl6wySduqT3K1-Vbuq-7H6xLE10hKpLhSqBTghpQNKNjm48jm0sHcFa3ENWzyWPOmpNfzDKmJAYK2UnBtqNSJP6AJzVrJXqSu-uzasq0VOVcRU4n8b39vU1olbho1eKF0cfQlQwbrtvWipBJJSsRp_tmB9SV9BXhENxOFTw"); + HttpResponse status = ourClient.execute(httpGet); + IOUtils.closeQuietly(status.getEntity().getContent()); + assertEquals(401, status.getStatusLine().getStatusCode()); + } + + @Test + public void testSearchWithValidToken() throws Exception { + myInterceptor.setTimeSkewAllowance(10 * 365 * 24 * 60 * 60); + + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Observation?"); + httpGet.addHeader( + "Authorization", + "Bearer " + + "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE0MDY4NDE4NTgsImF1ZCI6WyJjbGllbnQiXSwiaXNzIjoiaHR0cDpcL1wvbG9jYWxob3N0Ojg4ODhcL3Vobi1vcGVuaWQtY29ubmVjdFwvIiwianRpIjoiOTNiMzRjOTUtNTNiMC00YzZmLTkwYjEtYWVjODRjZTc3OGFhIiwiaWF0IjoxNDA2ODM4MjU4fQ.fYtwehPUulUYnDG_10bN6TNf7uw2FNUh_E40YagpITrVfXsV06pjU2YpNgy8nbSFmxY9IBH44UXTmMH9PLFiRn88WsPMSrUQbFCcvGIYwhqkRjGm_J1Y6oWIafUzCwZBCvk4Ne44p3DJRR6FSZRnnC850p55901DGQmNLe-rZJk3t0MHl6wySduqT3K1-Vbuq-7H6xLE10hKpLhSqBTghpQNKNjm48jm0sHcFa3ENWzyWPOmpNfzDKmJAYK2UnBtqNSJP6AJzVrJXqSu-uzasq0VOVcRU4n8b39vU1olbho1eKF0cfQlQwbrtvWipBJJSsRp_tmB9SV9BXhENxOFTw"); + HttpResponse status = ourClient.execute(httpGet); + IOUtils.closeQuietly(status.getEntity().getContent()); + assertEquals(200, status.getStatusLine().getStatusCode()); + } + + @Before + public void before() { + myInterceptor.setTimeSkewAllowance(10 * 60); + } + + @AfterClass + public static void afterClass() throws Exception { + ourServer.stop(); + } + + @BeforeClass + public static void beforeClass() throws Exception { + ourPort = PortUtil.findFreePort(); + ourServer = new Server(ourPort); + + ServletHandler proxyHandler = new ServletHandler(); + + DummyOpenIdServlet openIdServlet = new DummyOpenIdServlet(); + ServletHolder proxyHolder = new ServletHolder(openIdServlet); + proxyHandler.addServletWithMapping(proxyHolder, "/openid/*"); + + RestfulServer servlet = new RestfulServer(); + servlet.setResourceProviders(new DummyObservationResourceProvider()); + ServletHolder servletHolder = new ServletHolder(servlet); + proxyHandler.addServletWithMapping(servletHolder, "/*"); + + // DynamicServerConfigurationService s = new DynamicServerConfigurationService(); + // s.setWhitelist(new HashSet()); + // s.getWhitelist().add("http://localhost:8888/uhn-openid-connect/"); + + StaticServerConfigurationService srv = new StaticServerConfigurationService(); + srv.setServers(new HashMap()); + ServerConfiguration srvCfg = new ServerConfiguration(); + srvCfg.setJwksUri("http://localhost:" + ourPort + "/openid/jwk"); + srvCfg.setIssuer("http://localhost:8888/uhn-openid-connect/"); + srv.getServers().put("http://localhost:8888/uhn-openid-connect/", srvCfg); + srv.afterPropertiesSet(); + + StaticClientConfigurationService cli = new StaticClientConfigurationService(); + cli.setClients(new HashMap()); + cli.getClients().put("http://localhost:8888/uhn-openid-connect/", new RegisteredClient()); + + myInterceptor = new OpenIdConnectBearerTokenServerInterceptor(); + myInterceptor.setClientConfigurationService(cli); + myInterceptor.setServerConfigurationService(srv); + + servlet.registerInterceptor(myInterceptor); + + ourServer.setHandler(proxyHandler); + ourServer.start(); + + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS); + HttpClientBuilder builder = HttpClientBuilder.create(); + builder.setConnectionManager(connectionManager); + ourClient = builder.build(); + + } + + public static class DummyObservationResourceProvider implements IResourceProvider { + + @Override + public Class getResourceType() { + return Observation.class; + } + + @Search + public Observation search() { + Observation o = new Observation(); + o.setId("1"); + + o.getName().setText("This is an observation"); + + return o; + } + + } + +} diff --git a/hapi-fhir-mitreid-integration/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManagerTest.java b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorTest.java similarity index 64% rename from hapi-fhir-mitreid-integration/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManagerTest.java rename to hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorTest.java index 70026ba64ae..5ff04a04803 100644 --- a/hapi-fhir-mitreid-integration/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenSecurityManagerTest.java +++ b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/OpenIdConnectBearerTokenServerInterceptorTest.java @@ -20,14 +20,22 @@ import org.mitre.openid.connect.client.service.impl.StaticServerConfigurationSer import org.mitre.openid.connect.config.ServerConfiguration; import org.springframework.core.io.ClassPathResource; +import ca.uhn.fhir.model.api.IResource; +import ca.uhn.fhir.model.dstu.composite.CodingDt; +import ca.uhn.fhir.model.dstu.resource.Observation; +import ca.uhn.fhir.rest.annotation.RequiredParam; +import ca.uhn.fhir.rest.annotation.Search; +import ca.uhn.fhir.rest.param.ReferenceParam; +import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.server.Constants; +import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; -public class OpenIdConnectBearerTokenSecurityManagerTest { +public class OpenIdConnectBearerTokenServerInterceptorTest { @Test public void testValidateToken() throws Exception { - + StaticServerConfigurationService srv = new StaticServerConfigurationService(); srv.setServers(new HashMap()); ServerConfiguration srvCfg = new ServerConfiguration(); @@ -35,38 +43,41 @@ public class OpenIdConnectBearerTokenSecurityManagerTest { srvCfg.setIssuer("http://localhost:8888/uhn-openid-connect/"); srv.getServers().put("http://localhost:8888/uhn-openid-connect/", srvCfg); srv.afterPropertiesSet(); - + StaticClientConfigurationService cli = new StaticClientConfigurationService(); cli.setClients(new HashMap()); cli.getClients().put("http://localhost:8888/uhn-openid-connect/", new RegisteredClient()); - - OpenIdConnectBearerTokenSecurityManager mgr = new OpenIdConnectBearerTokenSecurityManager(); + + OpenIdConnectBearerTokenServerInterceptor mgr = new OpenIdConnectBearerTokenServerInterceptor(); mgr.setClientConfigurationService(cli); mgr.setServerConfigurationService(srv); - + HttpServletRequest req = mock(HttpServletRequest.class); - when(req.getHeader(Constants.HEADER_AUTHORIZATION)).thenReturn("Bearer " + "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE0MDY4NDE4NTgsImF1ZCI6WyJjbGllbnQiXSwiaXNzIjoiaHR0cDpcL1wvbG9jYWxob3N0Ojg4ODhcL3Vobi1vcGVuaWQtY29ubmVjdFwvIiwianRpIjoiOTNiMzRjOTUtNTNiMC00YzZmLTkwYjEtYWVjODRjZTc3OGFhIiwiaWF0IjoxNDA2ODM4MjU4fQ.fYtwehPUulUYnDG_10bN6TNf7uw2FNUh_E40YagpITrVfXsV06pjU2YpNgy8nbSFmxY9IBH44UXTmMH9PLFiRn88WsPMSrUQbFCcvGIYwhqkRjGm_J1Y6oWIafUzCwZBCvk4Ne44p3DJRR6FSZRnnC850p55901DGQmNLe-rZJk3t0MHl6wySduqT3K1-Vbuq-7H6xLE10hKpLhSqBTghpQNKNjm48jm0sHcFa3ENWzyWPOmpNfzDKmJAYK2UnBtqNSJP6AJzVrJXqSu-uzasq0VOVcRU4n8b39vU1olbho1eKF0cfQlQwbrtvWipBJJSsRp_tmB9SV9BXhENxOFTw"); + when(req.getHeader(Constants.HEADER_AUTHORIZATION)) + .thenReturn( + "Bearer " + + "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE0MDY4NDE4NTgsImF1ZCI6WyJjbGllbnQiXSwiaXNzIjoiaHR0cDpcL1wvbG9jYWxob3N0Ojg4ODhcL3Vobi1vcGVuaWQtY29ubmVjdFwvIiwianRpIjoiOTNiMzRjOTUtNTNiMC00YzZmLTkwYjEtYWVjODRjZTc3OGFhIiwiaWF0IjoxNDA2ODM4MjU4fQ.fYtwehPUulUYnDG_10bN6TNf7uw2FNUh_E40YagpITrVfXsV06pjU2YpNgy8nbSFmxY9IBH44UXTmMH9PLFiRn88WsPMSrUQbFCcvGIYwhqkRjGm_J1Y6oWIafUzCwZBCvk4Ne44p3DJRR6FSZRnnC850p55901DGQmNLe-rZJk3t0MHl6wySduqT3K1-Vbuq-7H6xLE10hKpLhSqBTghpQNKNjm48jm0sHcFa3ENWzyWPOmpNfzDKmJAYK2UnBtqNSJP6AJzVrJXqSu-uzasq0VOVcRU4n8b39vU1olbho1eKF0cfQlQwbrtvWipBJJSsRp_tmB9SV9BXhENxOFTw"); JWKSetCacheService val = mock(JWKSetCacheService.class); - + JWKSetKeyStore keyStore = new JWKSetKeyStore(); keyStore.setLocation(new ClassPathResource("/svr_keystore.jwks")); DefaultJwtSigningAndValidationService valSvc = new DefaultJwtSigningAndValidationService(keyStore); when(val.getValidator("AAAAAA")).thenReturn(valSvc); - + mgr.setValidationServices(val); - + try { - mgr.authenticate(req); - fail(); + mgr.authenticate(req); + fail(); } catch (AuthenticationException e) { assertThat(e.getMessage(), StringContains.containsString("expired")); } - - mgr.setTimeSkewAllowance(10 * 365 * 24 * 60); + + mgr.setTimeSkewAllowance(10 * 365 * 24 * 60 * 60); mgr.authenticate(req); - - + } + } diff --git a/hapi-fhir-mitreid-integration/src/test/java/ca/uhn/fhir/rest/server/security/RestAuthenticationEntryPoint.java b/hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/RestAuthenticationEntryPoint.java similarity index 100% rename from hapi-fhir-mitreid-integration/src/test/java/ca/uhn/fhir/rest/server/security/RestAuthenticationEntryPoint.java rename to hapi-fhir-oauth2/src/test/java/ca/uhn/fhir/rest/server/security/RestAuthenticationEntryPoint.java diff --git a/hapi-fhir-oauth2/src/test/resources/logback-test.xml b/hapi-fhir-oauth2/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..57a4105e2ac --- /dev/null +++ b/hapi-fhir-oauth2/src/test/resources/logback-test.xml @@ -0,0 +1,24 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hapi-fhir-base/src/test/resources/svr_keystore.jwks b/hapi-fhir-oauth2/src/test/resources/svr_keystore.jwks similarity index 100% rename from hapi-fhir-base/src/test/resources/svr_keystore.jwks rename to hapi-fhir-oauth2/src/test/resources/svr_keystore.jwks diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/TesterConfig.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/TesterConfig.java index af499890d2a..7d5805a6826 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/TesterConfig.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/TesterConfig.java @@ -1,15 +1,20 @@ package ca.uhn.fhir.to; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.springframework.beans.factory.annotation.Required; public class TesterConfig { + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TesterConfig.class); + + public static final String SYSPROP_FORCE_SERVERS = "ca.uhn.fhir.to.TesterConfig_SYSPROP_FORCE_SERVERS"; private LinkedHashMap myIdToServerName = new LinkedHashMap(); - + public LinkedHashMap getIdToServerName() { return myIdToServerName; } @@ -22,7 +27,17 @@ public class TesterConfig { @Required public void setServers(List theServers) { - for (String nextRaw : theServers) { + List servers = theServers; + + // This is mostly for unit tests + String force = System.getProperty(SYSPROP_FORCE_SERVERS); + if (StringUtils.isNotBlank(force)) { + ourLog.warn("Forcing server confirguration because of system property: {}", force); + servers = Collections.singletonList(force); + } + + + for (String nextRaw : servers) { String[] nextSplit = nextRaw.split(","); Validate.notBlank(nextSplit[0], "theId can not be blank"); Validate.notBlank(nextSplit[1], "theDisplayName can not be blank"); diff --git a/pom.xml b/pom.xml index 2c09ac6b0e2..9caf03a9046 100644 --- a/pom.xml +++ b/pom.xml @@ -80,13 +80,14 @@ hapi-fhir-jpaserver-base hapi-fhir-jpaserver-test restful-server-example + restful-server-example-test hapi-fhir-testpage-overlay hapi-fhir-jpaserver-uhnfhirtest 3.3.2 - 10.10.2.0 + 10.11.1.1 18.0 1.3 4.2.12.Final @@ -94,7 +95,7 @@ 9.2.2.v20140723 4.3.1 4.11 - 1.1.1 + 1.1.2 2.4.1 2.9.1 1.7 @@ -105,8 +106,9 @@ 1.9.5 2.7.1 UTF-8 + 3.1.0 1.7.7 - 4.0.6.RELEASE + 4.1.0.RELEASE 3.2.4.RELEASE 2.1.3.RELEASE 1.0.1 @@ -131,6 +133,7 @@ ${maven_surefire_plugin_version} true + random
diff --git a/restful-server-example-test/pom.xml b/restful-server-example-test/pom.xml index 8fcc6e5a8f1..2b30ade836c 100644 --- a/restful-server-example-test/pom.xml +++ b/restful-server-example-test/pom.xml @@ -11,7 +11,7 @@ restful-server-example-test jar - HAPI Tinder Plugin - Test Project + HAPI FHIR Sample RESTful Server - Tests diff --git a/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java b/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java index 61a853a5e65..eb3a926915f 100644 --- a/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java +++ b/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java @@ -23,6 +23,9 @@ public class ExampleTest { @AfterClass public static void afterClass() throws Exception { ourServer.stop(); + + System.clearProperty("ca.uhn.fhir.to.TesterConfig_SYSPROP_FORCE_SERVERS"); + } @Test @@ -40,6 +43,9 @@ public class ExampleTest { ourPort = RandomServerPortProvider.findFreePort(); ourServer = new Server(ourPort); + String base = "http://localhost:" + ourPort+"/fhir"; + System.setProperty("ca.uhn.fhir.to.TesterConfig_SYSPROP_FORCE_SERVERS", "example , Restful Server Example , " + base); + WebAppContext root = new WebAppContext(); root.setWar("file:../restful-server-example/target/restful-server-example.war"); @@ -54,8 +60,9 @@ public class ExampleTest { ourServer.start(); ourCtx = new FhirContext(); - ourClient = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort+"/fhir"); - + ourClient = ourCtx.newRestfulGenericClient(base); + + } } diff --git a/restful-server-example/pom.xml b/restful-server-example/pom.xml index 29bad8dd318..6daa8404eab 100644 --- a/restful-server-example/pom.xml +++ b/restful-server-example/pom.xml @@ -16,7 +16,7 @@ 0.6-SNAPSHOT war - Sample RESTful Server (HAPI-FHIR) + HAPI FHIR Sample RESTful Server @@ -51,7 +51,7 @@ ch.qos.logback logback-classic - 1.1.1 + 1.1.2 From b1b99e1aa2444e74c9078fe5b822f18700ac4de6 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Mon, 8 Sep 2014 09:27:02 -0400 Subject: [PATCH 2/5] - --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 9caf03a9046..e2cb0adebb9 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,7 @@ hapi-fhir-base + hapi-fhir-oauth2 hapi-fhir-base/examples hapi-tinder-plugin hapi-tinder-test From 8a77ac939dc7c47e09ffc424a3e136b623d0d552 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 10 Sep 2014 14:12:11 -0400 Subject: [PATCH 3/5] Documentation enhancements --- .../java/example/.ValidatorExamples.java.swp | Bin 0 -> 12288 bytes .../src/main/java/example/FhirDataModel.java | 162 ++++++++++-------- .../main/java/example/ValidatorExamples.java | 45 ++++- .../src/site/xdoc/doc_fhirobjects.xml | 17 ++ .../src/site/xdoc/doc_validation.xml | 15 +- .../java/ca/uhn/fhir/test/FhirTerserTest.java | 2 + hapi-fhir-oauth2/.gitignore | 1 + 7 files changed, 166 insertions(+), 76 deletions(-) create mode 100644 hapi-fhir-base/examples/src/main/java/example/.ValidatorExamples.java.swp diff --git a/hapi-fhir-base/examples/src/main/java/example/.ValidatorExamples.java.swp b/hapi-fhir-base/examples/src/main/java/example/.ValidatorExamples.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..9417b3b89bd248aef2121e8a99544402ba478586 GIT binary patch literal 12288 zcmeHNO>Z1E75vS4$Pv)(==%-52LwXuji10D0C7Md#07drBAmD(!Q)-eOtM|ITmg^t?2PUAef;`){h=sc zKXG~SB0a-q2%e*aeDwa&wO>A-BKZ~}X6Bg_Gi5KgO?P`P@Jwhub&*FeN_l;%t0YTh z#M5z~w=2SMGcjS07s=E{FHz0c)H>H96n&l*snDTTQJC>053lhpUR8&ed78xBNY!z6 z%r=kr<;z|HufVthN65^{=@Yj0$<{IY=p&cL4Sd-v;1%!+cm=!yUIDLwSHLUa75EP; zV2XX@9gOcjH^yh(d*9gG75&RA;1%!+cm=!yUIDLwSHLUa74Qmp1-t@Yfq$U_JSODN z{e&DifZ*}}|LX7m-ybGq2lxs23iurO47dTj06Y&o4(vRHcHlkW5)c48M+o^1_y+hI zxCOimyaq7fDd3O8gnSQt09*z31AiSNp? z2&MF<{jtC^{2qNqrq6P*UEjP5+H7ld3r_?}Xj!UAwCBml7{7}vu98-*^f~HCE@+u| zxza*`rLZ5Bagd9?Sx8cGPUc4BM(?IvH7dzB>9`4a7nd)YB-PBwkqv0Jsij#FJVq~- zOS`7qkctLlgmezvBfp>(_GBhPZGYlKwc0FAv>EbVNzyptDz^N90e|ahX8NYpZnxSH+I+va>(7(2BTPtay?BVstq@IZOJ62_P(Qw?e#Y(SDU&`O;5>fP0w?~ z7o^I#>GUH}m_+8sG5WeN>fVM>rOt&DhMlGJbaiR5+wH8)QCzZ2B9}{WIHSr3?yCcB zM8;%kSOL{dn%gXw>BNk(GDs6&o3bR}Y z1u?@1dTc-0rXnuJu@0=)YM@#e{&38tj=@E-Fl6xHhWS)oyAbER1tSyjcou zD6hr|H=f6o7ezXtiE%@AuY&P7UK6Q+@>rZm-e^35oy$COrA}UEto!ovQfFv_j!O}= zW~Wcn>60^4v!_m=blF2-2Q$wp$=N~!X>4Jqf6x=y!_(-u5uPmQ@P;Z`xCKu8Nb zOVUBmTFnyE!)ip;OUahVgVqJv%lA~g+K_ZHkI*qK-12kfJ^Gwef*UcEq>x3K4hzG@ zS~zdHeoaJUI{nk-J<7pZO?kS_2l_Z2$P(lN`qRknas7%o3|H6AuB_d4jk?WZxJw}Q z_6~HthyptwiL;1OOfyjmf=4~Uuy!(;YnDj1flUa&A;IoEH|kC%`?^!D>B3%ex1_r^{F + +
+ + +

+ The following example shows how to create an observation resource containing + a numeric datatype. +

+ + + + + +
+ +
+ diff --git a/hapi-fhir-base/src/site/xdoc/doc_validation.xml b/hapi-fhir-base/src/site/xdoc/doc_validation.xml index b8bf9a0d28e..731bf05d89b 100644 --- a/hapi-fhir-base/src/site/xdoc/doc_validation.xml +++ b/hapi-fhir-base/src/site/xdoc/doc_validation.xml @@ -23,7 +23,7 @@

- FHIR resource definitions are distributed with a set of XML schema files (XDS) + FHIR resource definitions are distributed with a set of XML schema files (XSD) as well as a set of XML Schematron (SCH) files. These two sets of files are complimentary to each other, meaning that in order to claim compliance to the FHIR specification, your resources must validate against both sets. @@ -60,6 +60,19 @@ + + +

+ The following example shows how to load a set of resources from files + on disk and validate each one. +

+ + + + + +
+ diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/test/FhirTerserTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/test/FhirTerserTest.java index 185b833a352..bc935f03bb1 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/test/FhirTerserTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/test/FhirTerserTest.java @@ -9,6 +9,7 @@ import org.junit.Test; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.dstu.resource.Patient; +import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum; import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.util.FhirTerser; @@ -18,6 +19,7 @@ public class FhirTerserTest { public void testGetAllPopulatedChildElementsOfType() { Patient p = new Patient(); + p.setGender(AdministrativeGenderCodesEnum.M); p.addIdentifier().setSystem("urn:foo"); p.addAddress().addLine("Line1"); p.addAddress().addLine("Line2"); diff --git a/hapi-fhir-oauth2/.gitignore b/hapi-fhir-oauth2/.gitignore index b83d22266ac..0f630157f4b 100644 --- a/hapi-fhir-oauth2/.gitignore +++ b/hapi-fhir-oauth2/.gitignore @@ -1 +1,2 @@ /target/ +/bin/ From f388c6df3d00009dc56c82fa7f4fc4aec555d581 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 10 Sep 2014 14:13:01 -0400 Subject: [PATCH 4/5] Nothing --- .../java/example/.ValidatorExamples.java.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 hapi-fhir-base/examples/src/main/java/example/.ValidatorExamples.java.swp diff --git a/hapi-fhir-base/examples/src/main/java/example/.ValidatorExamples.java.swp b/hapi-fhir-base/examples/src/main/java/example/.ValidatorExamples.java.swp deleted file mode 100644 index 9417b3b89bd248aef2121e8a99544402ba478586..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeHNO>Z1E75vS4$Pv)(==%-52LwXuji10D0C7Md#07drBAmD(!Q)-eOtM|ITmg^t?2PUAef;`){h=sc zKXG~SB0a-q2%e*aeDwa&wO>A-BKZ~}X6Bg_Gi5KgO?P`P@Jwhub&*FeN_l;%t0YTh z#M5z~w=2SMGcjS07s=E{FHz0c)H>H96n&l*snDTTQJC>053lhpUR8&ed78xBNY!z6 z%r=kr<;z|HufVthN65^{=@Yj0$<{IY=p&cL4Sd-v;1%!+cm=!yUIDLwSHLUa75EP; zV2XX@9gOcjH^yh(d*9gG75&RA;1%!+cm=!yUIDLwSHLUa74Qmp1-t@Yfq$U_JSODN z{e&DifZ*}}|LX7m-ybGq2lxs23iurO47dTj06Y&o4(vRHcHlkW5)c48M+o^1_y+hI zxCOimyaq7fDd3O8gnSQt09*z31AiSNp? z2&MF<{jtC^{2qNqrq6P*UEjP5+H7ld3r_?}Xj!UAwCBml7{7}vu98-*^f~HCE@+u| zxza*`rLZ5Bagd9?Sx8cGPUc4BM(?IvH7dzB>9`4a7nd)YB-PBwkqv0Jsij#FJVq~- zOS`7qkctLlgmezvBfp>(_GBhPZGYlKwc0FAv>EbVNzyptDz^N90e|ahX8NYpZnxSH+I+va>(7(2BTPtay?BVstq@IZOJ62_P(Qw?e#Y(SDU&`O;5>fP0w?~ z7o^I#>GUH}m_+8sG5WeN>fVM>rOt&DhMlGJbaiR5+wH8)QCzZ2B9}{WIHSr3?yCcB zM8;%kSOL{dn%gXw>BNk(GDs6&o3bR}Y z1u?@1dTc-0rXnuJu@0=)YM@#e{&38tj=@E-Fl6xHhWS)oyAbER1tSyjcou zD6hr|H=f6o7ezXtiE%@AuY&P7UK6Q+@>rZm-e^35oy$COrA}UEto!ovQfFv_j!O}= zW~Wcn>60^4v!_m=blF2-2Q$wp$=N~!X>4Jqf6x=y!_(-u5uPmQ@P;Z`xCKu8Nb zOVUBmTFnyE!)ip;OUahVgVqJv%lA~g+K_ZHkI*qK-12kfJ^Gwef*UcEq>x3K4hzG@ zS~zdHeoaJUI{nk-J<7pZO?kS_2l_Z2$P(lN`qRknas7%o3|H6AuB_d4jk?WZxJw}Q z_6~HthyptwiL;1OOfyjmf=4~Uuy!(;YnDj1flUa&A;IoEH|kC%`?^!D>B3%ex1_r^{F Date: Thu, 11 Sep 2014 16:28:29 -0400 Subject: [PATCH 5/5] Documentation tweaks --- hapi-fhir-base/src/site/xdoc/doc_validation.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-base/src/site/xdoc/doc_validation.xml b/hapi-fhir-base/src/site/xdoc/doc_validation.xml index 731bf05d89b..5f8301a2eda 100644 --- a/hapi-fhir-base/src/site/xdoc/doc_validation.xml +++ b/hapi-fhir-base/src/site/xdoc/doc_validation.xml @@ -17,7 +17,7 @@

HAPI provides a built-in and configurable mechanism for validating resources. - This mechanism is called the Resource Validator. + This mechanism is called the FHIR Validator.