-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add application stack filter to PicsureInfoService
Updated PicsureInfoService to restrict resources based on application stack. If the application stack configuration value exists and is not blank, resources will be filtered for that stack only. JAXRSConfiguration updated to initialize application stack. This helps when there is more than one application stack.
- Loading branch information
Showing
2 changed files
with
118 additions
and
89 deletions.
There are no files selected for viewing
105 changes: 60 additions & 45 deletions
105
pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/JAXRSConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,60 @@ | ||
package edu.harvard.dbmi.avillach; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.ejb.Startup; | ||
import javax.naming.Context; | ||
import javax.naming.InitialContext; | ||
import javax.naming.NamingException; | ||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
@Startup | ||
@ApplicationPath("PICSURE") | ||
public class JAXRSConfiguration extends Application { | ||
|
||
private Logger logger = LoggerFactory.getLogger(JAXRSConfiguration.class); | ||
|
||
public static String rolesClaim; | ||
|
||
@PostConstruct | ||
public void init() { | ||
logger.info("Starting pic-sure core app."); | ||
|
||
logger.info("Initializing roles claim."); | ||
initializeRolesClaim(); | ||
logger.info("Finished initializing roles claim."); | ||
|
||
} | ||
|
||
private void initializeRolesClaim(){ | ||
try{ | ||
Context ctx = new InitialContext(); | ||
rolesClaim = (String) ctx.lookup("global/roles_claim"); | ||
ctx.close(); | ||
} catch (NamingException e) { | ||
rolesClaim = "privileges"; | ||
} | ||
} | ||
|
||
public JAXRSConfiguration(){ | ||
} | ||
|
||
} | ||
package edu.harvard.dbmi.avillach; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.ejb.Startup; | ||
import javax.naming.Context; | ||
import javax.naming.InitialContext; | ||
import javax.naming.NamingException; | ||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
@Startup | ||
@ApplicationPath("PICSURE") | ||
public class JAXRSConfiguration extends Application { | ||
|
||
private Logger logger = LoggerFactory.getLogger(JAXRSConfiguration.class); | ||
|
||
public static String rolesClaim; | ||
|
||
public static String application_stack; | ||
|
||
@PostConstruct | ||
public void init() { | ||
logger.info("Starting pic-sure core app."); | ||
|
||
logger.info("Initializing roles claim."); | ||
initializeRolesClaim(); | ||
logger.info("Finished initializing roles claim."); | ||
|
||
logger.info("Load optional properties."); | ||
initializeApplicationStack(); | ||
logger.info("Finished loading optional properties."); | ||
} | ||
|
||
private void initializeApplicationStack() { | ||
try { | ||
Context ctx = new InitialContext(); | ||
application_stack = (String) ctx.lookup("global/application_stack"); | ||
ctx.close(); | ||
} catch (NamingException e) { | ||
// Currently, this parameter is optional and only used if there is more than one application stack. | ||
application_stack = null; | ||
} | ||
} | ||
|
||
private void initializeRolesClaim() { | ||
try { | ||
Context ctx = new InitialContext(); | ||
rolesClaim = (String) ctx.lookup("global/roles_claim"); | ||
ctx.close(); | ||
} catch (NamingException e) { | ||
rolesClaim = "privileges"; | ||
} | ||
} | ||
|
||
public JAXRSConfiguration() {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters