[jboss-cvs] JBossAS SVN: r71560 - projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/plugins.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 1 11:41:49 EDT 2008
Author: mmoyses
Date: 2008-04-01 11:41:49 -0400 (Tue, 01 Apr 2008)
New Revision: 71560
Modified:
projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/plugins/FilePassword.java
Log:
SECURITY-163
modified the constructor to accept URLs
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/plugins/FilePassword.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/plugins/FilePassword.java 2008-04-01 15:12:11 UTC (rev 71559)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/plugins/FilePassword.java 2008-04-01 15:41:49 UTC (rev 71560)
@@ -23,8 +23,12 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.RandomAccessFile;
+import java.net.MalformedURLException;
+import java.net.URL;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
@@ -37,8 +41,8 @@
/** Read a password in opaque form to a file for use with the FilePassword
accessor in conjunction with the JaasSecurityDomain
{CLASS}org.jboss.security.plugins.FilePassword:password-file
- format of the KeyStorePass attribute. The original opaque password file
- can be created by running:
+ format of the KeyStorePass attribute. The password file can also be an URL.
+ The original opaque password file can be created by running:
java org.jboss.security.plugins.FilePassword salt count password password-file
Running
java org.jboss.security.plugins.FilePassword
@@ -59,7 +63,45 @@
public FilePassword(String file)
{
- passwordFile = new File(file);
+ URL url = null;
+ try
+ {
+ url = new URL(file);
+ }
+ catch (MalformedURLException e)
+ {
+ }
+
+ if (url == null)
+ passwordFile = new File(file);
+ else
+ {
+ FileOutputStream fos = null;
+ try
+ {
+ InputStream is = url.openStream();
+ passwordFile = File.createTempFile("temp", null);
+ passwordFile.deleteOnExit();
+ fos = new FileOutputStream(passwordFile);
+ int b;
+ while ((b = is.read()) >= 0)
+ fos.write(b);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ try
+ {
+ if (fos != null)
+ fos.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
}
public char[] toCharArray()
More information about the jboss-cvs-commits
mailing list