java restlet 서버를 다루는 내 탐구가 계속됩니다.Restlet - 새로운 사용자가 생성 된 후 Authenticator Verifier 맵을 업데이트하는 방법?
원하는대로 내 라우팅을 설정할 수있었습니다. 특히 URL에서 POST 호출로 생성 할 수있는 사용자 리소스가 있습니다. 이 경우 데이터베이스에 새 사용자가 생성됩니다.
이 시점부터 새로운 사용자가 인증을 받기를 바랍니다. 문제는 인바운드 루트의 인증 프로그램이 처음에 사용자 이름과 암호를 한 번로드한다는 것입니다. 따라서 새 사용자가 생성되면 서버를 다시 시작하지 않으면 인증 할 수 없습니다.
이 문제를 쉽게 해결할 수있는 방법이 있어야합니다.
public class UserResource extends ServerResource{
@Post
public Representation acceptItem(Representation entity) {
//get the data from the form
//insert the new user in the db
/* TODO: I think i should add something here
to refresh the verifier map!
*/
}
}
은 어떻게 검증 맵을 새로 고칠 수 있습니다 :
public class APIServerApplication extends Application {
@Override
public Restlet createInboundRoot(){
//some routers and filter..
//here the verifier is initialized with the current users and passwords:
MapVerifier verifier = new MapVerifier();
//get users and pwd from DB
HashMap<String,String> usrPwdMap = SomeDBClass.getVerifierMap();
for(String uname : usrPwdMap.keySet()){
verifier.getLocalSecrets().put(uname, (usrPwdMap.get(uname)).toCharArray());
}
//..verifier is used to build the authenticator... etc
}
사용자 자원과 같은 :
이
는 응용 프로그램입니까?
생산 목적으로 결과를 찾는 사용자 정의 Restlet Verifier (하위 클래스 참조)를 구축해야한다는 데 동의합니다. 사용자 디렉토리 (데이터베이스 또는 다른 것)의 각 호출마다. –
감사합니다! 나는 이것을 조사하고있다. –