SEBSERV-335 name changing and code cleanup
This commit is contained in:
parent
6198f26a6f
commit
ec6f12a703
9 changed files with 34 additions and 34 deletions
|
@ -65,8 +65,8 @@ public final class Exam implements GrantEntity {
|
||||||
|
|
||||||
/** This attribute name is used on exams to store the flag for indicating the signature key check */
|
/** This attribute name is used on exams to store the flag for indicating the signature key check */
|
||||||
public static final String ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED = "SIGNATURE_KEY_CHECK_ENABLED";
|
public static final String ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED = "SIGNATURE_KEY_CHECK_ENABLED";
|
||||||
/** This attribute name is used to store the signature check grant threshold for statistical checks */
|
/** This attribute name is used to store the signature check grant threshold for numerical trust checks */
|
||||||
public static final String ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD = "STATISTICAL_GRANT_COUNT_THRESHOLD";
|
public static final String ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD = "NUMERICAL_TRUST_THRESHOLD";
|
||||||
/** This attribute name is used to store the signature check encryption certificate is one is used */
|
/** This attribute name is used to store the signature check encryption certificate is one is used */
|
||||||
public static final String ADDITIONAL_ATTR_SIGNATURE_KEY_CERT_ALIAS = "SIGNATURE_KEY_CERT_ALIAS";
|
public static final String ADDITIONAL_ATTR_SIGNATURE_KEY_CERT_ALIAS = "SIGNATURE_KEY_CERT_ALIAS";
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,17 @@ public class SecurityCheckResult {
|
||||||
|
|
||||||
public final boolean globalGranted;
|
public final boolean globalGranted;
|
||||||
public final boolean examGranted;
|
public final boolean examGranted;
|
||||||
public final boolean statisticallyGranted;
|
public final boolean numericallyGranted;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public SecurityCheckResult(
|
public SecurityCheckResult(
|
||||||
final boolean globalGranted,
|
final boolean globalGranted,
|
||||||
final boolean examGranted,
|
final boolean examGranted,
|
||||||
final boolean statisticallyGranted) {
|
final boolean numericallyGranted) {
|
||||||
|
|
||||||
this.globalGranted = globalGranted;
|
this.globalGranted = globalGranted;
|
||||||
this.examGranted = examGranted;
|
this.examGranted = examGranted;
|
||||||
this.statisticallyGranted = statisticallyGranted;
|
this.numericallyGranted = numericallyGranted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGlobalGranted() {
|
public boolean isGlobalGranted() {
|
||||||
|
@ -39,12 +39,12 @@ public class SecurityCheckResult {
|
||||||
return this.examGranted;
|
return this.examGranted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatisticallyGranted() {
|
public boolean isNumericallyGranted() {
|
||||||
return this.statisticallyGranted;
|
return this.numericallyGranted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAnyGrant() {
|
public boolean hasAnyGrant() {
|
||||||
return this.globalGranted | this.examGranted | this.statisticallyGranted;
|
return this.globalGranted | this.examGranted | this.numericallyGranted;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class ExamSignatureKeyForm implements TemplateComposer {
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
final boolean signatureKeyCheckEnabled = BooleanUtils.toBoolean(
|
final boolean signatureKeyCheckEnabled = BooleanUtils.toBoolean(
|
||||||
exam.additionalAttributes.get(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED));
|
exam.additionalAttributes.get(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED));
|
||||||
final String ct = exam.additionalAttributes.get(Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD);
|
final String ct = exam.additionalAttributes.get(Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD);
|
||||||
|
|
||||||
final Composite content = widgetFactory
|
final Composite content = widgetFactory
|
||||||
.defaultPageLayout(pageContext.getParent(), TILE);
|
.defaultPageLayout(pageContext.getParent(), TILE);
|
||||||
|
@ -135,7 +135,7 @@ public class ExamSignatureKeyForm implements TemplateComposer {
|
||||||
.withInputSpan(1))
|
.withInputSpan(1))
|
||||||
|
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD,
|
Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD,
|
||||||
FORM_STAT_GRANT_THRESHOLD,
|
FORM_STAT_GRANT_THRESHOLD,
|
||||||
(ct != null) ? ct : "2")
|
(ct != null) ? ct : "2")
|
||||||
.asNumber(number -> {
|
.asNumber(number -> {
|
||||||
|
@ -279,7 +279,7 @@ public class ExamSignatureKeyForm implements TemplateComposer {
|
||||||
|
|
||||||
private PageAction saveSettings(final PageAction action, final Form form) {
|
private PageAction saveSettings(final PageAction action, final Form form) {
|
||||||
final String enable = form.getFieldValue(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED);
|
final String enable = form.getFieldValue(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED);
|
||||||
final String threshold = form.getFieldValue(Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD);
|
final String threshold = form.getFieldValue(Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD);
|
||||||
final EntityKey entityKey = action.getEntityKey();
|
final EntityKey entityKey = action.getEntityKey();
|
||||||
|
|
||||||
this.pageService
|
this.pageService
|
||||||
|
@ -287,7 +287,7 @@ public class ExamSignatureKeyForm implements TemplateComposer {
|
||||||
.getBuilder(SaveAppSignatureKeySettings.class)
|
.getBuilder(SaveAppSignatureKeySettings.class)
|
||||||
.withURIVariable(API.PARAM_PARENT_MODEL_ID, entityKey.modelId)
|
.withURIVariable(API.PARAM_PARENT_MODEL_ID, entityKey.modelId)
|
||||||
.withFormParam(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED, enable)
|
.withFormParam(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED, enable)
|
||||||
.withFormParam(Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD, threshold)
|
.withFormParam(Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD, threshold)
|
||||||
.call()
|
.call()
|
||||||
.onError(error -> action.pageContext().notifySaveError(EntityType.EXAM, error));
|
.onError(error -> action.pageContext().notifySaveError(EntityType.EXAM, error));
|
||||||
return action;
|
return action;
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
private final ApplicationEventPublisher applicationEventPublisher;
|
private final ApplicationEventPublisher applicationEventPublisher;
|
||||||
private final AdditionalAttributesDAO additionalAttributesDAO;
|
private final AdditionalAttributesDAO additionalAttributesDAO;
|
||||||
private final boolean appSignatureKeyEnabled;
|
private final boolean appSignatureKeyEnabled;
|
||||||
private final int appSignatureKeyThreshold;
|
private final int defaultNumericalTrustThreshold;
|
||||||
|
|
||||||
public ExamDAOImpl(
|
public ExamDAOImpl(
|
||||||
final ExamRecordMapper examRecordMapper,
|
final ExamRecordMapper examRecordMapper,
|
||||||
|
@ -76,14 +76,14 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
final ApplicationEventPublisher applicationEventPublisher,
|
final ApplicationEventPublisher applicationEventPublisher,
|
||||||
final AdditionalAttributesDAO additionalAttributesDAO,
|
final AdditionalAttributesDAO additionalAttributesDAO,
|
||||||
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.enabled:false}") boolean appSignatureKeyEnabled,
|
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.enabled:false}") boolean appSignatureKeyEnabled,
|
||||||
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.threshold:2}") int appSignatureKeyThreshold) {
|
final @Value("${sebserver.webservice.api.admin.exam.app.signature.key.numerical.threshold:2}") int defaultNumericalTrustThreshold) {
|
||||||
|
|
||||||
this.examRecordMapper = examRecordMapper;
|
this.examRecordMapper = examRecordMapper;
|
||||||
this.examRecordDAO = examRecordDAO;
|
this.examRecordDAO = examRecordDAO;
|
||||||
this.applicationEventPublisher = applicationEventPublisher;
|
this.applicationEventPublisher = applicationEventPublisher;
|
||||||
this.additionalAttributesDAO = additionalAttributesDAO;
|
this.additionalAttributesDAO = additionalAttributesDAO;
|
||||||
this.appSignatureKeyEnabled = appSignatureKeyEnabled;
|
this.appSignatureKeyEnabled = appSignatureKeyEnabled;
|
||||||
this.appSignatureKeyThreshold = appSignatureKeyThreshold;
|
this.defaultNumericalTrustThreshold = defaultNumericalTrustThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -776,8 +776,8 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
this.additionalAttributesDAO.initAdditionalAttribute(
|
this.additionalAttributesDAO.initAdditionalAttribute(
|
||||||
EntityType.EXAM,
|
EntityType.EXAM,
|
||||||
examId,
|
examId,
|
||||||
Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD,
|
Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD,
|
||||||
String.valueOf(this.appSignatureKeyThreshold));
|
String.valueOf(this.defaultNumericalTrustThreshold));
|
||||||
final CharSequence salt = KeyGenerators.string().generateKey();
|
final CharSequence salt = KeyGenerators.string().generateKey();
|
||||||
this.additionalAttributesDAO.initAdditionalAttribute(
|
this.additionalAttributesDAO.initAdditionalAttribute(
|
||||||
EntityType.EXAM,
|
EntityType.EXAM,
|
||||||
|
|
|
@ -49,13 +49,13 @@ public interface ExamAdminService {
|
||||||
* @param institutionId The institution identifier
|
* @param institutionId The institution identifier
|
||||||
* @param examId The exam identifier
|
* @param examId The exam identifier
|
||||||
* @param enabled The enabled setting that indicates if the security key check is enabled or not
|
* @param enabled The enabled setting that indicates if the security key check is enabled or not
|
||||||
* @param statThreshold the statistical SEB client connection number grant threshold
|
* @param numThreshold the numerical SEB client connection number grant threshold
|
||||||
* @return Result refer to the exam with the new settings (additional attributes) or to an error when happened */
|
* @return Result refer to the exam with the new settings (additional attributes) or to an error when happened */
|
||||||
Result<Exam> saveSecurityKeySettings(
|
Result<Exam> saveSecurityKeySettings(
|
||||||
Long institutionId,
|
Long institutionId,
|
||||||
Long examId,
|
Long examId,
|
||||||
Boolean enabled,
|
Boolean enabled,
|
||||||
Integer statThreshold);
|
Integer numThreshold);
|
||||||
|
|
||||||
/** Applies all additional SEB restriction attributes that are defined by the
|
/** Applies all additional SEB restriction attributes that are defined by the
|
||||||
* type of the LMS of a given Exam to this given Exam.
|
* type of the LMS of a given Exam to this given Exam.
|
||||||
|
|
|
@ -102,10 +102,10 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.EXAM,
|
EntityType.EXAM,
|
||||||
examId,
|
examId,
|
||||||
Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD,
|
Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD,
|
||||||
String.valueOf(statThreshold))
|
String.valueOf(statThreshold))
|
||||||
.onError(error -> log
|
.onError(error -> log
|
||||||
.error("Failed to store ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD: ", error));
|
.error("Failed to store ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD: ", error));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.examDAO.setModified(examId);
|
this.examDAO.setModified(examId);
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class SecurityKeyServiceImpl implements SecurityKeyService {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (matches == null || matches.isEmpty()) {
|
if (matches == null || matches.isEmpty()) {
|
||||||
return statisticalCheck(examId, hashedSignatureKey);
|
return numericalCheck(examId, hashedSignatureKey);
|
||||||
} else {
|
} else {
|
||||||
return new SecurityCheckResult(
|
return new SecurityCheckResult(
|
||||||
matches.stream()
|
matches.stream()
|
||||||
|
@ -283,22 +283,22 @@ public class SecurityKeyServiceImpl implements SecurityKeyService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private SecurityCheckResult statisticalCheck(
|
private SecurityCheckResult numericalCheck(
|
||||||
final Long examId,
|
final Long examId,
|
||||||
final String hashedSignature) {
|
final String hashedSignature) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Apply statistical security check update for exam {}", examId);
|
log.debug("Apply numerical security check update for exam {}", examId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is no exam known yet, no statistical check can be applied
|
// if there is no exam known yet, no numerical check can be applied
|
||||||
if (examId == null) {
|
if (examId == null) {
|
||||||
return SecurityCheckResult.NO_GRANT;
|
return SecurityCheckResult.NO_GRANT;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final int statisticalGrantThreshold = getStatisticalGrantThreshold(examId);
|
final int numericalTrustThreshold = getNumericalTrustThreshold(examId);
|
||||||
final Long matches = this.clientConnectionDAO
|
final Long matches = this.clientConnectionDAO
|
||||||
.countSignatureHashes(examId, hashedSignature)
|
.countSignatureHashes(examId, hashedSignature)
|
||||||
.getOr(0L);
|
.getOr(0L);
|
||||||
|
@ -306,27 +306,27 @@ public class SecurityKeyServiceImpl implements SecurityKeyService {
|
||||||
if (matches <= 0) {
|
if (matches <= 0) {
|
||||||
return SecurityCheckResult.NO_GRANT;
|
return SecurityCheckResult.NO_GRANT;
|
||||||
} else {
|
} else {
|
||||||
return new SecurityCheckResult(false, false, matches > statisticalGrantThreshold);
|
return new SecurityCheckResult(false, false, matches > numericalTrustThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Unexpected error while trying to apply statistical app signature key check: ", e);
|
log.error("Unexpected error while trying to apply numerical app signature key check: ", e);
|
||||||
return SecurityCheckResult.NO_GRANT;
|
return SecurityCheckResult.NO_GRANT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStatisticalGrantThreshold(final Long examId) {
|
private int getNumericalTrustThreshold(final Long examId) {
|
||||||
// try to ger from running exam.
|
// try to ger from running exam.
|
||||||
final Exam runningExam = this.examSessionCacheService.getRunningExam(examId);
|
final Exam runningExam = this.examSessionCacheService.getRunningExam(examId);
|
||||||
if (runningExam != null) {
|
if (runningExam != null) {
|
||||||
final String threshold = runningExam.getAdditionalAttribute(
|
final String threshold = runningExam.getAdditionalAttribute(
|
||||||
Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD);
|
Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(threshold)) {
|
if (StringUtils.isNotBlank(threshold)) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(threshold);
|
return Integer.parseInt(threshold);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.warn("Failed to parse STATISTICAL_GRANT_COUNT_THRESHOLD");
|
log.warn("Failed to parse numerical trust threshold");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ public class SecurityKeyServiceImpl implements SecurityKeyService {
|
||||||
.getAdditionalAttribute(
|
.getAdditionalAttribute(
|
||||||
EntityType.EXAM,
|
EntityType.EXAM,
|
||||||
examId,
|
examId,
|
||||||
Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD)
|
Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD)
|
||||||
.map(attr -> Integer.valueOf(attr.getValue()))
|
.map(attr -> Integer.valueOf(attr.getValue()))
|
||||||
.getOr(1);
|
.getOr(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
required = true,
|
required = true,
|
||||||
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
||||||
@RequestParam(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED) final Boolean enableKeyCheck,
|
@RequestParam(Exam.ADDITIONAL_ATTR_SIGNATURE_KEY_CHECK_ENABLED) final Boolean enableKeyCheck,
|
||||||
@RequestParam(Exam.ADDITIONAL_ATTR_STATISTICAL_GRANT_COUNT_THRESHOLD) final Integer threshold) {
|
@RequestParam(Exam.ADDITIONAL_ATTR_NUMERICAL_TRUST_THRESHOLD) final Integer threshold) {
|
||||||
|
|
||||||
this.examDAO.byPK(examId)
|
this.examDAO.byPK(examId)
|
||||||
.flatMap(this::checkReadAccess)
|
.flatMap(this::checkReadAccess)
|
||||||
|
|
|
@ -803,7 +803,7 @@ sebserver.exam.signaturekey.action.deleteGrant=Delete Security Grant
|
||||||
sebserver.exam.signaturekey.title=App Signature Key Overview
|
sebserver.exam.signaturekey.title=App Signature Key Overview
|
||||||
sebserver.exam.signaturekey.form.enabled=Enable App Signature Key Check
|
sebserver.exam.signaturekey.form.enabled=Enable App Signature Key Check
|
||||||
sebserver.exam.signaturekey.form.enabled.tooltip=Enable the App Signature Key Check for this exam. If disabled no check will be applied
|
sebserver.exam.signaturekey.form.enabled.tooltip=Enable the App Signature Key Check for this exam. If disabled no check will be applied
|
||||||
sebserver.exam.signaturekey.form.grant.threshold=Threshold of Statistical Check
|
sebserver.exam.signaturekey.form.grant.threshold=Numerical Trust Threshold
|
||||||
sebserver.exam.signaturekey.form.grant.threshold.tooltip=If there is no explicit grant registered for a given App Signature Key,<br/>a given key will be considered valid if more then the given number of connected SEB clients has the same key.
|
sebserver.exam.signaturekey.form.grant.threshold.tooltip=If there is no explicit grant registered for a given App Signature Key,<br/>a given key will be considered valid if more then the given number of connected SEB clients has the same key.
|
||||||
|
|
||||||
sebserver.exam.signaturekey.keylist.actions=
|
sebserver.exam.signaturekey.keylist.actions=
|
||||||
|
|
Loading…
Reference in a new issue