SEBSERV-304

This commit is contained in:
anhefti 2022-05-11 16:29:49 +02:00
parent 2b1a503ef5
commit 63957d9156
4 changed files with 14 additions and 29 deletions

View file

@ -25,6 +25,7 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.Certificates;
import ch.ethz.seb.sebserver.gbl.util.Cryptor;
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.CertificateService;
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext;
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService;
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext;
public abstract class AbstractCertificateCryptor {
@ -65,7 +66,7 @@ public abstract class AbstractCertificateCryptor {
if (Arrays.equals(otherPublicKeyHash, publicKeyHash)) {
return EncryptionContext.contextOf(
sebConfigEncryptionContext.institutionId(),
sebConfigEncryptionContext.getStrategy(),
getStrategy(),
certificate,
alias);
}
@ -79,6 +80,8 @@ public abstract class AbstractCertificateCryptor {
}
}
protected abstract SEBConfigEncryptionService.Strategy getStrategy();
protected byte[] generatePublicKeyHash(final Certificate cert) {
try {

View file

@ -132,4 +132,9 @@ public class CertificateAsymetricKeyCryptor extends AbstractCertificateCryptor i
}
}
@Override
protected Strategy getStrategy() {
return Strategy.PUBLIC_KEY_HASH;
}
}

View file

@ -194,4 +194,9 @@ public class CertificateSymetricKeyCryptor extends AbstractCertificateCryptor im
return byteArray;
}
@Override
protected Strategy getStrategy() {
return Strategy.PUBLIC_KEY_HASH_SYMMETRIC_KEY;
}
}

View file

@ -150,34 +150,6 @@ public final class SEBConfigEncryptionServiceImpl implements SEBConfigEncryption
.getOrThrow()
.decrypt(pout, newIn, context);
// if (strategy == Strategy.PLAIN_TEXT) {
//
// getEncryptor(strategy)
// .getOrThrow()
// .decrypt(pout, newIn, context);
//
// } else if ((strategy == Strategy.PASSWORD_PSWD || strategy == Strategy.PASSWORD_PWCC)) {
// if (StringUtils.isBlank(context.getPassword())) {
// return new AsyncResult<>(new APIMessage.APIMessageException(
// APIMessage.ErrorMessage.MISSING_PASSWORD.of("Missing Password")));
// } else {
//
// // then decrypt stream with password
// getEncryptor(strategy)
// .getOrThrow()
// .decrypt(pout, newIn, context);
// }
// } else {
//
// // then decrypt stream with certificate
// getEncryptor(strategy)
// .getOrThrow()
// .decrypt(
// pout,
// newIn,
// EncryptionContext.contextOf(context.institutionId(), strategy, null, null));
// }
IOUtils.copyLarge(pin, output);
return new AsyncResult<>(null);