MER-C/wiki-java

Feature Request: Allow initial Login with .htaccess

SomeStrangeName opened this issue · 2 comments

Looks like the current Wiki class does not allow to open an API connection if the mediawiki installation is additionally protected with an .htaccess file.

Would be nice if you could add that functionality.

Ok, a simple solution would be to extend the calls this way:

package org.wikipedia;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;

public class MyWiki extends Wiki {
    public MyWiki(String url, String api) {
    super(url,api);
    }

    @Override
    protected URLConnection makeConnection(String url) throws IOException
    {
    URL url1 = new URL(url);
    URLConnection con = url1.openConnection();
    con.setRequestProperty("Authorization", "Basic "+new sun.misc.BASE64Encoder().encode ("user:password".getBytes()));
    return con;
    }
}

Of course User and passwort should not be hard coded.

MER-C commented

That is the intended solution. Since this is a rare use case, I don't see the need to add support for it.