All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.c4_soft.springaddons.security.oidc.starter.CompositeOAuth2AuthorizationRequestCustomizer Maven / Gradle / Ivy

The newest version!
package com.c4_soft.springaddons.security.oidc.starter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest;
import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest.Builder;

public class CompositeOAuth2AuthorizationRequestCustomizer implements Consumer {
	private final List> delegates;

	public CompositeOAuth2AuthorizationRequestCustomizer(Consumer... customizers) {
		delegates = new ArrayList<>(customizers.length + 3);
		Collections.addAll(delegates, customizers);
	}

	public CompositeOAuth2AuthorizationRequestCustomizer(
			CompositeOAuth2AuthorizationRequestCustomizer other,
			Consumer... customizers) {
		this(Stream.concat(other.delegates.stream(), Stream.of(customizers)).toArray(Consumer[]::new));
	}

	@Override
	public void accept(Builder t) {
		for (var consumer : delegates) {
			consumer.accept(t);
		}
	}

	public CompositeOAuth2AuthorizationRequestCustomizer addCustomizer(Consumer customizer) {
		this.delegates.add(customizer);
		return this;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy