Skip to content

Commit

Permalink
Update plugin-api to 4.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fdaugan committed Nov 24, 2023
1 parent e02a1d8 commit f799e35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.ligoj.api</groupId>
<artifactId>plugin-parent</artifactId>
<version>4.1.1</version>
<version>4.1.2</version>
<relativePath />
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package org.ligoj.app.plugin.id.resource;

import jakarta.ws.rs.NotAuthorizedException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -19,7 +20,6 @@

import javax.cache.annotation.CacheKey;
import javax.cache.annotation.CacheResult;
import jakarta.ws.rs.NotAuthorizedException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -60,13 +60,13 @@ public abstract class AbstractPluginIdResource<U extends IUserRepository> extend

@Override
public Authentication authenticate(final Authentication authentication, final String node, final boolean primary) {
@SuppressWarnings("unchecked")
final var repository = (U) getSelf().getConfiguration(node).getUserRepository();
@SuppressWarnings("unchecked") final var repository = (U) getSelf().getConfiguration(node).getUserRepository();

// Authenticate the user
if (repository.authenticate(authentication.getName(), (String) authentication.getCredentials())) {
final var user = repository.authenticate(authentication.getName(), (String) authentication.getCredentials());
if (user != null) {
// Return a new authentication based on resolved application user
return primary ? authentication
return primary ? new UsernamePasswordAuthenticationToken(user.getId(), null)
: new UsernamePasswordAuthenticationToken(toApplicationUser(repository, authentication), null);
}
throw new BadCredentialsException("");
Expand Down Expand Up @@ -99,7 +99,7 @@ protected String toApplicationUser(final U repository, final Authentication auth
/**
* Return the local identity property name. In the most case, will be a constant, but in some cases, the property
* name is determined dynamically depending on the available authentication principal
*
*
* @param repository The current repository.
* @param authentication The current authentication.
* @return The property name.
Expand Down Expand Up @@ -207,7 +207,7 @@ public IamConfiguration getConfiguration(final String node) {

/**
* Ensure the configuration is loaded for the given node. Cache is involved.
*
*
* @param node The node identifier, also used as cache key.
* @return The IAM configuration related to the given node.
*/
Expand All @@ -228,7 +228,7 @@ public boolean ensureCachedConfiguration(@CacheKey final String node) {
/**
* Refresh the IAM configuration related to the given node. The {@link #nodeConfigurations} is replaced by a new
* {@link IamConfiguration} instance.
*
*
* @param node The node identifier.
* @return The IAM configuration related to the given node.
*/
Expand All @@ -247,7 +247,7 @@ protected IamConfiguration refreshConfiguration(final String node) {

/**
* Copy the repository details to the IAM configuration.
*
*
* @param iam The target IAM configuration.
* @param repository The current {@link IUserRepository} instance.
*/
Expand Down

0 comments on commit f799e35

Please sign in to comment.