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

org.apache.wss4j.common.crypto.AlgorithmSuite Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you 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.apache.wss4j.common.crypto;

import java.util.HashSet;
import java.util.Collections;
import java.util.Set;

/**
 * This class holds the permitted values for encryption/signature/etc. algorithms on the
 * inbound side. If the corresponding value is not null then the received algorithm must
 * match the appropriate algorithm stored in this class.
 */
public class AlgorithmSuite {

    private Set signatureMethods = Collections.emptySet();
    private Set c14nAlgorithms = Collections.emptySet();
    private Set digestAlgorithms = Collections.emptySet();
    private Set transformAlgorithms = Collections.emptySet();

    private Set encryptionMethods = Collections.emptySet();
    private Set keyWrapAlgorithms = Collections.emptySet();

    private Set derivedKeyAlgorithms = Collections.emptySet();

    private int maximumSymmetricKeyLength = 256;
    private int minimumSymmetricKeyLength = 128;
    private int maximumAsymmetricKeyLength = 4096;
    private int minimumAsymmetricKeyLength = 1024;

    private int signatureDerivedKeyLength;
    private int encryptionDerivedKeyLength;

    public void addSignatureMethod(String signatureMethod) {
        if (signatureMethods.isEmpty()) {
            signatureMethods = new HashSet<>();
        }
        signatureMethods.add(signatureMethod);
    }

    public Set getSignatureMethods() {
        return signatureMethods;
    }

    public void addC14nAlgorithm(String c14nAlgorithm) {
        if (c14nAlgorithms.isEmpty()) {
            c14nAlgorithms = new HashSet<>();
        }
        c14nAlgorithms.add(c14nAlgorithm);
    }

    public Set getC14nAlgorithms() {
        return c14nAlgorithms;
    }

    public void addDigestAlgorithm(String digestAlgorithm) {
        if (digestAlgorithms.isEmpty()) {
            digestAlgorithms = new HashSet<>();
        }
        digestAlgorithms.add(digestAlgorithm);
    }

    public Set getDigestAlgorithms() {
        return digestAlgorithms;
    }

    public void addTransformAlgorithm(String transformAlgorithm) {
        if (transformAlgorithms.isEmpty()) {
            transformAlgorithms = new HashSet<>();
        }
        transformAlgorithms.add(transformAlgorithm);
    }

    public Set getTransformAlgorithms() {
        return transformAlgorithms;
    }

    public void addEncryptionMethod(String encryptionMethod) {
        if (encryptionMethods.isEmpty()) {
            encryptionMethods = new HashSet<>();
        }
        encryptionMethods.add(encryptionMethod);
    }

    public Set getEncryptionMethods() {
        return encryptionMethods;
    }

    public void addKeyWrapAlgorithm(String keyWrapAlgorithm) {
        if (keyWrapAlgorithms.isEmpty()) {
            keyWrapAlgorithms = new HashSet<>();
        }
        keyWrapAlgorithms.add(keyWrapAlgorithm);
    }

    public Set getKeyWrapAlgorithms() {
        return keyWrapAlgorithms;
    }

    public void addDerivedKeyAlgorithm(String derivedKeyAlgorithm) {
        if (derivedKeyAlgorithms.isEmpty()) {
            derivedKeyAlgorithms = new HashSet<>();
        }
        derivedKeyAlgorithms.add(derivedKeyAlgorithm);
    }

    public Set getDerivedKeyAlgorithms() {
        return derivedKeyAlgorithms;
    }

    public int getMaximumSymmetricKeyLength() {
        return maximumSymmetricKeyLength;
    }

    public void setMaximumSymmetricKeyLength(int maximumSymmetricKeyLength) {
        this.maximumSymmetricKeyLength = maximumSymmetricKeyLength;
    }

    public int getMinimumAsymmetricKeyLength() {
        return minimumAsymmetricKeyLength;
    }

    public void setMinimumAsymmetricKeyLength(int minimumAsymmetricKeyLength) {
        this.minimumAsymmetricKeyLength = minimumAsymmetricKeyLength;
    }

    public int getMaximumAsymmetricKeyLength() {
        return maximumAsymmetricKeyLength;
    }

    public void setMaximumAsymmetricKeyLength(int maximumAsymmetricKeyLength) {
        this.maximumAsymmetricKeyLength = maximumAsymmetricKeyLength;
    }

    public int getEncryptionDerivedKeyLength() {
        return encryptionDerivedKeyLength;
    }

    public void setEncryptionDerivedKeyLength(int encryptionDerivedKeyLength) {
        this.encryptionDerivedKeyLength = encryptionDerivedKeyLength;
    }

    public int getSignatureDerivedKeyLength() {
        return signatureDerivedKeyLength;
    }

    public void setSignatureDerivedKeyLength(int signatureDerivedKeyLength) {
        this.signatureDerivedKeyLength = signatureDerivedKeyLength;
    }

    public int getMinimumSymmetricKeyLength() {
        return minimumSymmetricKeyLength;
    }

    public void setMinimumSymmetricKeyLength(int minimumSymmetricKeyLength) {
        this.minimumSymmetricKeyLength = minimumSymmetricKeyLength;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy