简体   繁体   中英

how to prevent calling the Rest WebService from Postman?

i have a webservice that i call it from java Code like the following

            URL url = new URL("http://10.10.14.35:7004/rest/resources2/aa/api2/v_12/mywebserv
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/json");



            OutputStream os = conn.getOutputStream();
            os.write(JsonObject.getBytes());
            os.flush();

i want to secure it in a way if its called anywhere outside this java class (from postman for example ), it must not allow that

Are you sure about you really need it?

Main idea of web services is to be client side agnostic

What you are thinking about - will be not a service, but just trivial client-server application.

How about standard way of security/authentication over HTTP, using SSL / 2-way SSL etc...

Google about it if you'd like...

PS: - you also can build your own hashing/encryption code on client to makecsome hash value - pass it in custom header - and only server can dectyrpt, recognize and validate it

but... it is almost what Digest authentication is about, and still it will be not a web service anymore...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM