Когда я запускаю исходный код сервера CAS, я получаю такую ошибку.
Код: Выделить всё
ERROR o.a.c.u.s.AbstractJacksonBackedStringSerializer - Cannot read/parse [[{"acceptableUsagePolicy":{"enabled":true},"accessStrategy":{"caseInsensitive":false,"delegatedAuthenticationPolicy":{"exc...] to deserialize into List of type [interface org.apereo.cas.services.RegisteredService].Internal parsing error is [Unexpected token (START_OBJECT), expected VALUE_STRING: need String, Number of Boolean value that contains type id (for subtype of java.util.List)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]]
ERROR o.a.c.s.RestfulServiceRegistry - Cannot invoke "java.util.List.stream()" because "services" is null
RestfulServiceRegistry.java:load:144
ReferencePipeline.java:accept:197
ArrayList.java:forEachRemaining:1708
Просмотр документа (https://apereo.github.io/cas/7.0.x/services /REST-Service-Management.html).
Я обнаружил, что restfulApi возвращает потребность в коллекции объектов RegisteredService.
Итак, я определил контроллер загрузки Spring, как показано ниже.
Код: Выделить всё
@Controller
public class RegistrationServiceController {
@GetMapping ("/gtapi/getCustomServices")
public void getCustomServices(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json;charset=UTF-8");
response.setStatus(HttpServletResponse.SC_OK);
response.setCharacterEncoding("UTF-8");
Collection list2 = new ArrayList();
//List list = new ArrayList();
CasRegisteredService item1 = new CasRegisteredService();
item1.setServiceId("^(https|http|imaps)://.*");
item1.setId(10000005);
item1.setDescription("这是一个测试授权的地址配置");
item1.setName("Test");
list2.add(item1);
CasRegisteredService item2 = new CasRegisteredService();
item2.setServiceId("^https://www.weibo.com.*");
item2.setId(10000006);
item2.setDescription("这是一个测试授权的地址配置");
item2.setName("Test");
list2.add(item2);
String str = JSON.toJSONString(list2);
response.getWriter().write(str);
}
}
Затем я настраиваю ее в application.properties, как показано ниже.
Код: Выделить всё
cas.service-registry.rest.url=http://localhost:8443/cas/gtapi/getCustomServices
Могу ли я спросить, как скомпилировать этот контроллер? Какой тип должен возвращать этот контроллер?
Я хочу скомпилировать restfulApi в CAS или других проектах Spring. И CAS может использовать реестр служб RESTful
Подробнее здесь: https://stackoverflow.com/questions/791 ... reo-cas7-0