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

com.sap.cloud.security.ams.api.AttributesProcessor Maven / Gradle / Ivy

Go to download

Client Library for integrating Jakarta EE applications with SAP Authorization Management Service (AMS)

The newest version!
/************************************************************************
 * © 2019-2023 SAP SE or an SAP affiliate company. All rights reserved. *
 ************************************************************************/
package com.sap.cloud.security.ams.api;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

/**
 * Enhances the predefined
 * {@link com.sap.cloud.security.ams.dcl.client.pdp.Attributes} instance.
 */
public interface AttributesProcessor extends Comparable {
	Logger LOGGER = LoggerFactory.getLogger(AttributesProcessor.class);
	/**
	 * Instance is called first with lowest priority. 
* In case of multiple {@link AttributesProcessor} implementations, the * {@link com.sap.cloud.security.ams.dcl.client.pdp.Attributes} might be * overwritten by a {@link AttributesProcessor} that has specified a higher * priority with {@link #getPriority()}. */ int LOWEST_PRECEDENCE = 0; /** * Is called last, can be used to override the * {@link com.sap.cloud.security.ams.dcl.client.pdp.Attributes} from other * {@link AttributesProcessor} previously called. */ int HIGHEST_PRECEDENCE = 100; /** * Allows ordering between multiple {@link AttributesProcessor}. * * @return by default {@link #LOWEST_PRECEDENCE} */ default int getPriority() { return LOWEST_PRECEDENCE; } /** * Returns all services that implements {@code AttributesProcessor} interface. * * @return attribute processors */ static List getAll() { List services = new ArrayList<>(); ServiceLoader loader = ServiceLoader.load(AttributesProcessor.class); loader.forEach(services::add); services.sort(Comparator.comparing(AttributesProcessor::getPriority)); LOGGER.debug("found the following attribute processors: {}", services); return services; } /** * Callback to enhance or modify the predefined attributes. You can get the * actual {@link com.sap.cloud.security.ams.dcl.client.pdp.Attributes} with * {@link Principal#getAttributes()}. * * @param principal * provides all principal information including the predefined * attributes. * */ void processAttributes(Principal principal); @Override default int compareTo(AttributesProcessor other) { return Integer.compare(this.getPriority(), other.getPriority()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy