@ -85,24 +85,44 @@ abstract class HttpAuthMethod {
public HttpAuthMethod method ( String hdr ) {
public HttpAuthMethod method ( String hdr ) {
return None . INSTANCE ;
return None . INSTANCE ;
}
}
@Override
public String getSchemeName ( ) {
return "None" ; //$NON-NLS-1$
}
} ,
} ,
BASIC {
BASIC {
@Override
@Override
public HttpAuthMethod method ( String hdr ) {
public HttpAuthMethod method ( String hdr ) {
return new Basic ( ) ;
return new Basic ( ) ;
}
}
@Override
public String getSchemeName ( ) {
return "Basic" ; //$NON-NLS-1$
}
} ,
} ,
DIGEST {
DIGEST {
@Override
@Override
public HttpAuthMethod method ( String hdr ) {
public HttpAuthMethod method ( String hdr ) {
return new Digest ( hdr ) ;
return new Digest ( hdr ) ;
}
}
@Override
public String getSchemeName ( ) {
return "Digest" ; //$NON-NLS-1$
}
} ,
} ,
NEGOTIATE {
NEGOTIATE {
@Override
@Override
public HttpAuthMethod method ( String hdr ) {
public HttpAuthMethod method ( String hdr ) {
return new Negotiate ( hdr ) ;
return new Negotiate ( hdr ) ;
}
}
@Override
public String getSchemeName ( ) {
return "Negotiate" ; //$NON-NLS-1$
}
} ;
} ;
/ * *
/ * *
* Creates a HttpAuthMethod instance configured with the provided HTTP
* Creates a HttpAuthMethod instance configured with the provided HTTP
@ -112,6 +132,13 @@ abstract class HttpAuthMethod {
* @return a configured HttpAuthMethod instance
* @return a configured HttpAuthMethod instance
* /
* /
public abstract HttpAuthMethod method ( String hdr ) ;
public abstract HttpAuthMethod method ( String hdr ) ;
/ * *
* @return the name of the authentication scheme in the form to be used
* in HTTP authentication headers as specified in RFC2617 and
* RFC4559
* /
public abstract String getSchemeName ( ) ;
}
}
static final String EMPTY_STRING = "" ; //$NON-NLS-1$
static final String EMPTY_STRING = "" ; //$NON-NLS-1$
@ -270,7 +297,7 @@ abstract class HttpAuthMethod {
void configureRequest ( final HttpConnection conn ) throws IOException {
void configureRequest ( final HttpConnection conn ) throws IOException {
String ident = user + ":" + pass ; //$NON-NLS-1$
String ident = user + ":" + pass ; //$NON-NLS-1$
String enc = Base64 . encodeBytes ( ident . getBytes ( "UTF-8" ) ) ; //$NON-NLS-1$
String enc = Base64 . encodeBytes ( ident . getBytes ( "UTF-8" ) ) ; //$NON-NLS-1$
conn . setRequestProperty ( HDR_AUTHORIZATION , type . n ame( )
conn . setRequestProperty ( HDR_AUTHORIZATION , type . getSchemeN ame( )
+ " " + enc ) ; //$NON-NLS-1$
+ " " + enc ) ; //$NON-NLS-1$
}
}
}
}
@ -357,7 +384,7 @@ abstract class HttpAuthMethod {
v . append ( e . getValue ( ) ) ;
v . append ( e . getValue ( ) ) ;
v . append ( '"' ) ;
v . append ( '"' ) ;
}
}
conn . setRequestProperty ( HDR_AUTHORIZATION , type . n ame( )
conn . setRequestProperty ( HDR_AUTHORIZATION , type . getSchemeN ame( )
+ " " + v ) ; //$NON-NLS-1$
+ " " + v ) ; //$NON-NLS-1$
}
}
@ -514,7 +541,7 @@ abstract class HttpAuthMethod {
byte [ ] token = context . initSecContext ( prevToken , 0 ,
byte [ ] token = context . initSecContext ( prevToken , 0 ,
prevToken . length ) ;
prevToken . length ) ;
conn . setRequestProperty ( HDR_AUTHORIZATION , getType ( ) . n ame( )
conn . setRequestProperty ( HDR_AUTHORIZATION , getType ( ) . getSchemeN ame( )
+ " " + Base64 . encodeBytes ( token ) ) ; //$NON-NLS-1$
+ " " + Base64 . encodeBytes ( token ) ) ; //$NON-NLS-1$
} catch ( GSSException e ) {
} catch ( GSSException e ) {
IOException ioe = new IOException ( ) ;
IOException ioe = new IOException ( ) ;