@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @POST("/@/i18n/messages/{locale}") public void setMessage(String locale, Map<String, String> entries) { if (!(messages instanceof MutableMessages)) { throw new IllegalStateException( "can't update messages: not a MutableMessages instance. Are you in PROD mode?"); } try { for (Map.Entry<String, String> entry : entries.entrySet()) { ((MutableMessages) messages).setMessageTemplate( entry.getKey(), entry.getValue(), toLocale(locale)); } } catch (IOException e) { throw new RuntimeException(e); } }
methodAnnotations.add(new ResourceMethodAnnotation("POST", elem, post.value()));
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @POST("/@/i18n/messages/{locale}") public void setMessage(String locale, Map<String, String> entries) { if (!(messages instanceof MutableMessages)) { throw new IllegalStateException( "can't update messages: not a MutableMessages instance. Are you in PROD mode?"); } try { for (Map.Entry<String, String> entry : entries.entrySet()) { ((MutableMessages) messages).setMessageTemplate( entry.getKey(), entry.getValue(), toLocale(locale)); } } catch (IOException e) { throw new RuntimeException(e); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @POST("/@/tests/requests") public TestRequest submitTestRequest(TestRequest testRequest) { return server.submitTestRequest(testRequest); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @POST("/@/tests/requests") public TestRequest submitTestRequest(TestRequest testRequest) { return server.submitTestRequest(testRequest); }
@PermitAll @POST("/sessions") public Session authenticate(Map session) { RestxSession.current().clearPrincipal(); RestxSession.current().define(String.class, Session.SESSION_DEF_KEY, null); Map<String, ?> principal = getPrincipal(session); if (principal == null) { throw new WebException(HttpStatus.UNAUTHORIZED); } String name = (String) principal.get("name"); String passwordHash = (String) principal.get("passwordHash"); Optional<? extends RestxPrincipal> principalOptional = authenticator.authenticate( name, passwordHash, ImmutableMap.copyOf(principal)); if (principalOptional.isPresent()) { String sessionKey = uuidGenerator.doGenerate(); RestxSession.current().authenticateAs(principalOptional.get()); RestxSession.current().define(String.class, Session.SESSION_DEF_KEY, sessionKey); return new Session(sessionKey, principalOptional.get()); } else { throw new WebException(HttpStatus.UNAUTHORIZED); } }
@PermitAll @POST("/sessions") public Session authenticate(Map session) { RestxSession.current().clearPrincipal(); RestxSession.current().define(String.class, Session.SESSION_DEF_KEY, null); Map<String, ?> principal = getPrincipal(session); if (principal == null) { throw new WebException(HttpStatus.UNAUTHORIZED); } String name = (String) principal.get("name"); String passwordHash = (String) principal.get("passwordHash"); Optional<? extends RestxPrincipal> principalOptional = authenticator.authenticate( name, passwordHash, ImmutableMap.copyOf(principal)); if (principalOptional.isPresent()) { String sessionKey = uuidGenerator.doGenerate(); RestxSession.current().authenticateAs(principalOptional.get()); RestxSession.current().define(String.class, Session.SESSION_DEF_KEY, sessionKey); return new Session(sessionKey, principalOptional.get()); } else { throw new WebException(HttpStatus.UNAUTHORIZED); } }