Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read-only CORS headers for UI preview #18

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

import com.sample.rm.RMToolManager;
import com.sample.rm.RMToolConstants;
import com.sample.rm.resources.Oslc_rmDomainConstants;
import com.sample.rm.resources.Oslc_rmDomainConstants;
import com.sample.rm.resources.Oslc_rmDomainConstants;
import com.sample.rm.servlet.ServiceProviderCatalogSingleton;
import com.sample.rm.resources.Requirement;
Expand All @@ -98,6 +98,12 @@ public class ServiceProviderService1
// End of user code

// Start of user code class_methods
private void addCORS(final HttpServletResponse httpServletResponse) {
httpServletResponse.addHeader("Access-Control-Allow-Origin", "*");
httpServletResponse.addHeader("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD");
httpServletResponse.addHeader("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
httpServletResponse.addHeader("Access-Control-Allow-Credentials", "true");
}
// End of user code

public ServiceProviderService1()
Expand Down Expand Up @@ -318,6 +324,7 @@ public Compact getRequirementCompact(
compact.setLargePreview(largePreview);

httpServletResponse.addHeader(RMToolConstants.HDR_OSLC_VERSION, RMToolConstants.OSLC_VERSION_V2);
addCORS(httpServletResponse);
return compact;
}
throw new WebApplicationException(Status.NOT_FOUND);
Expand All @@ -342,6 +349,7 @@ public void getRequirementAsHtmlSmallPreview(

RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/com/sample/rm/requirementsmallpreview.jsp");
httpServletResponse.addHeader(RMToolConstants.HDR_OSLC_VERSION, RMToolConstants.OSLC_VERSION_V2);
addCORS(httpServletResponse);
rd.forward(httpServletRequest, httpServletResponse);
}

Expand All @@ -367,6 +375,7 @@ public void getRequirementAsHtmlLargePreview(

RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/com/sample/rm/requirementlargepreview.jsp");
httpServletResponse.addHeader(RMToolConstants.HDR_OSLC_VERSION, RMToolConstants.OSLC_VERSION_V2);
addCORS(httpServletResponse);
rd.forward(httpServletRequest, httpServletResponse);
}

Expand Down