how to override filters configured in a java file? -


i writing plugin nexus oss , need use new filter instead of filter prescribed in nexus oss .

in earlier versions of nexus oss ,all filters defined in web.xml follows

<filter>     <filter-name>nexusfilter</filter-name>     <filter-class>org.sonatype.nexus.security.filter.nexusjsecurityfilter</filter-class>     <init-param>       <param-name>config</param-name>       <param-value>       [filters]         authcbasic = org.sonatype.nexus.security.filter.authc.nexussecurehttpauthenticationfilter         authcbasic.applicationname = sonatype nexus repository manager api         authcbasic.fakeauthscheme = false          authcnxbasic = org.sonatype.nexus.security.filter.authc.nexussecurehttpauthenticationfilter         authcnxbasic.applicationname = sonatype nexus repository manager api (specialized auth)         authcnxbasic.fakeauthscheme = true 

so used modify web.xml take our filter instead of nexussecurehttpauthenticationfilter of nexus oss , job done .

but in latest version of nexus oss doing filter configiurations in java file

@named public class nexussecurityfiltermodule     extends abstractmodule {     @override     protected void configure()     {         requirebinding( filterchainresolver.class );          bindauthcfilter( "authcbasic", false, "sonatype nexus repository manager api" );         bindauthcfilter( "authcnxbasic", true, "sonatype nexus repository manager api (specialized auth)" ); . . . private void bindauthcfilter( string name, boolean fakeauthschem, string applicationname )     {         nexussecurehttpauthenticationfilter filter = new nexussecurehttpauthenticationfilter();         filter.setapplicationname( applicationname );         filter.setfakeauthscheme( boolean.tostring( fakeauthschem ) );         bindnamedfilter( name, filter );     } . . private void bindnamedfilter( string name, filter filter )     {         key<filter> key = key.get( filter.class, names.named( name ) );         bind( key ).toprovider( defer( filter ) ).in( scopes.singleton );     } 

full java code of filter configuration here nexussecurityfiltermodule.java.

so don't know how make nexus oss use our filter instead of nexussecurityfiltermodule.java. impediment here java file cannot modify did in web.xml . there way can override filter have configured in java file , make nexus oss use our custom filter.

i have solution not correct solution. anyway solve problem. replace javafile in jar usign decompile change code u want , againt inject in jar here step, 1. using java decompiler decompile class jar, here (nexussecurityfiltermodule.class) , java file (nexussecurityfiltermodule.java) 2. change filer u want. 3. compile class nexussecurityfiltermodule.class 4. inject jar. jar -uvf <jar-name> <javaclass> done. happy update!!


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -