/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2015 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * 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 org.wildfly.security.credential;

import org.wildfly.common.Assert;
import org.wildfly.security.evidence.Evidence;

/**
 * A credential is a piece of information that can be used to verify or produce evidence.
 */
public interface Credential {
    /**
     * Determine whether this credential can, generally speaking, verify the given evidence type.
     *
     * @param evidenceClass the evidence type (must not be {@code null})
     * @param algorithmName the evidence algorithm name (may be {@code null} if the type of evidence does not support
     * algorithm names)
     *
     * @return {@code true} if the evidence can be verified by this credential, {@code false} otherwise
     */
    default boolean canVerify(Class<? extends Evidence> evidenceClass, String algorithmName) {
        Assert.checkNotNullParam("evidenceClass", evidenceClass);
        return false;
    }

    /**
     * Verify the given evidence.
     *
     * @param evidence the evidence to verify (must not be {@code null})
     *
     * @return {@code true} if the evidence is verified, {@code false} otherwise
     */
    default boolean verify(Evidence evidence) {
        Assert.checkNotNullParam("evidence", evidence);
        return false;
    }
}

@@ -777,16 +777,72 @@
 Assert;%0A
+import org.wildfly.security.evidence.AlgorithmEvidence;%0A
 import o
@@ -880,16 +880,16 @@
 idence;%0A
-
 %0A/**%0A * 
@@ -1009,16 +1009,17 @@
 ntial %7B%0A
+%0A
     /**%0A
@@ -1618,16 +1618,16 @@
 Class);%0A
-
         
@@ -1647,16 +1647,540 @@
 %0A    %7D%0A%0A
+    /**%0A     * Determine whether this credential can verify the given evidence.%0A     *%0A     * @param evidence the evidence (must not be %7B@code null%7D)%0A     *%0A     * @return %7B@code true%7D if the evidence can be verified by this credential, %7B@code false%7D otherwise%0A     */%0A    default boolean canVerify(Evidence evidence) %7B%0A        Assert.checkNotNullParam(%22evidence%22, evidence);%0A        return canVerify(evidence.getClass(), evidence instanceof AlgorithmEvidence ? ((AlgorithmEvidence) evidence).getAlgorithm() : null);%0A    %7D%0A%0A
     /**%0A

Add utility to determine if an evidence object can be verified by a credential