diff --git a/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java b/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java index 89cebb25..1c7536c2 100644 --- a/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java +++ b/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java @@ -57,14 +57,12 @@ public final class RSA extends Algorithm implements KeyAgreement, Signature, Pub } public RSA(@NotNull DetectionLocation detectionLocation) { - super(NAME, PublicKeyEncryption.class, detectionLocation); - this.put(new Oid(OID, detectionLocation)); + this(PublicKeyEncryption.class, detectionLocation); } public RSA(int keyLength, @Nonnull DetectionLocation detectionLocation) { - super(NAME, PublicKeyEncryption.class, detectionLocation); + this(detectionLocation); this.put(new KeyLength(keyLength, detectionLocation)); - this.put(new Oid(OID, detectionLocation)); } public RSA( diff --git a/mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java b/mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java new file mode 100644 index 00000000..c267f259 --- /dev/null +++ b/mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java @@ -0,0 +1,39 @@ +/* + * SonarQube Cryptography Plugin + * Copyright (C) 2024 IBM + * + * 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 com.ibm.mapper.mapper.issues; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.ibm.mapper.model.INode; +import com.ibm.mapper.model.algorithms.RSA; +import com.ibm.mapper.utils.DetectionLocation; +import java.util.List; +import org.junit.Test; + +public class Issue127Test { + + @Test + public void test() { + final RSA rsa = + new RSA(2048, new DetectionLocation("test.java", 1, 1, List.of(), () -> "Test")); + final INode rsaCopy = rsa.deepCopy(); + assertThat(rsaCopy).isInstanceOf(RSA.class); + } +}