SEBSERV-90 implementation and fixes
This commit is contained in:
parent
a15b643d3c
commit
526b97d47b
5 changed files with 33 additions and 17 deletions
|
@ -106,6 +106,7 @@ public class LmsSetupForm implements TemplateComposer {
|
|||
final BooleanSupplier isNew = () -> entityKey == null;
|
||||
final BooleanSupplier isNotNew = () -> !isNew.getAsBoolean();
|
||||
final BooleanSupplier isSEBAdmin = () -> user.hasRole(UserRole.SEB_SERVER_ADMIN);
|
||||
final BooleanSupplier isEdit = () -> !readonly;
|
||||
|
||||
// get data or create new. handle error if happen
|
||||
final LmsSetup lmsSetup = isNew.getAsBoolean()
|
||||
|
@ -187,10 +188,12 @@ public class LmsSetupForm implements TemplateComposer {
|
|||
Domain.LMS_SETUP.ATTR_LMS_CLIENTNAME,
|
||||
FORM_CLIENTNAME_LMS_TEXT_KEY,
|
||||
(lmsSetup.getLmsAuthName() != null) ? lmsSetup.getLmsAuthName() : null))
|
||||
.addField(FormBuilder.text(
|
||||
Domain.LMS_SETUP.ATTR_LMS_CLIENTSECRET,
|
||||
FORM_SECRET_LMS_TEXT_KEY)
|
||||
.asPasswordField())
|
||||
.addFieldIf(
|
||||
isEdit,
|
||||
() -> FormBuilder.text(
|
||||
Domain.LMS_SETUP.ATTR_LMS_CLIENTSECRET,
|
||||
FORM_SECRET_LMS_TEXT_KEY)
|
||||
.asPasswordField())
|
||||
|
||||
.addField(FormBuilder.singleSelection(
|
||||
Domain.LMS_SETUP.ATTR_LMS_PROXY_AUTH_TYPE,
|
||||
|
@ -201,10 +204,12 @@ public class LmsSetupForm implements TemplateComposer {
|
|||
Domain.LMS_SETUP.ATTR_LMS_PROXY_AUTH_USERNAME,
|
||||
FORM_PROXY_AUTH_NAME_KEY,
|
||||
(lmsSetup.getProxyAuthUsername() != null) ? lmsSetup.getProxyAuthUsername() : null))
|
||||
.addField(FormBuilder.text(
|
||||
Domain.LMS_SETUP.ATTR_LMS_PROXY_AUTH_SECRET,
|
||||
FORM_PROXY_AUTH_PASS_KEY)
|
||||
.asPasswordField())
|
||||
.addFieldIf(
|
||||
isEdit,
|
||||
() -> FormBuilder.text(
|
||||
Domain.LMS_SETUP.ATTR_LMS_PROXY_AUTH_SECRET,
|
||||
FORM_PROXY_AUTH_PASS_KEY)
|
||||
.asPasswordField())
|
||||
|
||||
.buildFor((entityKey == null)
|
||||
? restService.getRestCall(NewLmsSetup.class)
|
||||
|
|
|
@ -308,6 +308,10 @@ public class SebExamConfigPropForm implements TemplateComposer {
|
|||
.withBody(inputStream)
|
||||
.call()
|
||||
.getOrThrow();
|
||||
} else {
|
||||
formHandle.getContext().publishPageMessage(
|
||||
new LocTextKey("sebserver.error.unexpected"),
|
||||
new LocTextKey("Please selecte a valid SEB Exam Configuration File"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,10 +45,6 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
|
|||
|
||||
@Override
|
||||
void build(final FormBuilder builder) {
|
||||
if (this.isPassword && builder.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean readonly = builder.readonly || this.readonly;
|
||||
final Label lab = builder.labelLocalized(
|
||||
builder.formParent,
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -217,7 +219,7 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate {
|
|||
private OAuth2RestTemplate createRestTemplate(
|
||||
final LmsSetup lmsSetup,
|
||||
final ClientCredentials credentials,
|
||||
final String accessTokenRequestPath) {
|
||||
final String accessTokenRequestPath) throws URISyntaxException {
|
||||
|
||||
final CharSequence plainClientId = credentials.clientId;
|
||||
final CharSequence plainClientSecret = this.clientCredentialService.getPlainClientSecret(credentials);
|
||||
|
@ -227,18 +229,25 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate {
|
|||
details.setClientId(plainClientId.toString());
|
||||
details.setClientSecret(plainClientSecret.toString());
|
||||
|
||||
// TODO get with proxy configuration if applied in LMSSetup
|
||||
ClientHttpRequestFactory clientHttpRequestFactory = null;
|
||||
if (lmsSetup.proxyAuthType != ProxyAuthType.NONE) {
|
||||
final ClientCredentials proxyCredentials = new ClientCredentials(
|
||||
lmsSetup.proxyAuthUsername,
|
||||
lmsSetup.proxyAuthSecret);
|
||||
|
||||
final CharSequence proxySecretPlain = this.clientCredentialService.getPlainClientSecret(proxyCredentials);
|
||||
// TODO check where we have to encrypt/decrypt the secret internally
|
||||
CharSequence proxySecretPlain;
|
||||
try {
|
||||
proxySecretPlain = this.clientCredentialService.getPlainClientSecret(proxyCredentials);
|
||||
} catch (final Exception e) {
|
||||
proxySecretPlain = lmsSetup.proxyAuthSecret;
|
||||
}
|
||||
|
||||
final URI uri = new URI(lmsSetup.lmsApiUrl);
|
||||
final ProxyData proxyData = new ProxyData(
|
||||
lmsSetup.proxyAuthType,
|
||||
null,
|
||||
-1,
|
||||
uri.getHost(),
|
||||
uri.getPort(),
|
||||
proxyCredentials.clientId,
|
||||
proxySecretPlain);
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
<Logger name="org.springframework.boot" level="INFO" additivity="true" />
|
||||
<Logger name="org.springframework.security" level="INFO" additivity="true" />
|
||||
|
||||
<Logger name="org.springframework.security.oauth2.client.OAuth2RestTemplate" level="DEBUG" additivity="true" />
|
||||
|
||||
<Logger name="org.springframework.context.support.ResourceBundleMessageSource" level="DEBUG" additivity="true" />
|
||||
|
||||
<Logger name="org.springframework.web" level="INFO" additivity="true" />
|
||||
|
|
Loading…
Reference in a new issue