File tree 2 files changed +33
-0
lines changed
src/server-cm/src/main/java/co/oslc/refimpl/cm/gen/servlet
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ public Set<Object> getSingletons() {
151
151
// Start of user code Custom Resource Classes
152
152
RESOURCE_CLASSES .add (OslcCorsFilter .class );
153
153
RESOURCE_CLASSES .add (OslcCspFilter .class );
154
+ RESOURCE_CLASSES .add (ExtendedPropWriteInterceptor .class );
154
155
// End of user code
155
156
156
157
RESOURCE_SHAPE_PATH_TO_RESOURCE_CLASS_MAP .put (OslcConstants .PATH_ALLOWED_VALUES , AllowedValues .class );
Original file line number Diff line number Diff line change
1
+ package co .oslc .refimpl .cm .gen .servlet ;
2
+
3
+ import co .oslc .refimpl .cm .gen .CMConstants ;
4
+ import co .oslc .refimpl .cm .gen .auth .AuthenticationApplication ;
5
+ import org .eclipse .lyo .oslc4j .core .model .ServiceProviderCatalog ;
6
+ import org .slf4j .Logger ;
7
+ import org .slf4j .LoggerFactory ;
8
+
9
+ import javax .ws .rs .WebApplicationException ;
10
+ import javax .ws .rs .ext .Provider ;
11
+ import javax .ws .rs .ext .WriterInterceptor ;
12
+ import javax .ws .rs .ext .WriterInterceptorContext ;
13
+ import javax .xml .namespace .QName ;
14
+ import java .io .IOException ;
15
+
16
+ @ Provider
17
+ public class ExtendedPropWriteInterceptor implements WriterInterceptor {
18
+ private static final QName OAUTH_REALM_NAME = new QName ("http://jazz.net/xmlns/prod/jazz/jfs/1.0/" , "oauthRealmName" );
19
+ private final Logger log = LoggerFactory .getLogger (ExtendedPropWriteInterceptor .class );
20
+
21
+ @ Override
22
+ public void aroundWriteTo (WriterInterceptorContext context ) throws IOException , WebApplicationException {
23
+ log .info ("Interceptor called" );
24
+ final Object entity = context .getEntity ();
25
+ if (entity instanceof ServiceProviderCatalog ) {
26
+ final ServiceProviderCatalog catalog = (ServiceProviderCatalog ) entity ;
27
+ catalog .getExtendedProperties ().put (OAUTH_REALM_NAME , AuthenticationApplication .OAUTH_REALM );
28
+ context .setEntity (catalog );
29
+ }
30
+ context .proceed ();
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments