cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How is the LoginInformationHandler to be used

pgaeckle
Explorer
0 Likes
366

Hi,

I'm try to extend the Login page with an additional field to be verified as part of the login process.
I therefore created a backoffice extension and extended the BackofficeAuthenticationProvider.

In there I planned to validate the additional field.
The class is named ExtendedBackofficeAuthenticationProvider and it overrides the method 

public Authentication authenticate(Authentication authentication)

The ExtendedBackofficeAuthenticationProvider is located here:
<extensionname>/backoffice/src/com/company/backoffice/security/ExtendedBackofficeAuthenticationProvider

In there I want to access the additional field code which is added to the Backoffice according to this help page.

My bean definitions in <extensionname>-backoffice-spring.xml

<alias name="extendedLoginInformationHandler" alias="loginInformationHandler"/>
<bean id="extendedLoginInformationHandler"
	  parent="defaultLoginInformationHandler"
	  init-method="init" scope="session">
	<property name="configuration">
		<list merge="true">
			<bean class="com.hybris.cockpitng.handler.login.LoginInformationConfigData">
				<constructor-arg value="code"/>
				<constructor-arg value="login.code.label"/>
				<constructor-arg value="java.lang.String"/>
				<constructor-arg>
					<value type="java.lang.Integer">3</value>
				</constructor-arg>
			</bean>
		</list>
	</property>
</bean>

And the Bean definition of the ExtendedBackofficeAuthenticationProvider:

<alias name="extendedBackofficeAuthenticationProvider" alias="backofficeAuthenticationProvider"/>
<bean id="extendedBackofficeAuthenticationProvider" parent="platformBackofficeAuthenticationProvider"
	  class="com.company.backoffice.security.ExtendedBackofficeAuthenticationProvider">
	<constructor-arg name="userService" ref="userService"/>
	<constructor-arg name="userDetailsService" ref="backofficeUserDetailsService"/>
	<constructor-arg name="loginInformationHandler" ref="loginInformationHandler"/>
	<lookup-method name="getBackofficeAuthEventListener" bean="backofficeAuthEventListener"/>
</bean>

The field is shown on the login page as expected and login still works but accessing the loginInformationHandler querying the field for username and code is not providing any value.
For the username I could also use the authentication handed into the authenticate method but how can I access my custom field code?

Checking the fields with the following code always result in an empty string

loginInformationHandler.getLoginInformation("code")

Whereas accessing via Registry shows the entered value.

((LoginInformationHandler)Registry.getApplicationContext().getBean("mfaLoginInformationHandler")).getLoginInformation("code")

I could potentially use it like that but I'd like to understand what is wrong.

Accepted Solutions (0)

Answers (0)

Ask a Question