views:

87

answers:

1

Hi,

after successfully building my application the start fails because it relies on config files which are located in the META-INF directory and after the build this directory is zipped into a jar file, hence making it unable to access the config files. After manually unzipping the jar, deleting the jar and renaming the directory with xxx.jar the program runs without a problem. The config files are needed for SSO login (Kerberos). Here is the code:

Bundle bundle = Platform.getBundle(Application.PLUGIN_ID);
String path;
try {
    path = new URL(bundle.getLocation().substring(18)).getPath();
} catch (MalformedURLException e1) {
    System.out.println(e1);
    path="";
} 
System.setProperty("java.security.auth.login.config",path+"META-INF/jaas-win.config");

Path variable contains something like "plugin/mydomain.pluginame-xxxx.jar/" But it seems that the System needs the jar unzipped.

That am I doing wrong building the app? Thanks

A: 

After changing the code to:

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    URL authconf = null;
    authconf= cl.getResource("META-INF/jaas-win.config");

    if (authconf == null) {
        loginContext = null;
        return;
    }

    String p;
    try {
         p = URLDecoder.decode(authconf.toExternalForm(), "UTF-8");
         System.setProperty("java.security.auth.login.config", p);
    } catch (UnsupportedEncodingException e1) {
        loginContext = null;
        return;
    }

it works now.

Raven