SEBSERV-304
This commit is contained in:
parent
2b1a503ef5
commit
63957d9156
4 changed files with 14 additions and 29 deletions
|
@ -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 {
|
||||
|
|
|
@ -132,4 +132,9 @@ public class CertificateAsymetricKeyCryptor extends AbstractCertificateCryptor i
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Strategy getStrategy() {
|
||||
return Strategy.PUBLIC_KEY_HASH;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -194,4 +194,9 @@ public class CertificateSymetricKeyCryptor extends AbstractCertificateCryptor im
|
|||
return byteArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Strategy getStrategy() {
|
||||
return Strategy.PUBLIC_KEY_HASH_SYMMETRIC_KEY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue