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

se.swedenconnect.security.algorithms.AlgorithmRegistry Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2022-2024 Sweden Connect
 *
 * Licensed 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.
 */
package se.swedenconnect.security.algorithms;

import java.util.List;
import java.util.function.Predicate;

/**
 * Interface representing an algorithm registry.
 * 

* The interface offers a direct possibility to search for an algorithm based on its URI. To search based on other * algorithm properties, use {@link #getAlgorithm(Predicate)} or {@link #getAlgorithms(Predicate)}. *

* * @author Martin Lindström ([email protected]) * @author Stefan Santesson ([email protected]) */ public interface AlgorithmRegistry { /** * Gets the algorithm based on its URI. * * @param algorithmUri the algorithm URI * @return the algorithm, or null if none is found */ Algorithm getAlgorithm(final String algorithmUri); /** * Gets an algorithm based on its URI and type. * * @param the algorithm type * @param algorithmUri the algorithm URI * @param clazz the type representing the algorithm * @return the algorithm, or null if none is found */ T getAlgorithm(final String algorithmUri, final Class clazz); /** * Gets the first algorithm that matches the supplied predicate. *

* If more than one algorithm matches the supplied predicate, the one with the lowest order is returned. *

* * @param predicate the predicate to apply * @return an Algorithm or null if no algorithms in the registry matches * @see AlgorithmPredicates */ Algorithm getAlgorithm(final Predicate predicate); /** * Gets the first algorithm that matches the given type and supplied predicate. *

* If more than one algorithm matches the supplied predicate, the one with the lowest order is returned. *

* * @param predicate the predicate to apply * @param clazz the type representing the algorithm * @return an Algorithm or null if no algorithms in the registry matches * @see AlgorithmPredicates */ T getAlgorithm(final Predicate predicate, final Class clazz); /** * Gets all algorithms that matches the supplied predicate. *

* The list is sorted with the lowest algorithms with the lowest order index first. *

* * @param predicate the predicate to apply * @return a (possibly empty) list of Algorithm objects */ List getAlgorithms(final Predicate predicate); /** * Gets all algorithms that matches the given type and the supplied predicate. *

* The list is sorted with the lowest algorithms with the lowest order index first. *

* * @param predicate the predicate to apply * @param clazz the type representing the algorithm * @return a (possibly empty) list of Algorithm objects */ List getAlgorithms(final Predicate predicate, final Class clazz); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy