html 또는 json 응답 (웹 또는 Android 클라이언트)을 반환하는 App Engine Restlet Project (v 2.2.2)와 다른 사용자의 db와 다른 데이터를 설정했습니다. HTTP 기본 인증을 구현했습니다. 그것은 모두 잘 작동합니다.Restlet 새 구성 요소의 web.xml 구성
내 기본 설정 기압 (I은 OFC를 단순화) :
MyApplication.java
public class MyApplication extends Application {
private ChallengeAuthenticator authenticatior;
private ChallengeAuthenticator createAuthenticator() {...}
public boolean authenticate(Request request, Response response) {...}
@Override
public Restlet createInboundRoot() {
this.authenticatior = createAuthenticator();
Router router = new Router(getContext());
router.attachDefault(MyRestlet.class);
authenticatior.setNext(router);
return authenticatior;
}
MyRestlet.java
public class MyRestlet extends ServerResource {
@Get("json")
public Representation getJSON() {
MyApplication app = (MyApplication) getApplication();
if (!app.authenticate(getRequest(), getResponse())) {
// Not authenticated
return null;
}
else {
return data;
}
@Get("html")
public String getHTML() {...}
}
web.xml을
<?xml ...>
<display-name>MyName</display-name>
<context-param>
<param-name>org.restlet.application</param-name>
<param-value>x.MyApplication</param-value>
</context-param>
<servlet>
<servlet-name>MyRestlet</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyRestlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
이제 암호화를 추가하고 키/인증서를 만들려고합니다. 내 가이드는 tutorial입니다. 간단한 구성 요소를 먼저 추가하고 HTTP를 유지하고 포트를 8183으로 변경하려고했습니다.이 경우는 tutorial입니다. 나는 이제 꽤 놀았으며 내 구성 요소가 작동하지 않는 것처럼 보입니다. 그래서 제 질문은 :이 메인 메서드를 어디에 두겠습니까 (다음 코드는 튜토리얼에서 가져온 것입니까?). 어느 클래스에 삽입해야합니까? 아니면 별도의 서버 클래스를 만들어야합니까? 그리고 web.xml보기에 필요한 변경 사항이 정확히 무엇인지 (이 점에 관해서는 많이 알지 못했습니다. 이것이 중요한 문제라고 생각합니다)? 어떤 도움을 주셔서 감사합니다!
public static void main(String[] args) throws Exception {
// Create a new Restlet component and add a HTTP server connector to it
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
// Then attach it to the local host
component.getDefaultHost().attach("/trace", Part05.class);
// Now, let's start the component!
// Note that the HTTP server connector is also automatically started.
component.start();
}