= AuthenticationConverter
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defines an SPI to attempt to convert a Spring _Authentication_ into an Apache Causeway xref:refguide:applib:index/services/user/UserMemento.adoc[UserMemento] .

The _Authentication_ will have already been verified as having been _Authentication#isAuthenticated() authenticated_ .

Implementations should be defined as Spring _Component_ s and added to the _Configuration application context_ either by being _Import imported_ explicitly or implicitly through _ComponentScan_ .

All known converters are checked one by one, but checking stops once one converter has successively converted the _Authentication_ into a xref:refguide:applib:index/services/user/UserMemento.adoc[UserMemento] (in other words, chain-of-responsibility pattern). Use the _jakarta.annotation.Priority_ annotation to influence the order in which converter implementations are checked.

== API

[source,java]
.AuthenticationConverter.java
----
interface AuthenticationConverter {
  UserMemento convert(Authentication authentication)     // <.>
}
----

<.> xref:#convert_Authentication[convert(Authentication)]
+
--
Attempt to convert a Spring _Authentication_ (which will have been _Authentication#isAuthenticated() authenticated_ ) into a xref:refguide:applib:index/services/user/UserMemento.adoc[UserMemento] .
--

== Members

[#convert_Authentication]
=== convert(Authentication)

Attempt to convert a Spring _Authentication_ (which will have been _Authentication#isAuthenticated() authenticated_ ) into a xref:refguide:applib:index/services/user/UserMemento.adoc[UserMemento] .

There are many different implementations of _Authentication_ , so the implementation should be targeted at a specific implementation.

The framework provides some default implementations for the most common use cases.
