Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.97 KB | None | 0 0
  1. package org.magnum.mobilecloud.video;
  2.  
  3. import org.magnum.mobilecloud.video.repository.VideoRepository;
  4. import org.springframework.boot.SpringApplication;
  5. import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  6. import org.springframework.context.annotation.ComponentScan;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.context.annotation.Import;
  9. import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  10. import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
  11. import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  12.  
  13. //Tell Spring to automatically inject any dependencies that are marked in
  14. //our classes with @Autowired
  15. @EnableAutoConfiguration
  16. // Tell Spring to turn on WebMVC (e.g., it should enable the DispatcherServlet
  17. // so that requests can be routed to our Controllers)
  18. @EnableWebMvc
  19.  
  20. @Import(OAuth2SecurityConfiguration.class)
  21.  
  22. @EnableJpaRepositories(basePackageClasses = VideoRepository.class)
  23.  
  24. // Tell Spring that this object represents a Configuration for the
  25. // application
  26. @Configuration
  27. // Tell Spring to go and scan our controller package (and all sub packages) to
  28. // find any Controllers or other components that are part of our applciation.
  29. // Any class in this package that is annotated with @Controller is going to be
  30. // automatically discovered and connected to the DispatcherServlet.
  31. @ComponentScan
  32. public class Application extends RepositoryRestMvcConfiguration {
  33.  
  34.     // The app now requires that you pass the location of the keystore and
  35.     // the password for your private key that you would like to setup HTTPS
  36.     // with. In Eclipse, you can set these options by going to:
  37.     //    1. Run->Run Configurations
  38.     //    2. Under Java Applications, select your run configuration for this app
  39.     //    3. Open the Arguments tab
  40.     //    4. In VM Arguments, provide the following information to use the
  41.     //       default keystore provided with the sample code:
  42.     //
  43.     //       -Dkeystore.file=src/main/resources/private/keystore -Dkeystore.pass=changeit
  44.     //
  45.     //    5. Note, this keystore is highly insecure! If you want more securtiy, you
  46.     //       should obtain a real SSL certificate:
  47.     //
  48.     //       http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html
  49.     //
  50.     // Tell Spring to launch our app!
  51.     public static void main(String[] args) {
  52.         SpringApplication.run(Application.class, args);
  53.     }
  54.  
  55.    
  56.     // This version uses the Tomcat web container and configures it to
  57.     // support HTTPS. The code below performs the configuration of Tomcat
  58.     // for HTTPS. Each web container has a different API for configuring
  59.     // HTTPS.
  60.     //
  61.     // The app now requires that you pass the location of the keystore and
  62.     // the password for your private key that you would like to setup HTTPS
  63.     // with. In Eclipse, you can set these options by going to:
  64.     //    1. Run->Run Configurations
  65.     //    2. Under Java Applications, select your run configuration for this app
  66.     //    3. Open the Arguments tab
  67.     //    4. In VM Arguments, provide the following information to use the
  68.     //       default keystore provided with the sample code:
  69.     //
  70.     //       -Dkeystore.file=src/main/resources/private/keystore -Dkeystore.pass=changeit
  71.     //
  72.     //    5. Note, this keystore is highly insecure! If you want more securtiy, you
  73.     //       should obtain a real SSL certificate:
  74.     //
  75.     //       http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html
  76.     //
  77.     /*
  78.     @Bean
  79.     EmbeddedServletContainerCustomizer containerCustomizer(
  80.             @Value("${keystore.file:src/main/resources/private/keystore}") String keystoreFile,
  81.             @Value("${keystore.pass:changeit}") final String keystorePass) throws Exception {
  82.  
  83.         // If you were going to reuse this class in another
  84.         // application, this is one of the key sections that you
  85.         // would want to change
  86.        
  87.         final String absoluteKeystoreFile = new File(keystoreFile).getAbsolutePath();
  88.  
  89.         return new EmbeddedServletContainerCustomizer () {
  90.  
  91.             @Override
  92.             public void customize(ConfigurableEmbeddedServletContainer container) {
  93.                     TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
  94.                     tomcat.addConnectorCustomizers(
  95.                             new TomcatConnectorCustomizer() {
  96.                                 @Override
  97.                                 public void customize(Connector connector) {
  98.                                     connector.setPort(8443);
  99.                                     connector.setSecure(true);
  100.                                     connector.setScheme("https");
  101.  
  102.                                     Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
  103.                                     proto.setSSLEnabled(true);
  104.                                     proto.setKeystoreFile(absoluteKeystoreFile);
  105.                                     proto.setKeystorePass(keystorePass);
  106.                                     proto.setKeystoreType("JKS");
  107.                                     proto.setKeyAlias("tomcat");
  108.                                 }
  109.                             });
  110.            
  111.             }
  112.         };
  113.     }*/
  114.    
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement