You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2006/04/14 08:30:51 UTC
svn commit: r394030 [3/3] - in /geronimo/branches/1.1:
applications/console-core/src/java/org/apache/geronimo/console/util/
applications/console-framework/src/webapp/WEB-INF/data/
applications/console-standard/src/java/org/apache/geronimo/console/ appl...
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java Thu Apr 13 23:30:38 2006
@@ -69,6 +69,12 @@
this.configId = configId;
}
+ /**
+ * Gets a List (with elements of type Dependency) of the configuration and
+ * JAR dependencies of this configuration.
+ *
+ * @see Dependency
+ */
public List getDependencies() {
return Collections.unmodifiableList(new ArrayList(dependencies));
}
@@ -94,6 +100,10 @@
addDependencies(dependencies);
}
+ /**
+ * todo: I should be documented so it's not completely unclear what kind of
+ * elements I hold.
+ */
public Set getHiddenClasses() {
return hiddenClasses;
}
@@ -107,6 +117,10 @@
addHiddenClasses(hiddenClasses);
}
+ /**
+ * todo: I should be documented so it's not completely unclear what kind of
+ * elements I hold.
+ */
public Set getNonOverrideableClasses() {
return nonOverrideableClasses;
}
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java Thu Apr 13 23:30:38 2006
@@ -121,41 +121,13 @@
KernelConfigurationManager.class.getClassLoader());
}
- private class TestConfigStore implements ConfigurationStore {
- public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
- throw new UnsupportedOperationException();
- }
-
- public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
- throw new UnsupportedOperationException();
- }
-
+ private class TestConfigStore extends NullConfigurationStore {
public ConfigurationData loadConfiguration(Artifact configId) throws IOException, InvalidConfigException, NoSuchConfigException {
return (ConfigurationData) configurations.get(configId);
}
public boolean containsConfiguration(Artifact configId) {
return configurations.containsKey(configId);
- }
-
- public String getObjectName() {
- throw new UnsupportedOperationException();
- }
-
- public AbstractName getAbstractName() {
- throw new UnsupportedOperationException();
- }
-
- public List listConfigurations() {
- throw new UnsupportedOperationException();
- }
-
- public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
- throw new UnsupportedOperationException();
- }
-
- public URL resolve(Artifact configId, String moduleName, URI uri) throws NoSuchConfigException, MalformedURLException {
- throw new UnsupportedOperationException();
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java Thu Apr 13 23:30:38 2006
@@ -40,6 +40,7 @@
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.NullConfigurationStore;
/**
* @version $Rev$ $Date$
@@ -148,8 +149,7 @@
}
}
- public static class MockConfigStore implements ConfigurationStore {
-
+ public static class MockConfigStore extends NullConfigurationStore {
URL baseURL;
public MockConfigStore() {
@@ -159,12 +159,6 @@
this.baseURL = baseURL;
}
- public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
- }
-
- public void uninstall(Artifact configID) throws NoSuchConfigException, IOException {
- }
-
public ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException {
ConfigurationData configurationData = new ConfigurationData(configId, new Jsr77Naming());
configurationData.setConfigurationStore(this);
@@ -173,22 +167,6 @@
public boolean containsConfiguration(Artifact configID) {
return true;
- }
-
- public String getObjectName() {
- return null;
- }
-
- public AbstractName getAbstractName() {
- return null;
- }
-
- public List listConfigurations() {
- return null;
- }
-
- public File createNewConfigurationDir(Artifact configId) {
- return null;
}
public URL resolve(Artifact configId, String moduleName, URI uri) throws NoSuchConfigException, MalformedURLException {
Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/J2EEServer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/J2EEServer.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/J2EEServer.java (original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/J2EEServer.java Thu Apr 13 23:30:38 2006
@@ -19,7 +19,9 @@
import org.apache.geronimo.management.J2EEDeployedObject;
import org.apache.geronimo.management.J2EEResource;
import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.system.configuration.ConfigurationInstaller;
/**
* Geronimo-specific extensions to the standard J2EE server management
@@ -114,4 +116,13 @@
*/
public KeystoreManager getKeystoreManager();
+ /**
+ * Gets the ConfigurationInstaller associated with this J2EEServer.
+ */
+ public ConfigurationInstaller getConfigurationInstaller();
+
+ /**
+ * Gets the ConfigurationManager associated with this J2EEServer.
+ */
+ public ConfigurationManager getConfigurationManager();
}
Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreInstance.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreInstance.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreInstance.java (original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreInstance.java Thu Apr 13 23:30:38 2006
@@ -17,6 +17,11 @@
package org.apache.geronimo.management.geronimo;
import java.security.cert.Certificate;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.KeyStoreException;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.TrustManager;
/**
* Management interface for dealing with a specific Keystore
@@ -71,6 +76,19 @@
public boolean unlockPrivateKey(String alias, char[] password) throws KeystoreIsLocked;
/**
+ * Gets the aliases for all the private keys that are currently unlocked.
+ * This only works if the keystore is unlocked.
+ */
+ public String[] getUnlockedKeys() throws KeystoreIsLocked;
+
+ /**
+ * Checks whether this keystore can be used as a trust store (e.g. has at
+ * least one trust certificate). This only works if the keystore is
+ * unlocked.
+ */
+ public boolean isTrustStore() throws KeystoreIsLocked;
+
+ /**
* Clears any saved password for the specified private key, meaning this
* key cannot be used for a socket factory by other server components.
* You can still query and update it by passing the password to other
@@ -130,4 +148,22 @@
public boolean generateKeyPair(String alias, char[] storePassword, char[] keyPassword, String keyAlgorithm, int keySize,
String signatureAlgorithm, int validity, String commonName, String orgUnit,
String organization, String locality, String state, String country);
+
+
+ /**
+ * Gets a KeyManager for a key in this Keystore. This only works if both
+ * the keystore and the private key in question have been unlocked,
+ * allowing other components in the server to access them.
+ * @param algorithm The SSL algorithm to use for this key manager
+ * @param alias The alias of the key to use in the keystore
+ */
+ public KeyManager[] getKeyManager(String algorithm, String alias) throws NoSuchAlgorithmException,
+ UnrecoverableKeyException, KeyStoreException, KeystoreIsLocked;
+
+ /**
+ * Gets a TrustManager for this keystore. This only works if the keystore
+ * has been unlocked, allowing other components in the server to access it.
+ * @param algorithm The SSL algorithm to use for this trust manager
+ */
+ public TrustManager[] getTrustManager(String algorithm) throws KeyStoreException, NoSuchAlgorithmException, KeystoreIsLocked;
}
Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreManager.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreManager.java (original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/KeystoreManager.java Thu Apr 13 23:30:38 2006
@@ -16,7 +16,13 @@
*/
package org.apache.geronimo.management.geronimo;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.KeyStoreException;
+import java.security.KeyManagementException;
+import java.security.NoSuchProviderException;
import javax.net.ServerSocketFactory;
+import javax.net.ssl.SSLServerSocketFactory;
/**
* Management interface for working with keystores. Mostly this is used to
@@ -35,6 +41,9 @@
/**
* Gets a ServerSocketFactory using one Keystore to access the private key
* and another to provide the list of trusted certificate authorities.
+ * @param provider The SSL provider to use, or null for the default
+ * @param protocol The SSL protocol to use
+ * @param algorithm The SSL algorithm to use
* @param keyStore The key keystore name as provided by listKeystores. The
* KeystoreInstance for this keystore must be unlocked.
* @param keyAlias The name of the private key in the keystore. The
@@ -50,8 +59,9 @@
* keystore cannot be used because it has not been
* unlocked.
*/
- public ServerSocketFactory createSSLFactory(String keyStore, String keyAlias, String trustStore)
- throws KeystoreIsLocked, KeyIsLocked;
+ public SSLServerSocketFactory createSSLFactory(String provider, String protocol, String algorithm,
+ String keyStore, String keyAlias, String trustStore, ClassLoader loader)
+ throws KeystoreIsLocked, KeyIsLocked, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException, NoSuchProviderException;
/**
* Creates a new, empty keystore. The name should be a valid file name
@@ -61,4 +71,18 @@
* @param password The password to use to protect the new keystore
*/
public KeystoreInstance createKeystore(String name, char[] password);
+
+ /**
+ * Gets the aliases for any keystores that are available to be used as
+ * private key keystores for an SSL factory. This means the keystore is
+ * unlocked and contains at least one private key that's unlocked.
+ */
+ public KeystoreInstance[] getUnlockedKeyStores();
+
+ /**
+ * Gets the aliases for any keystores that are available to be used as
+ * trusted certificate keystores for an SSL factory. This means the
+ * keystore is unlocked and contains at least one trust certificate.
+ */
+ public KeystoreInstance[] getUnlockedTrustStores();
}
Modified: geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java (original)
+++ geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java Thu Apr 13 23:30:38 2006
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
+import java.net.URI;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -33,6 +34,7 @@
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
@@ -41,20 +43,26 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.DynamicGBean;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.management.geronimo.KeystoreInstance;
import org.apache.geronimo.management.geronimo.KeystoreIsLocked;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
import org.apache.geronimo.util.jce.X509Principal;
import org.apache.geronimo.util.jce.X509V1CertificateGenerator;
@@ -65,27 +73,52 @@
*
* @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
*/
-public class FileKeystoreInstance implements KeystoreInstance, DynamicGBean {
+public class FileKeystoreInstance implements KeystoreInstance, GBeanLifecycle {
private static final Log log = LogFactory.getLog(FileKeystoreInstance.class);
- private final static String MAGIC_KEYSTORE_PWD_KEY = "#KeystorePW";
final static String JKS = "JKS";
- private File keystoreFile;
+ private URI keystorePath; // relative path
+ private ServerInfo serverInfo; // used to decode relative path
+ private File keystoreFile; // Only valid after startup
private String keystoreName;
- private Map unlockKeyPasswords = new HashMap();
+ private char[] keystorePassword; // Used to "unlock" the keystore for other services
+ private Map keyPasswords = new HashMap();
private Kernel kernel;
private ObjectName objectName;
- private char[] openPassword;
+ private char[] openPassword; // The password last used to open the keystore for editing
// The following variables are the state of the keystore, which should be chucked if the file on disk changes
private List privateKeys = new ArrayList();
private List trustCerts = new ArrayList();
private KeyStore keystore;
private long keystoreReadDate = Long.MIN_VALUE;
- public FileKeystoreInstance(File keystoreFile, String keystoreName, Kernel kernel, String objectName) throws MalformedObjectNameException {
- this.keystoreFile = keystoreFile;
+ public FileKeystoreInstance(ServerInfo serverInfo, URI keystorePath, String keystoreName, String keystorePassword, String keyPasswords, Kernel kernel, String objectName) throws MalformedObjectNameException {
+ this.serverInfo = serverInfo;
+ this.keystorePath = keystorePath;
this.keystoreName = keystoreName;
this.kernel = kernel;
this.objectName = ObjectName.getInstance(objectName);
+ this.keystorePassword = keystorePassword == null ? null : keystorePassword.toCharArray();
+ if(keyPasswords != null) {
+ String[] keys = keyPasswords.split("\\]\\!\\[");
+ for (int i = 0; i < keys.length; i++) {
+ String key = keys[i];
+ int pos = key.indexOf('=');
+ this.keyPasswords.put(key.substring(0, pos), key.substring(pos+1).toCharArray());
+ }
+ }
+ }
+
+ public void doStart() throws Exception {
+ keystoreFile = new File(serverInfo.resolve(keystorePath));
+ if(!keystoreFile.exists() || !keystoreFile.canRead()) {
+ throw new IllegalArgumentException("Invalid keystore file ("+keystorePath+" = "+keystoreFile.getAbsolutePath()+")");
+ }
+ }
+
+ public void doStop() throws Exception {
+ }
+
+ public void doFail() {
}
public String getKeystoreName() {
@@ -94,25 +127,16 @@
public boolean unlockKeystore(char[] password) {
//todo: test whether password is correct and if not return false
- try {
- kernel.setAttribute(objectName, MAGIC_KEYSTORE_PWD_KEY, password);
- } catch (Exception e) {
- log.error("Unable to save keystore password for keystore '"+keystoreName+"'", e);
- return false;
- }
+ keystorePassword = password;
return true;
}
public void lockKeystore() {
- try {
- kernel.setAttribute(objectName, MAGIC_KEYSTORE_PWD_KEY, null);
- } catch (Exception e) {
- log.error("Unable to clear keystore password for keystore '"+keystoreName+"'", e);
- }
+ keystorePassword = null;
}
public boolean isKeystoreLocked() {
- return unlockKeyPasswords.get(MAGIC_KEYSTORE_PWD_KEY) == null;
+ return keystorePassword == null;
}
public String[] listPrivateKeys(char[] storePassword) {
@@ -129,25 +153,56 @@
throw new KeystoreIsLocked("Keystore '"+keystoreName+"' is locked!");
}
//todo: test whether password is correct and if not return false
- try {
- kernel.setAttribute(objectName, alias, password);
- } catch (Exception e) {
- log.error("Unable to save key password for key '"+alias+"' in keystore '"+keystoreName+"'", e);
- return false;
- }
+ keyPasswords.put(alias, password);
+ storePasswords();
return true;
}
+ public String[] getUnlockedKeys() throws KeystoreIsLocked {
+ if(isKeystoreLocked()) {
+ throw new KeystoreIsLocked("Keystore '"+keystoreName+"' is locked; please unlock it in the console.");
+ }
+ if(keystore == null || keystoreReadDate < keystoreFile.lastModified()) {
+ loadKeystoreData(keystorePassword);
+ }
+ return (String[]) keyPasswords.keySet().toArray(new String[keyPasswords.size()]);
+ }
+
+ public boolean isTrustStore() throws KeystoreIsLocked {
+ if(isKeystoreLocked()) {
+ throw new KeystoreIsLocked("Keystore '"+keystoreName+"' is locked; please unlock it in the console.");
+ }
+ if(keystore == null || keystoreReadDate < keystoreFile.lastModified()) {
+ loadKeystoreData(keystorePassword);
+ }
+ return trustCerts.size() > 0;
+ }
+
public void lockPrivateKey(String alias) {
+ storePasswords();
+ keyPasswords.remove(alias);
+ }
+
+ private void storePasswords() {
+ StringBuffer buf = new StringBuffer();
+ for (Iterator it = keyPasswords.entrySet().iterator(); it.hasNext();) {
+ if(buf.length() > 0) {
+ buf.append("]![");
+ }
+ Map.Entry entry = (Map.Entry) it.next();
+ buf.append(entry.getKey()).append("=").append(entry.getValue());
+ }
try {
- kernel.setAttribute(objectName, alias, null);
+ kernel.setAttribute(objectName, "keyPasswords", buf.toString());
} catch (Exception e) {
- log.error("Unable to clear keystore password for keystore '"+keystoreName+"'", e);
+ log.error("Unable to save key passwords in keystore '"+keystoreName+"'", e);
}
}
+ public void setKeyPasswords(String passwords) {} // Just so the kernel sees the new value
+
public boolean isKeyUnlocked(String alias) {
- return unlockKeyPasswords.get(alias) == null;
+ return keyPasswords.get(alias) == null;
}
public String[] listTrustCertificates(char[] storePassword) {
@@ -212,6 +267,29 @@
return false;
}
+ public KeyManager[] getKeyManager(String algorithm, String alias) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeystoreIsLocked {
+ if(isKeystoreLocked()) {
+ throw new KeystoreIsLocked("Keystore '"+keystoreName+"' is locked; please unlock it in the console.");
+ }
+ if(keystore == null || keystoreReadDate < keystoreFile.lastModified()) {
+ loadKeystoreData(keystorePassword);
+ }
+ KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(algorithm);
+ keyFactory.init(keystore, (char[]) keyPasswords.get(alias));
+ return keyFactory.getKeyManagers();
+ }
+
+ public TrustManager[] getTrustManager(String algorithm) throws KeyStoreException, NoSuchAlgorithmException, KeystoreIsLocked {
+ if(isKeystoreLocked()) {
+ throw new KeystoreIsLocked("Keystore '"+keystoreName+"' is locked; please unlock it in the console.");
+ }
+ if(keystore == null || keystoreReadDate < keystoreFile.lastModified()) {
+ loadKeystoreData(keystorePassword);
+ }
+ TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(algorithm);
+ trustFactory.init(keystore);
+ return trustFactory.getTrustManagers();
+ }
private boolean saveKeystore(char[] password) {
try {
@@ -233,30 +311,19 @@
return false;
}
- // ==================== Should only be accessed by the Kernel =================
-
- public Object getAttribute(String name) throws Exception {
- return unlockKeyPasswords.get(name);
- }
-
- public void setAttribute(String name, Object value) throws Exception {
- unlockKeyPasswords.put(name, value);
- }
-
- public Object invoke(String name, Object[] arguments, String[] types) throws Exception {
- throw new UnsupportedOperationException();
- }
-
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(FileKeystoreInstance.class, NameFactory.KEYSTORE_INSTANCE);
- infoFactory.addAttribute("keystoreFile", File.class, true, false);
+ infoFactory.addAttribute("keystorePath", URI.class, true, false);
infoFactory.addAttribute("keystoreName", String.class, true, false);
+ infoFactory.addAttribute("keystorePassword", String.class, true, true);
+ infoFactory.addAttribute("keyPasswords", String.class, true, true);
infoFactory.addAttribute("kernel", Kernel.class, false);
infoFactory.addAttribute("objectName", String.class, false);
+ infoFactory.addReference("ServerInfo", ServerInfo.class, NameFactory.GERONIMO_SERVICE);
infoFactory.addInterface(KeystoreInstance.class);
- infoFactory.setConstructor(new String[]{"keystoreFile", "keystoreName", "kernel", "objectName"});
+ infoFactory.setConstructor(new String[]{"ServerInfo","keystorePath", "keystoreName", "keystorePassword", "keyPasswords", "kernel", "objectName"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
@@ -299,10 +366,6 @@
log.error("Unable to open keystore with provided password", e);
}
return false;
- }
-
- private char[] getKeystorePassword() {
- return (char[])unlockKeyPasswords.get(MAGIC_KEYSTORE_PWD_KEY);
}
private boolean isLoaded(char[] password) {
Modified: geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreManager.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreManager.java (original)
+++ geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreManager.java Thu Apr 13 23:30:38 2006
@@ -23,11 +23,15 @@
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
+import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
@@ -37,7 +41,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import javax.net.ServerSocketFactory;
+import javax.net.ssl.SSLServerSocketFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.AbstractName;
@@ -141,7 +145,16 @@
AbstractName myName = kernel.getAbstractNameFor(this);
aName = kernel.getNaming().createChildName(myName, name, NameFactory.KEYSTORE_INSTANCE);
GBeanData data = new GBeanData(aName, FileKeystoreInstance.getGBeanInfo());
- data.setAttribute("keystoreFile", test);
+ try {
+ String path = configuredDir.toString();
+ if(!path.endsWith("/")) {
+ path += "/";
+ }
+ data.setAttribute("keystorePath", new URI(path +name));
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException("Can't resolve keystore path: "+e.getMessage());
+ }
+ data.setReferencePattern("ServerInfo", kernel.getAbstractNameFor(serverInfo));
data.setAttribute("keystoreName", name);
EditableConfigurationManager mgr = ConfigurationUtil.getEditableConfigurationManager(kernel);
if(mgr != null) {
@@ -160,8 +173,35 @@
}
}
- public ServerSocketFactory createSSLFactory(String keyStore, String keyAlias, String trustStore) throws KeystoreIsLocked, KeyIsLocked {
- throw new UnsupportedOperationException();
+ public SSLServerSocketFactory createSSLFactory(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore, ClassLoader loader) throws KeystoreIsLocked, KeyIsLocked, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException, NoSuchProviderException {
+ KeystoreInstance keyInstance = getKeystore(keyStore);
+ if(keyInstance.isKeystoreLocked()) {
+ throw new KeystoreIsLocked("Keystore '"+keyStore+"' is locked; please use the keystore page in the admin console to unlock it");
+ }
+ if(keyInstance.isKeyUnlocked(keyAlias)) {
+ throw new KeystoreIsLocked("Key '"+keyAlias+"' in keystore '"+keyStore+"' is locked; please use the keystore page in the admin console to unlock it");
+ }
+ KeystoreInstance trustInstance = trustStore == null ? null : getKeystore(trustStore);
+ if(trustInstance != null && trustInstance.isKeystoreLocked()) {
+ throw new KeystoreIsLocked("Keystore '"+trustStore+"' is locked; please use the keystore page in the admin console to unlock it");
+ }
+
+ // OMG this hurts, but it causes ClassCastExceptions elsewhere unless done this way!
+ try {
+ Class cls = loader.loadClass("javax.net.ssl.SSLContext");
+ Object ctx = cls.getMethod("getInstance", new Class[] {String.class}).invoke(null, new Object[]{protocol});
+ Class kmc = loader.loadClass("[Ljavax.net.ssl.KeyManager;");
+ Class tmc = loader.loadClass("[Ljavax.net.ssl.TrustManager;");
+ Class src = loader.loadClass("java.security.SecureRandom");
+ cls.getMethod("init", new Class[]{kmc, tmc, src}).invoke(ctx, new Object[]{keyInstance.getKeyManager(algorithm, keyAlias),
+ trustInstance == null ? null : trustInstance.getTrustManager(algorithm),
+ new java.security.SecureRandom()});
+ Object result = cls.getMethod("getServerSocketFactory", new Class[0]).invoke(ctx, new Object[0]);
+ return (SSLServerSocketFactory) result;
+ } catch (Exception e) {
+ log.error("Unable to dynamically load", e);
+ return null;
+ }
}
public KeystoreInstance createKeystore(String name, char[] password) {
@@ -187,6 +227,32 @@
log.error("Unable to create keystore", e);
}
return null;
+ }
+
+ public KeystoreInstance[] getUnlockedKeyStores() {
+ List results = new ArrayList();
+ for (Iterator it = keystores.iterator(); it.hasNext();) {
+ KeystoreInstance instance = (KeystoreInstance) it.next();
+ try {
+ if(!instance.isKeystoreLocked() && instance.getUnlockedKeys().length > 0) {
+ results.add(instance);
+ }
+ } catch (KeystoreIsLocked locked) {}
+ }
+ return (KeystoreInstance[]) results.toArray(new KeystoreInstance[results.size()]);
+ }
+
+ public KeystoreInstance[] getUnlockedTrustStores() {
+ List results = new ArrayList();
+ for (Iterator it = keystores.iterator(); it.hasNext();) {
+ KeystoreInstance instance = (KeystoreInstance) it.next();
+ try {
+ if(!instance.isKeystoreLocked() && instance.isTrustStore()) {
+ results.add(instance);
+ }
+ } catch (KeystoreIsLocked locked) {}
+ }
+ return (KeystoreInstance[]) results.toArray(new KeystoreInstance[results.size()]);
}
public static final GBeanInfo GBEAN_INFO;
Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java?rev=394030&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java Thu Apr 13 23:30:38 2006
@@ -0,0 +1,285 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.system.configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.WriteableRepository;
+import org.apache.geronimo.util.encoders.Base64;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * A GBean that knows how to download configurations from a Maven repository.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class ConfigInstallerGBean implements ConfigurationInstaller {
+ private final static Log log = LogFactory.getLog(ConfigInstallerGBean.class);
+ private ConfigurationManager configManager;
+ private WriteableRepository writeableRepo;
+ private ConfigurationStore configStore;
+
+ public ConfigInstallerGBean(ConfigurationManager configManager, WriteableRepository repository, ConfigurationStore configStore) {
+ this.configManager = configManager;
+ this.writeableRepo = repository;
+ this.configStore = configStore;
+ }
+
+ public ConfigurationMetadata[] listConfigurations(URL mavenRepository, String username, String password) throws IOException {
+ String repository = mavenRepository.toString();
+ if(!repository.endsWith("/")) {
+ repository = repository+"/";
+ }
+ URL url = new URL(repository+"geronimo-configs.xml");
+ InputStream in = openStream(url, username, password);
+ try {
+ return loadConfiguration(in);
+ } catch (Exception e) {
+ log.error("Unable to load repository configuration data", e);
+ return new ConfigurationMetadata[0];
+ }
+ }
+
+ private ConfigurationMetadata[] loadConfiguration(InputStream in) throws ParserConfigurationException, IOException, SAXException {
+ ConfigurationStore[] stores = configManager.getStores();
+ Set set = new HashSet();
+ for (int i = 0; i < stores.length; i++) {
+ ConfigurationStore store = stores[i];
+ List list = store.listConfigurations();
+ for (int j = 0; j < list.size(); j++) {
+ ConfigurationInfo info = (ConfigurationInfo) list.get(i);
+ set.add(info.getConfigID().toString());
+ }
+ }
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(in);
+ in.close();
+ Element root = doc.getDocumentElement();
+ NodeList configs = root.getElementsByTagName("configuration");
+ List results = new ArrayList();
+ for (int i = 0; i < configs.getLength(); i++) {
+ Element config = (Element) configs.item(i);
+ String configId = getChildText(config, "config-id");
+ boolean eligible = true;
+ String[] prereqs = getChildrenText(config, "prerequisite");
+ for (int j = 0; j < prereqs.length; j++) {
+ boolean found = false;
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ String id = (String) it.next();
+ if(id.startsWith(prereqs[j])) {
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ eligible = false;
+ break;
+ }
+ }
+ Artifact artifact = Artifact.create(configId);
+ ConfigurationMetadata data = new ConfigurationMetadata(artifact, getChildText(config, "name"), getChildText(config, "category"), configManager.isLoaded(artifact), eligible);
+ data.setGeronimoVersions(getChildrenText(config, "geronimo-version"));
+ data.setPrerequisites(prereqs);
+ results.add(data);
+ }
+ return (ConfigurationMetadata[]) results.toArray(new ConfigurationMetadata[results.size()]);
+ }
+
+ private String getChildText(Element root, String property) {
+ NodeList children = root.getChildNodes();
+ for(int i=0; i<children.getLength(); i++) {
+ Node check = children.item(i);
+ if(check.getNodeType() == Node.ELEMENT_NODE && check.getNodeName().equals(property)) {
+ NodeList nodes = check.getChildNodes();
+ StringBuffer buf = null;
+ for(int j=0; j<nodes.getLength(); j++) {
+ Node node = nodes.item(j);
+ if(node.getNodeType() == Node.TEXT_NODE) {
+ if(buf == null) {
+ buf = new StringBuffer();
+ }
+ buf.append(node.getNodeValue());
+ }
+ }
+ return buf == null ? null : buf.toString();
+ }
+ }
+ return null;
+ }
+
+ private String[] getChildrenText(Element root, String property) {
+ NodeList children = root.getChildNodes();
+ List results = new ArrayList();
+ for(int i=0; i<children.getLength(); i++) {
+ Node check = children.item(i);
+ if(check.getNodeType() == Node.ELEMENT_NODE && check.getNodeName().equals(property)) {
+ NodeList nodes = check.getChildNodes();
+ StringBuffer buf = null;
+ for(int j=0; j<nodes.getLength(); j++) {
+ Node node = nodes.item(j);
+ if(node.getNodeType() == Node.TEXT_NODE) {
+ if(buf == null) {
+ buf = new StringBuffer();
+ }
+ buf.append(node.getNodeValue());
+ }
+ }
+ results.add(buf == null ? null : buf.toString());
+ }
+ }
+ return (String[]) results.toArray(new String[results.size()]);
+ }
+
+ public ConfigurationMetadata loadDependencies(URL mavenRepository, String username, String password, ConfigurationMetadata source) throws IOException {
+ String configId = source.getConfigId().toString();
+ String url = getURL(configId, mavenRepository.toString());
+
+ Artifact artifact = Artifact.create(configId);
+ InputStream in = openStream(new URL(url), username, password);
+ try { //todo: use a file status monitor
+ writeableRepo.copyToRepository(in, artifact, null); //todo: download only SNAPSHOTS if previously available?
+ } finally {
+ in.close();
+ }
+ try {
+ ConfigurationData data = configStore.loadConfiguration(artifact);
+ source.setDependencies(getDependencies(data));
+ return source;
+ } catch (NoSuchConfigException e) {
+ throw new IllegalStateException("Installed configuration into repository but ConfigStore does not see it: "+e.getMessage());
+ } catch (InvalidConfigException e) {
+ throw new IllegalStateException("Installed configuration into repository but ConfigStore cannot load it: "+e.getMessage());
+ }
+ }
+
+ private static Dependency[] getDependencies(ConfigurationData data) {
+ List dependencies = data.getEnvironment().getDependencies();
+ Collection children = data.getChildConfigurations().values();
+ for (Iterator it = children.iterator(); it.hasNext();) {
+ ConfigurationData child = (ConfigurationData) it.next();
+ dependencies.addAll(child.getEnvironment().getDependencies());
+ }
+ return (Dependency[]) children.toArray(new Dependency[children.size()]);
+ }
+
+ public DownloadResults install(URL mavenRepository, String username, String password, Artifact configId) throws IOException {
+ DownloadResults results = new DownloadResults();
+ downloadConfigurationDeps(configId,mavenRepository.toString(),username,password,results);
+ return results;
+ }
+
+ private String getURL(String configId, String baseRepositoryURL) {
+ if(!baseRepositoryURL.endsWith("/")) {
+ baseRepositoryURL += "/";
+ }
+ String[] parts = configId.split("/");
+ return baseRepositoryURL+parts[0]+"/"+parts[3]+"s/"+parts[1]+"-"+parts[2]+"."+parts[3];
+ }
+
+ private InputStream openStream(URL url, String username, String password) throws IOException {
+ InputStream in;
+ if(username != null) { //todo: try connecting first and only use authentication if challenged
+ URLConnection con = url.openConnection();
+ con.setRequestProperty("Authorization", "Basic " + new String(Base64.encode((username + ":" + password).getBytes())));
+ in = con.getInputStream();
+ } else {
+ in = url.openStream();
+ }
+ return in;
+ }
+
+ private void downloadConfigurationDeps(Artifact configID, String repoURL, String username, String password, DownloadResults results) throws IOException {
+ if(!repoURL.endsWith("/")) {
+ repoURL += "/";
+ }
+ try {
+ ConfigurationData data = null;
+ if(configStore.containsConfiguration(configID)) {
+ data = configStore.loadConfiguration(configID);
+ }
+ if(data == null) {
+ throw new IllegalStateException("No configuration store for repository "+writeableRepo);
+ }
+ Dependency[] dependencies = getDependencies(data);
+ // Download the dependencies
+ for (int i = 0; i < dependencies.length; i++) {
+ Dependency dep = dependencies[i];
+ Artifact artifact = dep.getArtifact();
+ //todo: check all repositories?
+ if(writeableRepo.contains(artifact)) {
+ results.addDependencyPresent(artifact);
+ continue;
+ }
+ String url = getURL(dep.toString(), repoURL);
+ //todo: use a file status monitor
+ writeableRepo.copyToRepository(openStream(new URL(url), username, password), artifact, null);
+ results.addDependencyInstalled(artifact);
+ downloadConfigurationDeps(artifact, repoURL, username, password, results);
+ }
+ } catch (NoSuchConfigException e) {
+ throw new IllegalStateException("Installed configuration into repository but ConfigStore does not see it: "+e.getMessage());
+ } catch (InvalidConfigException e) {
+ throw new IllegalStateException("Installed configuration into repository but ConfigStore cannot load it: "+e.getMessage());
+ }
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ static {
+ GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ConfigInstallerGBean.class);
+ infoFactory.addReference("ConfigManager", ConfigurationManager.class, "ConfigurationManager");
+ infoFactory.addReference("Repository", WriteableRepository.class, "GBean");
+ infoFactory.addReference("ConfigStore", ConfigurationStore.class, "ConfigurationStore");
+ infoFactory.addInterface(ConfigurationInstaller.class);
+
+ infoFactory.setConstructor(new String[]{"ConfigManager", "Repository", "ConfigStore"});
+
+ GBEAN_INFO = infoFactory.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+}
Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java?rev=394030&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java Thu Apr 13 23:30:38 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.system.configuration;
+
+import java.net.URL;
+import java.io.IOException;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ * Knows how to import and export configurations
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public interface ConfigurationInstaller {
+ /**
+ * Lists the configurations available for download in a particular Geronimo repository.
+ * @param mavenRepository The base URL to the maven repository
+ * @param username Optional username, if the maven repo uses HTTP Basic authentication.
+ * Set this to null if no authentication is required.
+ * @param password Optional password, if the maven repo uses HTTP Basic authentication.
+ * Set this to null if no authentication is required.
+ */
+ public ConfigurationMetadata[] listConfigurations(URL mavenRepository, String username, String password) throws IOException;
+
+ /**
+ * Populates the dependency information for a particular configuration descriptor.
+ * @param mavenRepository The base URL to the maven repository
+ * @param username Optional username, if the maven repo uses HTTP Basic authentication.
+ * Set this to null if no authentication is required.
+ * @param password Optional password, if the maven repo uses HTTP Basic authentication.
+ * Set this to null if no authentication is required.
+ * @param source The configuration descriptor that should have dependency
+ * information added (though if this is a remote call a different
+ * object will be returned).
+ */
+ public ConfigurationMetadata loadDependencies(URL mavenRepository, String username, String password, ConfigurationMetadata source) throws IOException;
+
+ /**
+ * Installs a configuration from a remote repository into the local Geronimo server,
+ * including all its dependencies.
+ * @param mavenRepository The base URL to the maven repository
+ * @param username Optional username, if the maven repo uses HTTP Basic authentication.
+ * Set this to null if no authentication is required.
+ * @param password Optional password, if the maven repo uses HTTP Basic authentication.
+ * Set this to null if no authentication is required.
+ * @param configId The identifier of the configuration to install.
+ */
+ public DownloadResults install(URL mavenRepository, String username, String password, Artifact configId) throws IOException;
+}
Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationMetadata.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationMetadata.java?rev=394030&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationMetadata.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationMetadata.java Thu Apr 13 23:30:38 2006
@@ -0,0 +1,111 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.system.configuration;
+
+import java.io.Serializable;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Dependency;
+
+/**
+ * Various metadata on a configuration that's used when listing, importing,
+ * and exporting configurations.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class ConfigurationMetadata implements Serializable, Comparable {
+ private Artifact configId;
+ private String description;
+ private String category;
+ private boolean installed;
+ private Dependency[] dependencies;
+ private boolean eligible;
+ private String[] geronimoVersions;
+ private String[] prerequisites;
+
+ public ConfigurationMetadata(Artifact configId, String description, String category, boolean installed, boolean eligible) {
+ this.configId = configId;
+ this.description = description;
+ this.category = category;
+ this.installed = installed;
+ this.eligible = eligible;
+ }
+
+ public void setDependencies(Dependency[] dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public Artifact getConfigId() {
+ return configId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public boolean isInstalled() {
+ return installed;
+ }
+
+ public String getVersion() {
+ String[] parts = configId.toString().split("/");
+ if(parts.length == 4) {
+ return parts[2];
+ }
+ return "unknown version";
+ }
+
+ /**
+ * Note: if null, this information has not yet been loaded from the repository
+ */
+ public Dependency[] getDependencies() {
+ return dependencies;
+ }
+
+ public String[] getGeronimoVersions() {
+ return geronimoVersions;
+ }
+
+ public void setGeronimoVersions(String[] geronimoVersions) {
+ this.geronimoVersions = geronimoVersions;
+ }
+
+ public String[] getPrerequisites() {
+ return prerequisites;
+ }
+
+ public void setPrerequisites(String[] prerequisites) {
+ this.prerequisites = prerequisites;
+ }
+
+ public boolean isEligible() {
+ return eligible;
+ }
+
+
+ public int compareTo(Object o) {
+ ConfigurationMetadata other = (ConfigurationMetadata) o;
+ int test = category.compareTo(other.category);
+ if(test != 0) return test;
+ test = description.compareTo(other.description);
+
+ return test;
+ }
+}
Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java?rev=394030&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java Thu Apr 13 23:30:38 2006
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.system.configuration;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ * Lists the results of a configuration download operation.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class DownloadResults implements Serializable {
+ private List dependenciesPresent = new ArrayList();
+ private List dependenciesInstalled = new ArrayList();
+
+ void addDependencyPresent(Artifact dep) {
+ dependenciesPresent.add(dep);
+ }
+
+ void addDependencyInstalled(Artifact dep) {
+ dependenciesInstalled.add(dep);
+ }
+
+ public Artifact[] getDependenciesPresent() {
+ return (Artifact[]) dependenciesPresent.toArray(new Artifact[dependenciesPresent.size()]);
+ }
+
+ public Artifact[] getDependenciesInstalled() {
+ return (Artifact[]) dependenciesInstalled.toArray(new Artifact[dependenciesInstalled.size()]);
+ }
+}
Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/DownloadResults.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Thu Apr 13 23:30:38 2006
@@ -20,6 +20,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
@@ -29,6 +30,7 @@
import java.util.SortedSet;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
import javax.management.ObjectName;
import org.apache.geronimo.gbean.AbstractName;
@@ -165,7 +167,7 @@
public URL resolve(Artifact configId, String moduleName, URI uri) throws NoSuchConfigException, MalformedURLException {
File location = repository.getLocation(configId);
if (location.isDirectory()) {
- File inPlaceLocation = null;
+ File inPlaceLocation = null;
try {
inPlaceLocation = InPlaceConfigurationUtil.readInPlaceLocation(location);
} catch (IOException e) {
@@ -174,10 +176,10 @@
location = inPlaceLocation;
}
- if (moduleName != null) {
+ if (moduleName != null) {
location = new File(location, moduleName);
}
-
+
if (location.isDirectory()) {
URL locationUrl = location.toURL();
URL resolvedUrl = new URL(locationUrl, uri.toString());
@@ -191,6 +193,48 @@
baseURL = new URL(baseURL, moduleName + "/");
}
return new URL(baseURL, uri.toString());
+ }
+ }
+
+ public void exportConfiguration(Artifact configId, OutputStream output) throws IOException, NoSuchConfigException {
+ File dir = repository.getLocation(configId);
+ if (dir == null) {
+ throw new NoSuchConfigException(configId);
+ }
+ if (!dir.exists() || !dir.canRead()) {
+ throw new IOException("Cannot read config store directory for " + configId + " (" + dir.getAbsolutePath() + ")");
+ }
+ ZipOutputStream out = new ZipOutputStream(output);
+ byte[] buf = new byte[10240];
+ writeToZip(dir, out, "", buf);
+ out.closeEntry();
+ out.finish();
+ out.flush();
+ }
+
+ private void writeToZip(File dir, ZipOutputStream out, String prefix, byte[] buf) throws IOException {
+ File[] all = dir.listFiles();
+ for (int i = 0; i < all.length; i++) {
+ File file = all[i];
+ if (file.isDirectory()) {
+ writeToZip(file, out, prefix + file.getName() + "/", buf);
+ } else {
+ ZipEntry entry = new ZipEntry(prefix + file.getName());
+ out.putNextEntry(entry);
+ writeToZipStream(file, out, buf);
+ }
+ }
+ }
+
+ private void writeToZipStream(File file, OutputStream out, byte[] buf) throws IOException {
+ FileInputStream in = new FileInputStream(file);
+ int count;
+ try {
+ while ((count = in.read(buf, 0, buf.length)) > -1) {
+ out.write(buf, 0, count);
+ }
+ } finally {
+ in.close();
}
}
Modified: geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=394030&r1=394029&r2=394030&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Thu Apr 13 23:30:38 2006
@@ -68,6 +68,7 @@
import org.apache.geronimo.kernel.config.EditableKernelConfigurationManager;
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.NullConfigurationStore;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
@@ -362,7 +363,7 @@
super.tearDown();
}
- public static class MockConfigStore implements ConfigurationStore {
+ public static class MockConfigStore extends NullConfigurationStore {
private Map configs = new HashMap();
URL baseURL;
@@ -396,22 +397,6 @@
public boolean containsConfiguration(Artifact configID) {
return true;
- }
-
- public String getObjectName() {
- return null;
- }
-
- public AbstractName getAbstractName() {
- return null;
- }
-
- public List listConfigurations() {
- return null;
- }
-
- public File createNewConfigurationDir(Artifact configId) {
- return null;
}
public URL resolve(Artifact configId, String moduleName, URI uri) throws NoSuchConfigException, MalformedURLException {