41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
package ru.oa2.lti.infrastructure;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.client.RestClient;
|
|
import ru.oa2.lti.config.AppProperties;
|
|
|
|
@Slf4j
|
|
@Component
|
|
public class LMSServiceImpl implements LMSService {
|
|
|
|
private final RestClient restClient;
|
|
private final AppProperties appProperties;
|
|
|
|
public LMSServiceImpl(RestClient restClient, AppProperties appProperties) {
|
|
this.restClient = restClient;
|
|
this.appProperties = appProperties;
|
|
}
|
|
|
|
@Override
|
|
public String ltiAuth(String ltiLoginHint, String iss, String loginHint) {
|
|
var result = restClient
|
|
.get()
|
|
.uri("/lti/auth?" +
|
|
"state=start" +
|
|
"&code=code1" +
|
|
"&iss=" + iss +
|
|
"&login_hint=" + loginHint +
|
|
"&redirect_uri=" + appProperties.lmsUrl() + "/tool/lti/redirect" +
|
|
"<i_message_hint=" + ltiLoginHint)
|
|
.retrieve();
|
|
|
|
ResponseEntity<String> body = result.toEntity(String.class);
|
|
if (log.isDebugEnabled()) {
|
|
log.debug("lti/auth RESPONSE: {}", body);
|
|
}
|
|
return body.getBody();
|
|
}
|
|
}
|