Hi,
I try to get run Digest Authentication in a client (Eclipse RCP) Server (Tomcat/Spring) application. I configured Digest configuration on server:
First authentication works fine!Code:<bean id="digestAuthenticationFilter" class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter"> <property name="userDetailsService" ref="ldapUserDetailsService" /> <property name="authenticationEntryPoint" ref="digestEntryPoint" /> </bean> <bean id="digestEntryPoint" class="org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint"> <property name="realmName" value="EAP Realm" /> <property name="key" value="acegi" /> <!-- 8h --> <property name="nonceValiditySeconds" value="28800" /> </bean> <bean id="ldapUserDetailsService" class="org.springframework.security.ldap.userdetails.LdapUserDetailsService"> <constructor-arg ref="userSearch"/> <constructor-arg ref="authoritiesPopulator"/> </bean>
The second request always uses Basic Authentication (i can see it in the request header in debug mode).
I use the following implementation of CommonsHttpInvokerRequestExecutor on the client:
Although I set all Digest information, every request comes with Basic authentication on the server.Code:public class AuthenticatedCommonsHttpInvokerRequestExecutor extends CommonsHttpInvokerRequestExecutor { @Override protected void executePostMethod(HttpInvokerClientConfiguration config, HttpClient httpClient, PostMethod postMethod) throws IOException { Authentication auth = SecurityContextHolder.getContext() .getAuthentication(); if (auth != null) { String username = auth.getPrincipal().toString(); String password = auth.getCredentials().toString(); Credentials credentials = new UsernamePasswordCredentials(username, password); List<String> authPrefs = new java.util.ArrayList<String>(1); authPrefs.add(AuthPolicy.DIGEST); httpClient.getParams().setParameter( AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); httpClient.getParams().setAuthenticationPreemptive( auth.isAuthenticated()); httpClient.getState().setCredentials(AuthScope.ANY, credentials); } super.executePostMethod(config, httpClient, postMethod); } }
Does anyone know the issue?
Regards
phil


Reply With Quote