This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Title":"RESTful Web APIs", | |
| "Price":"$31.92", | |
| "Paperback":"408 pages", | |
| "Language":"English" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Create SSL Configurator | |
| SslConfigurator sslConfigurator = SslConfigurator.newInstance(); | |
| //Register a keystore | |
| sslConfigurator.trustStoreFile("dwstart.keystore") | |
| .trustStorePassword("crimson"); | |
| //Create SSL Context | |
| SSLContext sSLContext = sslConfigurator.createSSLContext(); | |
| //Obtain client | |
| Client client = ClientBuilder | |
| .newBuilder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class IntegrationTest { | |
| @ClassRule | |
| public static final DropwizardAppRule<DWGettingStartedConfiguration> RULE | |
| = new DropwizardAppRule<>(DWGettingStartedApplication.class, | |
| "config.yml"); | |
| @Test | |
| public void testGetGreeting() { | |
| String expected = "Hello world!"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Server configuration. | |
| server: | |
| applicationConnectors: | |
| - type: http | |
| port: 8080 | |
| - type: https | |
| port: 8443 | |
| keyStorePath: dwstart.keystore | |
| keyStorePassword: crimson | |
| validateCerts: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| keytool -genkeypair | |
| -keyalg RSA | |
| -dname "CN=localhost" | |
| -keystore dwstart.keystore | |
| -keypass crimson | |
| -storepass crimson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Server configuration. | |
| server: | |
| applicationConnectors: | |
| - type: http | |
| port: 8085 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void run(final DWGettingStartedConfiguration configuration, | |
| final Environment environment) { | |
| environment.jersey().register(AuthFactory.binder( | |
| new BasicAuthFactory<>( | |
| new GreetingAuthenticator(configuration.getLogin(), | |
| configuration.getPassword()), | |
| "SECURITY REALM", | |
| User.class))); | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GreetingAuthenticator | |
| implements Authenticator<BasicCredentials, User> { | |
| private String login; | |
| private String password; | |
| public GreetingAuthenticator(String login, String password) { | |
| this.login = login; | |
| this.password = password; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DWGettingStartedConfiguration extends Configuration { | |
| @NotNull | |
| private String login; | |
| @NotNull | |
| private String password; | |
| @JsonProperty | |
| public String getLogin() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Configuration file for DWGettingStarted application. | |
| --- | |
| # User login. | |
| login: javaeeeee | |
| # User password. | |
| password: crimson |