]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/ext/test/org/argeo/cms/security/RunHttpSpnego.java
1 package org
.argeo
.cms
.security
;
2 import java
.io
.BufferedReader
;
3 import java
.io
.InputStream
;
4 import java
.io
.InputStreamReader
;
5 import java
.net
.Authenticator
;
6 import java
.net
.PasswordAuthentication
;
9 public class RunHttpSpnego
{
11 static final String kuser
= "mbaudier@ARGEO.EU"; // your account name
12 static final String kpass
= "test"; // retrieve password for your account
14 static class MyAuthenticator
extends Authenticator
{
15 public PasswordAuthentication
getPasswordAuthentication() {
16 // I haven't checked getRequestingScheme() here, since for NTLM
17 // and Negotiate, the usrname and password are all the same.
18 System
.err
.println("Feeding username and password for " + getRequestingScheme());
19 return (new PasswordAuthentication(kuser
, kpass
.toCharArray()));
23 public static void main(String
[] args
) throws Exception
{
24 Authenticator
.setDefault(new MyAuthenticator());
25 URL url
= new URL(args
[0]);
26 InputStream ins
= url
.openConnection().getInputStream();
27 BufferedReader reader
= new BufferedReader(new InputStreamReader(ins
));
29 while((str
= reader
.readLine()) != null)
30 System
.out
.println(str
);