azından bir Restlet var olarak oluşturulur, bu sayede (2.2.3) uygulama (ı Restlet yeniyim): Bu tek başına bir java uygulaması olarak çalışırgüvenliğini Bileşenleri Restlet
component = new Component();
component.getServers().add(Protocol.HTTP, port);
Context childContext = component.getContext().createChildContext();
JaxRsApplication application = new JaxRsApplication(childContext);
application.add(this);
application.setStatusService(new ErrorStatusService());
childContext.getAttributes().put(MY_SERVER, this);
component.getDefaultHost().attach(application);
. Güvenlik eklemek istiyorum. İşte restlet authentication documentation temel kimlik doğrulama kodudur:
// Guard the restlet with BASIC authentication.
ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
// Instantiates a Verifier of identifier/secret couples based on a simple Map.
MapVerifier mapVerifier = new MapVerifier();
// Load a single static login/secret pair.
mapVerifier.getLocalSecrets().put("login", "secret".toCharArray());
guard.setVerifier(mapVerifier);
guard.setNext(restlet);
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getDefaultHost().attachDefault(guard);
benim şimdiki koduna güvenlik mekanizması olduğunu entegre edebilirsiniz nasıl? Restlet uygulamanızı bekçi için bir sonraki öğe olarak belirtmeniz gerekir.