|
| 1 | +package Arguments; |
| 2 | + |
| 3 | +import Arguments.ObjectBuilderRSA.*; |
| 4 | +import Encryption.AsyncEncryption; |
| 5 | +import Encryption.Encryption; |
| 6 | +import Exceptions.AESSpecifyPassword; |
| 7 | +import Exceptions.ArgumentsNotValidException; |
| 8 | +import Exceptions.Base64NotValid; |
| 9 | +import Loggers.Logger; |
| 10 | +import Utilites.FactoryClassUtility; |
| 11 | + |
| 12 | +import javax.crypto.BadPaddingException; |
| 13 | +import javax.crypto.IllegalBlockSizeException; |
| 14 | +import javax.crypto.NoSuchPaddingException; |
| 15 | +import java.io.IOException; |
| 16 | +import java.security.InvalidAlgorithmParameterException; |
| 17 | +import java.security.InvalidKeyException; |
| 18 | +import java.security.NoSuchAlgorithmException; |
| 19 | +import java.security.spec.InvalidKeySpecException; |
| 20 | +import java.util.List; |
| 21 | + |
| 22 | +public class DetectRSAEncryption extends DetectArguments { |
| 23 | + public DetectRSAEncryption(Arguments obj) { |
| 24 | + super(obj); |
| 25 | + } |
| 26 | + |
| 27 | + @Override |
| 28 | + public Encryption matches(List<String> args, List<Logger> loggers) throws InterruptedException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, AESSpecifyPassword, ArgumentsNotValidException, IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException, InvalidAlgorithmParameterException, InvalidKeyException, Base64NotValid { |
| 29 | + if (args.contains("-bRSA")) { |
| 30 | + // initialize constructors with factory class utility |
| 31 | + ObjectBuilderRSA builderRSA = |
| 32 | + new SizeKeyRSAMatching( |
| 33 | + new VerbosityMatchingRSA( |
| 34 | + new InputPublicKeyRSAMatching( |
| 35 | + new InputPrivateKeyRSAMatching( |
| 36 | + new InputFileRSAMatching( |
| 37 | + new OutputFileRSAMatching( |
| 38 | + new WritePrivateKeyRSAMatching( |
| 39 | + new WritePublicKeyRSAMatching( |
| 40 | + new FinalEncryptionFromTerminal( |
| 41 | + new FinalDecryptionFromTerminal( |
| 42 | + new FinalEncryptionFile( |
| 43 | + new FinalDecryptionFile( |
| 44 | + null |
| 45 | + ) |
| 46 | + ) |
| 47 | + ) |
| 48 | + ) |
| 49 | + ) |
| 50 | + ) |
| 51 | + ) |
| 52 | + ) |
| 53 | + ) |
| 54 | + ) |
| 55 | + ) |
| 56 | + ); |
| 57 | + AsyncEncryption instance = FactoryClassUtility.RSAInstance(loggers); |
| 58 | + ObjectBuilderRSA t = builderRSA.matchBuilder(instance, args, loggers); |
| 59 | + return instance; |
| 60 | + } |
| 61 | + return super.matches(args, loggers); |
| 62 | + } |
| 63 | +} |
0 commit comments