Nginx with Java library

Jennie Jia Jennie.Jia at amdocs.com
Thu May 23 21:29:32 UTC 2019


I am following the example posted by https://github.com/nginx-clojure/nginx-clojure/blob/master/example-projects/c-module-integration-example/src/java/example/MyHandler.java. 

Here is my code to do the logic, but I checking the java library provided by this nginx-clojure https://github.com/nginx-clojure/nginx-clojure/tree/master/src/java/nginx/clojure/java.  I can not figure out how to get  "cookie" header value from the http request ( it use NginxJavaRequest.java here.  Any help are appreciated.!

Here is my nginx.conf

location /java {
          content_handler_type  java;
          content_handler_name  example.MyHandler;
}


Here is my  java code

package example;

import static nginx.clojure.MiniConstants.*;
import static nginx.clojure.NginxClojureRT.*;

import java.io.IOException;
import java.util.Map;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;

import nginx.clojure.MiniConstants;
import nginx.clojure.java.NginxJavaRequest;
import nginx.clojure.java.NginxJavaRingHandler;

public class MyHandler implements NginxJavaRingHandler {

	public MyHandler() {
	}

	public Object[] invoke(Map<String, Object> request) throws IOException {
		
		
		NginxJavaRequest req = ((NginxJavaRequest)request);
		
		// TODO  Need Figure out how to get Cookie from the request
		String encryptedCookie = req.getVariable("cookie");   // not sure if it is correct
		
		if (encryptedCookie == null) 
			return new Object[] { 
			NGX_HTTP_UNAUTHORIZED, //http status 401
		
		};
						
		String decryptedCookie = "";
		    try {
		    	decryptedCookie = CipherUtil.decryptPKC(encryptedCookie);
		    } catch (Exception e) {
		     
		    }
		
		return  new Object[] { 
			NGX_HTTP_OK, //http status 200
		
		};
	}

}


-----Original Message-----
From: nginx <nginx-bounces at nginx.org> On Behalf Of Patrick
Sent: Wednesday, May 22, 2019 8:35 PM
To: nginx at nginx.org
Subject: Re: Nginx with Java library

On 2019-05-22 14:02, Jennie Jia wrote:
> The java library is ONAP Portal/SDK

If you can find the cookie decryption library, then you can call it from clojure -- though spinning up a clojure/java runtime to get access to a cookie seems to be expensive unless you're already writing clojure code.


Patrick
_______________________________________________
nginx mailing list
nginx at nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
This email and the information contained herein is proprietary and confidential and subject to the Amdocs Email Terms of Service, which you may review at https://www.amdocs.com/about/email-terms-of-service <https://www.amdocs.com/about/email-terms-of-service>



More information about the nginx mailing list