Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/136#discussion_r70873672
  
    --- Diff: src/java/org/apache/nutch/api/NutchServer.java ---
    @@ -113,19 +114,43 @@ public NutchServer() {
         component = new Component();
         component.getLogger().setLevel(Level.parse(logLevel));
     
    -    // Add a new HTTP server listening on defined port.
    -    component.getServers().add(Protocol.HTTP, port);
    +    AuthenticationTypeEnum authenticationType = 
configManager.get(ConfigResource.DEFAULT).getEnum("restapi.auth", 
AuthenticationTypeEnum.NONE);
    +
    +    if (authenticationType == AuthenticationTypeEnum.SSL) {
    +      // Add a new HTTPS server listening on defined port.
    +      Server server = component.getServers().add(Protocol.HTTPS, port);
    +
    +      Series parameters = server.getContext().getParameters();
    +      parameters.add("sslContextFactory", 
"org.restlet.engine.ssl.DefaultSslContextFactory");
    +
    +      String keyStorePath = configManager.get(ConfigResource.DEFAULT)
    +              .get("restapi.auth.ssl.storepath", 
"etc/nutch-ssl.keystore.jks");
    +      parameters.add("keyStorePath", keyStorePath);
    +
    +      String keyStorePassword = configManager.get(ConfigResource.DEFAULT)
    +              .get("restapi.auth.ssl.storepass", "password");
    +      parameters.add("keyStorePassword", keyStorePassword);
    +
    +      String keyPassword = configManager.get(ConfigResource.DEFAULT)
    +              .get("restapi.auth.ssl.keypass", "password");
    +      parameters.add("keyPassword", keyPassword);
    +
    +      parameters.add("keyStoreType", "JKS");
    +      LOG.info("SSL Authentication is set for NutchServer");
    +    } else {
    +      // Add a new HTTP server listening on defined port.
    +      component.getServers().add(Protocol.HTTP, port);
    +    }
     
         Context childContext = component.getContext().createChildContext();
         JaxRsApplication application = new JaxRsApplication(childContext);
         application.add(this);
         application.setStatusService(new ErrorStatusService());
         childContext.getAttributes().put(NUTCH_SERVER, this);
     
    -    AuthenticationTypeEnum authenticationType = 
configManager.get(ConfigResource.DEFAULT).getEnum("restapi.auth", 
AuthenticationTypeEnum.NONE);
    -
         switch (authenticationType) {
           case NONE:
    +      case SSL:
             // Attach the application without security
    --- End diff --
    
    @lewismc I've removed unnecessary comment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to