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

Added System property as another fallback option #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -39,6 +39,12 @@ public static IssuedTokenManager getInstance(){
}
}

public static void reInitialize(){
synchronized (IssuedTokenManager.class) {
manager = new IssuedTokenManager();
}
}

public IssuedTokenContext createIssuedTokenContext(IssuedTokenConfiguration config, String appliesTo){
IssuedTokenContext ctx = new IssuedTokenContextImpl();
ctx.getSecurityPolicy().add(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,15 @@ public class DefaultCallbackHandler implements CallbackHandler {
private Class truststoreCertSelectorClass;
private String useXWSSCallbacksStr;
private boolean useXWSSCallbacks;
private static final String SECURITY_ENV_PATH_LOCATION = "com.sun.xml.wss.security-env-properties";

public DefaultCallbackHandler(String clientOrServer, Properties assertions) throws XWSSecurityException {

Properties properties = null;
if (assertions != null && !assertions.isEmpty()) {
properties = assertions;
} else {
//fallback option
//1st fallback option
properties = new Properties();
String resource = clientOrServer + "-security-env.properties";
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
Expand All @@ -231,9 +232,32 @@ public DefaultCallbackHandler(String clientOrServer, Properties assertions) thro
properties.load(in);
} catch (IOException ex) {
throw new XWSSecurityException(ex);
} finally {
try {
in.close();
} catch (IOException e) {}
}
} else {
//throw new XWSSecurityException("Resource " + resource + " could not be located in classpath");
//2nd and 3rd fallback check system properties
String path = System.getProperty(SECURITY_ENV_PATH_LOCATION);
if(path==null) {
path = java.lang.System.getenv(SECURITY_ENV_PATH_LOCATION);
}
if(path!=null) {
try {
in = new FileInputStream(path);
properties.load(in);
} catch (IOException ex) {
throw new XWSSecurityException(ex);
} finally {
try {
if(in!=null) in.close();
}catch (IOException e) {}
}
}
else {
//throw new XWSSecurityException("Resource " + resource + " could not be located in the classpath nor in the file system.");
}
}
}

Expand Down