Search code examples
javafilterstrutsopenid

MitreId Client authentication filter configuration


i am fairly new to the struts environment and i have been looking around for this kind of thing but cannot find it anywhere else. my problem is that i need to configure the OIDAuthenticationFilter. although there is an example in the MitreId website, i cant seem to translate it into the framework i am using which is struts.

what is in the example that i have seen is using some kind of spring security which i am not sure how it works but i understand what it is doing/configuring:

https://github.com/mitreid-connect/OpenID-Connect-Java-Spring-Server/wiki/Client-configuration

the code is too large and i am not going to paste it here for that reason...

in my code, in web.xml is have the following so far:

<filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>com.something.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>
    <url-pattern>*.do</url-pattern>
</filter-mapping>

and the authentication filter calss is extending the OIDAuthenticationFilter:

public class AuthenticationFilter extends OIDCAuthenticationFilter {


public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

}

}

i know how to use it in struts and setting the rest up in web.xml, but what i dont know is how do i translate what the example is doing or how it is doing to the way i am doing. as i can see, many things are given values and many classes have parameters being set in the example.

thanks :)


Solution

  • After looking at it for a few days, i have analysed the filter configurations in the link given. i have come to a conclusion that all i had to do is to instantiate the objects needed to configure the filter, and finally set the objects in the filter. this would then look similar to the configuration in the link which uses spring security. but of course, instead of beans i would use java.

    here is what it looked like in the end:

    this.setAuthenticationManager(new OAuth2AuthenticationManager());
    this.setIssuerService(new StaticSingleIssuerService());
    this.setServerConfigurationService(new StaticServerConfigurationService());
    this.setClientConfigurationService(new StaticClientConfigurationService());
    this.setAuthRequestOptionsService(new StaticAuthRequestOptionsService());
    this.setAuthRequestUrlBuilder(new PlainAuthRequestUrlBuilder());
    

    and from here, simply by doing a

    this.get....();
    

    you would then be able to get the object you created above as new and configure according to the link that was given as there are sets and gets for everything.

    i did not think it would be that simple as it is the first time i deal with filters and they sound more complicated than they actually are.