Project

General

Profile

« Previous | Next » 

Revision 9164

use singleton for getting JWT token - refactor in d1_portal project

View differences:

src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java
47 47
import org.dataone.mimemultipart.MultipartRequest;
48 48
import org.dataone.mimemultipart.MultipartRequestResolver;
49 49
import org.dataone.portal.PortalCertificateManager;
50
import org.dataone.portal.TokenGenerator;
50 51
import org.dataone.service.exceptions.BaseException;
51 52
import org.dataone.service.exceptions.InvalidRequest;
52 53
import org.dataone.service.exceptions.ServiceFailure;
......
150 151
            session = CertificateManager.getInstance().getSession(request);
151 152
            
152 153
            // #2
154
            // check for token
153 155
            if (session == null) {
156
            	String token = request.getHeader("x-dataone-auth-token");
157
            	if (token != null) {
158
            		session = TokenGenerator.getInstance().getSession(token);
159
            	}
160
            }
161
            
162
            // #3
163
            if (session == null) {
154 164
	        	// check for session-based certificate from the portal
155 165
            	try {
156 166
		        	String configurationFileName = servletContext.getInitParameter("oa4mp:client.config.file");
......
174 184
            	}
175 185
            }
176 186
            
177
            // #3
187
            // #4
178 188
            // last resort, check for Metacat sessionid
179 189
            if (session == null) {
180 190
	            SessionData sessionData = RequestUtil.getSessionData(request);
src/edu/ucsb/nceas/metacat/restservice/v1/MNResourceHandler.java
478 478
				logMetacat.warn(e.getMessage(), e);
479 479
			}
480 480
			String token = null;
481
			token = TokenGenerator.getJWT(userId, fullName);
481
			token = TokenGenerator.getInstance().getJWT(userId, fullName);
482 482
			
483 483
			response.setStatus(200);
484 484
			response.setContentType("text/plain");
src/edu/ucsb/nceas/metacat/restservice/v2/MNResourceHandler.java
776 776
			}
777 777
			
778 778
			String token = null;
779
			token = TokenGenerator.getJWT(userId, fullName);
779
			token = TokenGenerator.getInstance().getJWT(userId, fullName);
780 780
			
781 781
			response.setStatus(200);
782 782
			response.setContentType("text/plain");

Also available in: Unified diff