Search in sources :

Example 1 with IdentityLookup

use of io.gravitee.rest.api.idp.api.identity.IdentityLookup in project gravitee-management-rest-api by gravitee-io.

the class CompositeIdentityManager method search.

@Override
public Collection<SearchableUser> search(String query) {
    Set<SearchableUser> users = new HashSet<>();
    for (IdentityLookup identityLookup : identityLookups) {
        if (identityLookup.searchable()) {
            Collection<User> lookupUsers = identityLookup.search(query);
            if (lookupUsers != null) {
                boolean allowEmailInSearchResults = identityLookup.allowEmailInSearchResults();
                users.addAll(lookupUsers.stream().map(user -> new DefaultSearchableUser(user, allowEmailInSearchResults)).collect(Collectors.toSet()));
            }
        }
    }
    return users;
}
Also used : SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) IdentityLookup(io.gravitee.rest.api.idp.api.identity.IdentityLookup) SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) User(io.gravitee.rest.api.idp.api.identity.User)

Example 2 with IdentityLookup

use of io.gravitee.rest.api.idp.api.identity.IdentityLookup in project gravitee-management-rest-api by gravitee-io.

the class CompositeIdentityManager method lookup.

@Override
public Optional<User> lookup(final String reference) {
    LOGGER.debug("Looking for a user: reference[{}]", reference);
    try {
        IdentityReference identityReference = referenceSerializer.deserialize(reference);
        LOGGER.debug("Lookup identity information from reference: source[{}] id[{}]", identityReference.getSource(), identityReference.getReference());
        for (final IdentityLookup identityLookup : identityLookups) {
            if (identityLookup.canHandle(identityReference)) {
                final User user = identityLookup.retrieve(identityReference);
                if (user != null) {
                    return of(user);
                }
            }
        }
    } catch (final Exception ex) {
        LOGGER.error("Unable to extract IDP: token[" + reference + "]", ex);
    }
    return empty();
}
Also used : IdentityLookup(io.gravitee.rest.api.idp.api.identity.IdentityLookup) SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) User(io.gravitee.rest.api.idp.api.identity.User) IdentityReference(io.gravitee.rest.api.idp.api.identity.IdentityReference)

Example 3 with IdentityLookup

use of io.gravitee.rest.api.idp.api.identity.IdentityLookup in project gravitee-management-rest-api by gravitee-io.

the class IdentityProviderManagerImpl method loadIdentityProvider.

@Override
public AuthenticationProvider loadIdentityProvider(String identityProvider, Map<String, Object> properties) {
    // By loading an identity provider we are mounting both authentication provider and identity lookup
    AuthenticationProvider authenticationProvider = authenticationProvider(identityProvider, properties);
    IdentityLookup identityLookup = identityLookup(identityProvider, properties);
    compositeIdentityManager.addIdentityLookup(identityLookup);
    return authenticationProvider;
}
Also used : IdentityLookup(io.gravitee.rest.api.idp.api.identity.IdentityLookup) AuthenticationProvider(io.gravitee.rest.api.idp.api.authentication.AuthenticationProvider)

Aggregations

IdentityLookup (io.gravitee.rest.api.idp.api.identity.IdentityLookup)3 SearchableUser (io.gravitee.rest.api.idp.api.identity.SearchableUser)2 User (io.gravitee.rest.api.idp.api.identity.User)2 AuthenticationProvider (io.gravitee.rest.api.idp.api.authentication.AuthenticationProvider)1 IdentityReference (io.gravitee.rest.api.idp.api.identity.IdentityReference)1