8888
8989/**
9090 * Top-level entry point to the entire application.
91- * <p>
92- * See the Dropwizard docs here:
93- * <a href="https://dropwizard.github.io">https://dropwizard.github.io</a>
91+ *
92+ * <p> See the Dropwizard docs here: <a
93+ * href="https://dropwizard.github.io">https://dropwizard.github.io</a>
9494 */
9595public class ConsentApplication extends Application <ConsentConfiguration > {
9696
@@ -106,19 +106,21 @@ public static void main(String[] args) throws Exception {
106106 try {
107107 String dsn = System .getProperties ().getProperty ("sentry.dsn" );
108108 if (StringUtils .isNotBlank (dsn )) {
109- Sentry .init (config -> {
110- config .setDsn (dsn );
111- config .setDiagnosticLevel (SentryLevel .ERROR );
112- config .setServerName ("Consent" );
113- config .addContextTag ("Consent" );
114- config .addInAppInclude ("org.broadinstitute" );
115- });
109+ Sentry .init (
110+ config -> {
111+ config .setDsn (dsn );
112+ config .setDiagnosticLevel (SentryLevel .ERROR );
113+ config .setServerName ("Consent" );
114+ config .addContextTag ("Consent" );
115+ config .addInAppInclude ("org.broadinstitute" );
116+ });
116117 Thread .currentThread ().setUncaughtExceptionHandler (UncaughtExceptionHandlers .systemExit ());
117118 } else {
118119 LOGGER .error ("Unable to bootstrap sentry logging." );
119120 }
120121 } catch (Exception e ) {
121- LOGGER .error (MessageFormat .format ("Exception loading sentry properties: {0}" , e .getMessage ()));
122+ LOGGER .error (
123+ MessageFormat .format ("Exception loading sentry properties: {0}" , e .getMessage ()));
122124 }
123125 new ConsentApplication ().run (args );
124126 LOGGER .info ("Consent Application Started" );
@@ -187,18 +189,24 @@ public void run(ConsentConfiguration config, Environment env) {
187189
188190 // Authentication filters
189191 final OAuthAuthenticator authenticator = injector .getProvider (OAuthAuthenticator .class ).get ();
190- final DuosUserAuthenticator duosUserAuthenticator = injector .getProvider (DuosUserAuthenticator .class ).get ();
191- final AuthorizationHelper authorizationHelper = injector .getProvider (AuthorizationHelper .class ).get ();
192+ final DuosUserAuthenticator duosUserAuthenticator =
193+ injector .getProvider (DuosUserAuthenticator .class ).get ();
194+ final AuthorizationHelper authorizationHelper =
195+ injector .getProvider (AuthorizationHelper .class ).get ();
192196 // Requests annotated with @Auth AuthUser will be authenticated through this filter
193- final AuthFilter <String , AuthUser > primaryAuthFilter = new OAuthCustomAuthFilter <>(authenticator , authorizationHelper );
194- // Requests annotated with @Auth DuosUser will be authenticated through this filter and are guaranteed to have a populated User object
195- final AuthFilter <String , DuosUser > duosAuthUserFilter = new OAuthCustomAuthFilter <>(duosUserAuthenticator , authorizationHelper );
196- final PolymorphicAuthDynamicFeature <AuthUser > feature = new PolymorphicAuthDynamicFeature <>(
197- Map .of (
198- AuthUser .class , primaryAuthFilter ,
199- DuosUser .class , duosAuthUserFilter ));
200- final AbstractBinder binder = new PolymorphicAuthValueFactoryProvider .Binder <>(
201- Set .of (AuthUser .class , DuosUser .class ));
197+ final AuthFilter <String , AuthUser > primaryAuthFilter =
198+ new OAuthCustomAuthFilter <>(authenticator , authorizationHelper );
199+ // Requests annotated with @Auth DuosUser will be authenticated through this filter and are
200+ // guaranteed to have a populated User object
201+ final AuthFilter <String , DuosUser > duosAuthUserFilter =
202+ new OAuthCustomAuthFilter <>(duosUserAuthenticator , authorizationHelper );
203+ final PolymorphicAuthDynamicFeature <AuthUser > feature =
204+ new PolymorphicAuthDynamicFeature <>(
205+ Map .of (
206+ AuthUser .class , primaryAuthFilter ,
207+ DuosUser .class , duosAuthUserFilter ));
208+ final AbstractBinder binder =
209+ new PolymorphicAuthValueFactoryProvider .Binder <>(Set .of (AuthUser .class , DuosUser .class ));
202210 env .jersey ().register (feature );
203211 env .jersey ().register (binder );
204212
@@ -224,15 +232,16 @@ private void initializeLiquibase(ConsentConfiguration config)
224232 values .set ("ui" , new LoggerUIService ());
225233 } catch (IllegalAccessException | NoSuchFieldException ignored ) {
226234 }
227- Connection connection = DriverManager .getConnection (
228- config .getDataSourceFactory ().getUrl (),
229- config .getDataSourceFactory ().getUser (),
230- config .getDataSourceFactory ().getPassword ()
231- );
232- Database database = DatabaseFactory .getInstance ()
233- .findCorrectDatabaseImplementation (new JdbcConnection (connection ));
234- Liquibase liquibase = new Liquibase (liquibaseFile (), new ClassLoaderResourceAccessor (),
235- database );
235+ Connection connection =
236+ DriverManager .getConnection (
237+ config .getDataSourceFactory ().getUrl (),
238+ config .getDataSourceFactory ().getUser (),
239+ config .getDataSourceFactory ().getPassword ());
240+ Database database =
241+ DatabaseFactory .getInstance ()
242+ .findCorrectDatabaseImplementation (new JdbcConnection (connection ));
243+ Liquibase liquibase =
244+ new Liquibase (liquibaseFile (), new ClassLoaderResourceAccessor (), database );
236245 liquibase .update (new Contexts (), new LabelExpression ());
237246 }
238247
@@ -246,5 +255,4 @@ private String liquibaseFile() {
246255 }
247256 return changeLogFile ;
248257 }
249-
250258}
0 commit comments