Skip to content

making the proxy with NTLM work (for grizzly provider) #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/src/main/java/com/ning/http/client/ProxyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public String toString() {
private int port;
private String ntlmDomain = System.getProperty("http.auth.ntlm.domain", "");

private boolean isBasic = true;
/*private boolean isBasic = true;

public boolean isBasic() {
return isBasic;
}

public void setBasic(boolean isBasic) {
this.isBasic = isBasic;
}
}*/

public ProxyServer(final Protocol protocol, final String host, final int port, String principal, String password) {
this.protocol = protocol;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.ning.http.client.providers.grizzly;

import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;

import com.ning.http.util.Base64;

public class GSSSPNEGOWrapper {

private static final String KERBEROS_OID = "1.2.840.113554.1.2.2";

static GSSManager getManager() {
return GSSManager.getInstance();
}

static byte[] generateGSSToken(
final byte[] input, final Oid oid, final String authServer) throws GSSException {
byte[] token = input;
if (token == null) {
token = new byte[0];
}
GSSManager manager = getManager();
GSSName serverName = manager.createName("HTTP@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
GSSContext gssContext = manager.createContext(
serverName.canonicalize(oid), oid, null, GSSContext.DEFAULT_LIFETIME);
gssContext.requestMutualAuth(true);
gssContext.requestCredDeleg(true);
return gssContext.initSecContext(token, 0, token.length);
}

public static String generateToken(String authServer)
{
String returnVal = "";
Oid oid;
try {
oid = new Oid(KERBEROS_OID);
byte[] token = GSSSPNEGOWrapper.generateGSSToken(null, oid, authServer);
returnVal = new String(Base64.encode(token));
} catch (GSSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return returnVal;
}
}
Loading