Skip to content
Closed
Show file tree
Hide file tree
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 @@ -153,6 +153,7 @@ public Set<Object> getSingletons() {
// Start of user code Custom Resource Classes
RESOURCE_CLASSES.add(OslcCorsFilter.class);
RESOURCE_CLASSES.add(OslcCspFilter.class);
RESOURCE_CLASSES.add(ExtendedPropWriteInterceptor.class);
// End of user code

RESOURCE_SHAPE_PATH_TO_RESOURCE_CLASS_MAP.put(OslcConstants.PATH_ALLOWED_VALUES, AllowedValues.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package co.oslc.refimpl.cm.gen.servlet;

import co.oslc.refimpl.cm.gen.CMConstants;
import co.oslc.refimpl.cm.gen.auth.AuthenticationApplication;
import org.eclipse.lyo.oslc4j.core.model.ServiceProviderCatalog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.ext.Provider;
import javax.ws.rs.ext.WriterInterceptor;
import javax.ws.rs.ext.WriterInterceptorContext;
import javax.xml.namespace.QName;
import java.io.IOException;

@Provider
public class ExtendedPropWriteInterceptor implements WriterInterceptor {
private static final QName OAUTH_REALM_NAME = new QName("http://jazz.net/xmlns/prod/jazz/jfs/1.0/", "oauthRealmName");
private final Logger log = LoggerFactory.getLogger(ExtendedPropWriteInterceptor.class);

@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
log.info("Interceptor called");
final Object entity = context.getEntity();
if (entity instanceof ServiceProviderCatalog) {
final ServiceProviderCatalog catalog = (ServiceProviderCatalog) entity;
catalog.getExtendedProperties().put(OAUTH_REALM_NAME, AuthenticationApplication.OAUTH_REALM);
context.setEntity(catalog);
}
context.proceed();
}
}