You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by kamaci <gi...@git.apache.org> on 2016/06/26 22:16:40 UTC

[GitHub] nutch pull request #128: NUTCH-2289 SSL support for Nutch 2.X REST API.

GitHub user kamaci opened a pull request:

    https://github.com/apache/nutch/pull/128

    NUTCH-2289 SSL support for Nutch 2.X REST API.

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kamaci/nutch NUTCH-2289

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nutch/pull/128.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #128
    
----
commit 52ffc5a983f261570fd25f10f2f8fcf70d543c88
Author: Furkan KAMACI <fu...@gmail.com>
Date:   2016-06-19T20:27:15Z

    NUTCH-2284 Basic Authentication support for Nutch 2.X REST API.

commit e147b43ac0551548acff14576e2156e3b5f7e9fa
Author: Furkan KAMACI <fu...@gmail.com>
Date:   2016-06-26T14:45:46Z

    NUTCH-2285 Digest Authentication support for Nutch 2.X REST API.

commit 38a636a190fc37051868f7ca101b3537057972ad
Author: Furkan KAMACI <fu...@gmail.com>
Date:   2016-06-26T17:49:31Z

    NUTCH-2288 Upgrade Restlet to 2.3.7.

commit c0b2f54d3cab5c6dfaa334b5a1acb899fe3fca5e
Author: Furkan KAMACI <fu...@gmail.com>
Date:   2016-06-26T22:16:23Z

    NUTCH-2289 SSL support for Nutch 2.X REST API.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request #128: NUTCH-2289 SSL support for Nutch 2.X REST API.

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/128#discussion_r68630587
  
    --- Diff: src/java/org/apache/nutch/api/NutchServer.java ---
    @@ -99,17 +114,70 @@ 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);
     
    -    // Attach the application.
    -    component.getDefaultHost().attach(application);
    +    if (authenticationType == AuthenticationTypeEnum.NONE || authenticationType == AuthenticationTypeEnum.SSL ) {
    +      component.getDefaultHost().attach(application);
    +      return;
    +    }
    +
    +    String username = configManager.get(ConfigResource.DEFAULT).get("restapi.auth.username", "admin");
    +    String password = configManager.get(ConfigResource.DEFAULT).get("restapi.auth.password", "nutch");
    +
    +    MapVerifier mapVerifier = new MapVerifier();
    +    mapVerifier.getLocalSecrets().put(username, password.toCharArray());
    +
    +    if (authenticationType == AuthenticationTypeEnum.BASIC) {
    --- End diff --
    
    Please see comment on other issue for use of switch block.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request #128: NUTCH-2289 SSL support for Nutch 2.X REST API.

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/128#discussion_r68630436
  
    --- Diff: conf/nutch-default.xml ---
    @@ -1435,4 +1435,60 @@
       </description>
     </property>
     
    +<property>
    +  <name>restapi.auth</name>
    +  <value>NONE</value>
    +  <description>
    +    Configures authentication type for communicating with RESTAPI. Valid values are BASIC, DIGEST, SSL and NONE.
    +    When no authentication type is defined NONE will be used as default which does not provide security.
    +    Use the restapi.auth.username and restapi.auth.auth.password properties to configure
    --- End diff --
    
    Typo again


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request #128: NUTCH-2289 SSL support for Nutch 2.X REST API.

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci closed the pull request at:

    https://github.com/apache/nutch/pull/128


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---