AutoLoginFilter Import Failed in Class file

Jamie Sammons, modified 2 Years ago. New Member Posts: 18 Join Date: 4/11/23 Recent Posts

I am trying to override the implementation of com.liferay.portal.security.sso.openid.connect.internal.servlet.filter.auto.login.OpenIdConnectAutoLoginFilter to set some additional session data to the session before granting the authentication. For this while I am creating my own filter which extends com.liferay.portal.servlet.filters.autologin.AutoLoginFilter the eclipse showing class not found in the import statement.

Below is the Custom Filter class I am trying to create. The import com.liferay.portal.servlet.filters.autologin.AutoLoginFilter;  shows could not resolve;

import com.liferay.portal.servlet.filters.autologin.AutoLoginFilter;
import javax.servlet.Filter;
import org.osgi.service.component.annotations.Component;
import com.liferay.portal.security.sso.openid.connect.constants.OpenIdConnectConstants;


@Component(
	configurationPid = "com.liferay.portal.security.sso.openid.connect.configuration.OpenIdConnectConfiguration",
	property = {
		"after-filter=Virtual Host Filter", "servlet-context-name=",
		"servlet-filter-name=SSO OpenId Connect Auto Login Filter",
		"url-pattern=" + OpenIdConnectConstants.REDIRECT_URL_PATTERN
	},
	service = {Filter.class}
)
public class CustomOpenIdConnectAutoLoginFilter extends AutoLoginFilter {

}

Below is the present gradle.build file

dependencies {
	compileOnly group: "com.liferay.portal", name: "release.portal.api"

	cssBuilder group: "com.liferay", name: "com.liferay.css.builder", version: "3.1.0"
	
	compileOnly group: "com.liferay", name: "com.liferay.portal.security.sso.openid.connect.impl", version: "7.0.21"

	compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.0.0"

	compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
	
}

Do I need to add any gradle dependancy to get this class in my portlet module.
Let me know your suggestions.

 

 

thumbnail
Olaf Kock, modified 2 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

AutoLoginFilter is packaged in portal-impl, which is not exported - thus you can't have external modules depend on it.

That being said, you can just add another filter that is completely independent of AutoLoginFilter and do the additional work there - you don't need to depend on that component just to provide more data to the session. Your filters have a declarable order (as you're already using in your sample), so you can pick where your filter should be in the chain - before or after the original AutoLoginFilter.