package org.argeo.cms.internal.http.client;
-import java.net.URI;
import java.net.URL;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.DefaultHttpParams;
import org.apache.commons.httpclient.params.HttpParams;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.internal.runtime.KernelConstants;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSManager;
/** Implementation of the SPNEGO auth scheme. */
public class SpnegoAuthScheme implements AuthScheme {
- private final static Log log = LogFactory.getLog(SpnegoAuthScheme.class);
+// private final static Log log = LogFactory.getLog(SpnegoAuthScheme.class);
public static final String NAME = "Negotiate";
private final static Oid KERBEROS_OID;
private boolean complete = false;
private String realm;
- private String tokenStr;
@Override
public void processChallenge(String challenge) throws MalformedChallengeException {
-// if(tokenStr!=null){
-// log.error("Received challenge while there is a token. Failing.");
-// complete = false;
-// }
+ // if(tokenStr!=null){
+ // log.error("Received challenge while there is a token. Failing.");
+ // complete = false;
+ // }
}
@Override
public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException {
-// log.debug("authenticate " + method + " " + uri);
-// return null;
+ // log.debug("authenticate " + method + " " + uri);
+ // return null;
throw new UnsupportedOperationException();
}
} catch (URIException e1) {
throw new IllegalStateException("Cannot authenticate", e1);
}
- String serverPrinc = "HTTP@" + hostname;
+ String serverPrinc = KernelConstants.DEFAULT_KERBEROS_SERVICE + "@" + hostname;
try {
// Get service's principal name
throw new AuthenticationException("Cannot authenticate to " + serverPrinc, e);
}
}
-
- private void doAuthenticate(URI uri){
-
- }
public static void main(String[] args) {
if (args.length == 0) {
ArrayList<String> schemes = new ArrayList<>();
schemes.add(SpnegoAuthScheme.NAME);
params.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
- params.setParameter(CredentialsProvider.PROVIDER, new SpnegoCredentialProvider());
+ params.setParameter(CredentialsProvider.PROVIDER, new HttpCredentialProvider());
int responseCode = Subject.doAs(lc.getSubject(), new PrivilegedExceptionAction<Integer>() {
public Integer run() throws Exception {