From: Mathieu Baudier Date: Sun, 16 Jan 2011 21:17:49 +0000 (+0000) Subject: Adapt Security to RCP X-Git-Tag: argeo-commons-2.1.30~1522 X-Git-Url: https://git.argeo.org/?a=commitdiff_plain;h=83dc7b38160651626d00f6048f20183e01ad323a;p=lgpl%2Fargeo-commons.git Adapt Security to RCP git-svn-id: https://svn.argeo.org/commons/trunk@4035 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/features/org.argeo.eclipse.dep.common/pom.xml b/eclipse/features/org.argeo.eclipse.dep.common/pom.xml index 2ef694097..7c0a8455a 100644 --- a/eclipse/features/org.argeo.eclipse.dep.common/pom.xml +++ b/eclipse/features/org.argeo.eclipse.dep.common/pom.xml @@ -24,22 +24,6 @@ org.eclipse.core org.eclipse.core.runtime - - org.eclipse.swt - org.eclipse.swt - - - org.eclipse.swt - org.eclipse.swt.gtk.linux.x86_64 - - - org.eclipse.swt - org.eclipse.swt.gtk.linux.x86 - - - org.eclipse.swt - org.eclipse.swt.win32.win32.x86 - org.eclipse.core org.eclipse.core.commands @@ -57,17 +41,15 @@ org.eclipse.equinox org.eclipse.equinox.launcher + + org.eclipse.equinox - org.eclipse.equinox.launcher.gtk.linux.x86_64 - - - org.eclipse.equinox - org.eclipse.equinox.launcher.gtk.linux.x86 + org.eclipse.equinox.security org.eclipse.equinox - org.eclipse.equinox.launcher.win32.win32.x86 + org.eclipse.equinox.security.ui diff --git a/eclipse/features/org.argeo.eclipse.dep.rcp/pom.xml b/eclipse/features/org.argeo.eclipse.dep.rcp/pom.xml index 571745e19..a6ef2d5b8 100644 --- a/eclipse/features/org.argeo.eclipse.dep.rcp/pom.xml +++ b/eclipse/features/org.argeo.eclipse.dep.rcp/pom.xml @@ -30,5 +30,33 @@ org.eclipse.ui org.eclipse.ui + + + + org.eclipse.swt + org.eclipse.swt + + + org.eclipse.swt + org.eclipse.swt.gtk.linux.x86_64 + + + org.eclipse.swt + org.eclipse.swt.win32.win32.x86 + + + + + + + + + + + + + + + diff --git a/eclipse/features/pom.xml b/eclipse/features/pom.xml index c01f98b8d..1b72355fa 100644 --- a/eclipse/features/pom.xml +++ b/eclipse/features/pom.xml @@ -45,24 +45,7 @@ org.apache.felix maven-bundle-plugin ${version.maven-bundle-plugin} - - META-INF - - ${project.artifactId} - ${project.version}-r${buildNumber} - - - - - bundle-manifest - process-resources - - manifest - - - - @@ -70,6 +53,13 @@ org.argeo.maven.plugins maven-argeo-osgi-plugin + + resolve-pde-sources + + pde-sources + + generate-resources + generate-descriptors @@ -77,12 +67,30 @@ generate-resources - + + check-osgi + test + + equinox + + + true + + -clean + + + + + + org.argeo.commons.osgi + org.argeo.osgi.boot + 0.2.2-SNAPSHOT + test + + \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.eclipse.ui/pom.xml b/eclipse/plugins/org.argeo.eclipse.ui/pom.xml index a40ed57c2..ee5398252 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/pom.xml +++ b/eclipse/plugins/org.argeo.eclipse.ui/pom.xml @@ -74,6 +74,10 @@ org.springframework org.springframework.context + + org.springframework.osgi + org.springframework.osgi.extender + diff --git a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/AbstractSpringUiPlugin.java b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/AbstractSpringUiPlugin.java deleted file mode 100644 index 5c31d6137..000000000 --- a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/AbstractSpringUiPlugin.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2010 Mathieu Baudier - * - * 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.argeo.eclipse.spring; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; -import org.springframework.context.ApplicationContext; - -public abstract class AbstractSpringUiPlugin extends AbstractUIPlugin { - private BundleContext bundleContext; - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - this.bundleContext = context; - } - - @Override - public void stop(BundleContext context) throws Exception { - super.stop(context); - } - - public ApplicationContext getApplicationContext() { - return ApplicationContextTracker.getApplicationContext(bundleContext - .getBundle()); - } -} diff --git a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java index e29d5a056..805d11d8a 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java +++ b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/ApplicationContextTracker.java @@ -20,7 +20,6 @@ import static java.text.MessageFormat.format; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.eclipse.ui.ArgeoUiPlugin; import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -54,8 +53,8 @@ class ApplicationContextTracker { */ public ApplicationContextTracker(final Bundle contributorBundle, final BundleContext factoryBundleContext) { - final String filter = format(FILTER, contributorBundle - .getSymbolicName()); + final String filter = format(FILTER, + contributorBundle.getSymbolicName()); try { applicationContextServiceTracker = new ServiceTracker( factoryBundleContext, FrameworkUtil.createFilter(filter), @@ -98,9 +97,7 @@ class ApplicationContextTracker { static ApplicationContext getApplicationContext(Bundle contributorBundle) { if (log.isTraceEnabled()) - log - .trace("Get application context for bundle " - + contributorBundle); + log.trace("Get application context for bundle " + contributorBundle); if (contributorBundle.getState() != Bundle.ACTIVE && contributorBundle.getState() != Bundle.STARTING) { @@ -114,8 +111,7 @@ class ApplicationContextTracker { } final ApplicationContextTracker applicationContextTracker = new ApplicationContextTracker( - contributorBundle, ArgeoUiPlugin.getDefault() - .getBundleContext()); + contributorBundle, contributorBundle.getBundleContext()); ApplicationContext applicationContext = null; try { applicationContext = applicationContextTracker diff --git a/osgi/runtime/org.argeo.osgi.boot/pom.xml b/osgi/runtime/org.argeo.osgi.boot/pom.xml index 9e9f30c62..e5d29a912 100644 --- a/osgi/runtime/org.argeo.osgi.boot/pom.xml +++ b/osgi/runtime/org.argeo.osgi.boot/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.argeo.commons.osgi @@ -38,6 +39,7 @@ org.argeo.osgi.boot.Activator + J2SE-1.4 diff --git a/pom.xml b/pom.xml index 5f6feca0c..7344fc97a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.argeo @@ -82,6 +83,7 @@ limitations under the License. org.apache.maven.plugins maven-compiler-plugin + 2.3.2 1.5 1.5 @@ -90,6 +92,7 @@ limitations under the License. org.apache.maven.plugins maven-source-plugin + 2.1.2 attach-sources @@ -107,6 +110,7 @@ limitations under the License. maven-jar-plugin + 2.3.1 target/classes/META-INF/MANIFEST.MF @@ -123,6 +127,7 @@ limitations under the License. ${project.version}-r${buildNumber} ${pom.artifactId} + J2SE-1.5 <_removeheaders>Bnd-LastModified @@ -167,6 +172,7 @@ limitations under the License. org.apache.maven.plugins maven-resources-plugin + 2.4.3 UTF-8 @@ -249,6 +255,7 @@ limitations under the License. org.apache.maven.plugins maven-project-info-reports-plugin + 2.3.1 @@ -271,6 +278,7 @@ limitations under the License. org.apache.maven.plugins maven-javadoc-plugin + 2.7 false true @@ -280,6 +288,7 @@ limitations under the License. org.apache.maven.plugins maven-jxr-plugin + 2.2 true @@ -287,6 +296,7 @@ limitations under the License. org.apache.maven.plugins maven-surefire-report-plugin + 2.7.1 false true @@ -295,6 +305,7 @@ limitations under the License. org.codehaus.mojo taglist-maven-plugin + 2.4 true @@ -307,6 +318,7 @@ limitations under the License. org.apache.maven.plugins maven-changelog-plugin + 2.2 false diff --git a/security/eclipse/plugins/org.argeo.security.equinox/.classpath b/security/eclipse/plugins/org.argeo.security.equinox/.classpath new file mode 100644 index 000000000..92f19d2ff --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.equinox/.project b/security/eclipse/plugins/org.argeo.security.equinox/.project new file mode 100644 index 000000000..e4dd594e8 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/.project @@ -0,0 +1,28 @@ + + + org.argeo.security.equinox + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/security/eclipse/plugins/org.argeo.security.equinox/.settings/org.eclipse.jdt.core.prefs b/security/eclipse/plugins/org.argeo.security.equinox/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62fa6bd36 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Sun Jan 16 11:20:02 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/security/eclipse/plugins/org.argeo.security.equinox/.settings/org.eclipse.pde.core.prefs b/security/eclipse/plugins/org.argeo.security.equinox/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..87ab38102 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Sun Jan 16 11:19:07 CET 2011 +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/security/eclipse/plugins/org.argeo.security.equinox/META-INF/spring/loginModules.xml b/security/eclipse/plugins/org.argeo.security.equinox/META-INF/spring/loginModules.xml new file mode 100644 index 000000000..f454d7a3a --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/META-INF/spring/loginModules.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.equinox/META-INF/spring/osgi.xml b/security/eclipse/plugins/org.argeo.security.equinox/META-INF/spring/osgi.xml new file mode 100644 index 000000000..8003fb277 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/META-INF/spring/osgi.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/security/eclipse/plugins/org.argeo.security.equinox/build.properties b/security/eclipse/plugins/org.argeo.security.equinox/build.properties new file mode 100644 index 000000000..87a7fc250 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/build.properties @@ -0,0 +1,5 @@ +bin.includes = META-INF/,\ + jaas/,\ + plugin.xml +source.. = src/main/java/ +output.. = target/classes/ diff --git a/security/eclipse/plugins/org.argeo.security.equinox/jaas/jaas_default.txt b/security/eclipse/plugins/org.argeo.security.equinox/jaas/jaas_default.txt new file mode 100644 index 000000000..b6cbaa655 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/jaas/jaas_default.txt @@ -0,0 +1,14 @@ +UNIX { + org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient + extensionId="org.argeo.security.equinox.unixLoginModule"; +}; + +SPRING { + org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient + extensionId="org.argeo.security.equinox.springLoginModule"; +}; + +SPRING_SECURITY_CONTEXT { + org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient + extensionId="org.argeo.security.equinox.springSecurityContextLoginModule"; +}; \ No newline at end of file diff --git a/security/eclipse/plugins/org.argeo.security.equinox/plugin.xml b/security/eclipse/plugins/org.argeo.security.equinox/plugin.xml new file mode 100644 index 000000000..b407360ac --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/plugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + name="Spring Login Module" + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.equinox/pom.xml b/security/eclipse/plugins/org.argeo.security.equinox/pom.xml new file mode 100644 index 000000000..1c0014844 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/pom.xml @@ -0,0 +1,76 @@ + + 4.0.0 + + org.argeo.commons.security + 0.2.2-SNAPSHOT + plugins + .. + + org.argeo.security.equinox + Commons Security Equinox + jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.felix + maven-bundle-plugin + ${version.maven-bundle-plugin} + + + lazy + org.argeo.security.equinox.EquinoxSecurity + *, + org.springframework.core, + org.argeo.eclipse.spring + + + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.equinox + org.eclipse.equinox.security + + + + + org.argeo.commons.basic + org.argeo.basic.nodeps + 0.2.2-SNAPSHOT + + + + + org.springframework.security + org.springframework.security.core + + + + + org.slf4j + com.springsource.slf4j.org.apache.commons.logging + + + + diff --git a/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/CurrentUser.java b/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/CurrentUser.java new file mode 100644 index 000000000..d89ddee5a --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/CurrentUser.java @@ -0,0 +1,64 @@ +package org.argeo.security.equinox; + +import java.security.Principal; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.security.auth.Subject; + +import org.eclipse.equinox.security.auth.ILoginContext; +import org.eclipse.equinox.security.auth.LoginContextFactory; +import org.springframework.security.Authentication; +import org.springframework.security.GrantedAuthority; + +public class CurrentUser { + public final static String getUsername() { + Subject subject = getSubject(); + if (subject == null) + return null; + Principal principal = subject.getPrincipals().iterator().next(); + return principal.getName(); + + } + + public final static Set roles() { + Principal principal = getSubject().getPrincipals().iterator().next(); + Authentication authentication = (Authentication) principal; + Set roles = Collections.synchronizedSet(new HashSet()); + for (GrantedAuthority ga : authentication.getAuthorities()) { + roles.add(ga.getAuthority()); + } + return Collections.unmodifiableSet(roles); + } + + private final static ILoginContext getLoginContext() { + return EquinoxSecurity.getLoginContext(); +// return LoginContextFactory +// .createContext(EquinoxSecurity.CONTEXT_SPRING); + } + + // private static void login() { + // try { + // getLoginContext().login(); + // } catch (LoginException e) { + // throw new RuntimeException("Cannot login", e); + // } + // } + + public final static Subject getSubject() { + + Subject subject = null; + // subject = Subject.getSubject(AccessController.getContext()); + try { + getLoginContext().login(); + subject = getLoginContext().getSubject(); + } catch (Exception e) { + throw new RuntimeException("Cannot retrieve subject", e); + } + + return subject; + + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/EquinoxSecurity.java b/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/EquinoxSecurity.java new file mode 100644 index 000000000..e1a72b14f --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/EquinoxSecurity.java @@ -0,0 +1,38 @@ +package org.argeo.security.equinox; + +import java.net.URL; + +import org.eclipse.equinox.security.auth.ILoginContext; +import org.eclipse.equinox.security.auth.LoginContextFactory; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class EquinoxSecurity implements BundleActivator { + public final static String CONTEXT_SPRING = "SPRING"; + private static final String JAAS_CONFIG_FILE = "jaas/jaas_default.txt"; + + private static BundleContext bundleContext; + + public void start(BundleContext context) throws Exception { + bundleContext = context; + // URL url = new URL( + // "file:////home/mbaudier/dev/src/commons/security/eclipse/plugins/org.argeo.security.ui.rcp/jaas_config.txt"); + // // URL url = new URL( + // // + // "file:////home/mbaudier/dev/src/commons/security/eclipse/plugins/org.argeo.security.ui.rcp/jaas_config.txt"); + // ILoginContext secureContext = LoginContextFactory.createContext( + // configName, url); + getLoginContext(); + } + + public void stop(BundleContext context) throws Exception { + bundleContext = null; + } + + static ILoginContext getLoginContext() { + String configName = CONTEXT_SPRING; + URL configUrl = bundleContext.getBundle().getEntry(JAAS_CONFIG_FILE); + return LoginContextFactory.createContext(configName, configUrl); + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/SpringLoginModule.java b/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/SpringLoginModule.java new file mode 100644 index 000000000..4f8641c26 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/SpringLoginModule.java @@ -0,0 +1,113 @@ +package org.argeo.security.equinox; + +import java.util.Map; + +import javax.security.auth.Subject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.TextOutputCallback; +import javax.security.auth.login.LoginException; + +import org.springframework.security.Authentication; +import org.springframework.security.AuthenticationException; +import org.springframework.security.AuthenticationManager; +import org.springframework.security.BadCredentialsException; +import org.springframework.security.context.SecurityContextHolder; +import org.springframework.security.providers.UsernamePasswordAuthenticationToken; +import org.springframework.security.providers.jaas.SecurityContextLoginModule; + +public class SpringLoginModule extends SecurityContextLoginModule { + private AuthenticationManager authenticationManager; + private Subject subject; + + private CallbackHandler callbackHandler; + + public SpringLoginModule() { + + } + + @SuppressWarnings("rawtypes") + public void initialize(Subject subject, CallbackHandler callbackHandler, + Map sharedState, Map options) { + super.initialize(subject, callbackHandler, sharedState, options); + this.subject = subject; + this.callbackHandler = callbackHandler; + } + + public boolean login() throws LoginException { + // thread already logged in + if (SecurityContextHolder.getContext().getAuthentication() != null) + return super.login(); + + if (subject.getPrincipals(Authentication.class).size() == 1) { + registerAuthentication(subject.getPrincipals(Authentication.class) + .iterator().next()); + return super.login(); + } else if (subject.getPrincipals(Authentication.class).size() > 1) { + throw new LoginException( + "Multiple Authentication principals not supported: " + + subject.getPrincipals(Authentication.class)); + } else { + // ask for username and password + Callback label = new TextOutputCallback( + TextOutputCallback.INFORMATION, "Required login"); + NameCallback nameCallback = new NameCallback("User"); + PasswordCallback passwordCallback = new PasswordCallback( + "Password", false); + + if (callbackHandler == null) { + // throw new LoginException("No call back handler available"); + return false; + } + try { + callbackHandler.handle(new Callback[] { label, nameCallback, + passwordCallback }); + } catch (Exception e) { + LoginException le = new LoginException( + "Callback handling failed"); + le.initCause(e); + throw le; + } + + // Set user name and password + String username = nameCallback.getName(); + String password = ""; + if (passwordCallback.getPassword() != null) { + password = String.valueOf(passwordCallback.getPassword()); + } + UsernamePasswordAuthenticationToken credentials = new UsernamePasswordAuthenticationToken( + username, password); + + try { + Authentication authentication = authenticationManager + .authenticate(credentials); + registerAuthentication(authentication); + return super.login(); + } catch (Exception e) { + LoginException loginException = new LoginException( + "Bad credentials"); + loginException.initCause(e); + throw loginException; + } + } + } + + /** + * Register an {@link Authentication} in the security context. + * + * @param authentication + * has to implement {@link Authentication}. + */ + protected void registerAuthentication(Object authentication) { + SecurityContextHolder.getContext().setAuthentication( + (Authentication) authentication); + } + + public void setAuthenticationManager( + AuthenticationManager authenticationManager) { + this.authenticationManager = authenticationManager; + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui.rap/org.argeo.security.ui.rap-maven.target b/security/eclipse/plugins/org.argeo.security.ui.rap/org.argeo.security.ui.rap-maven.target new file mode 100644 index 000000000..9b9a29794 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rap/org.argeo.security.ui.rap-maven.target @@ -0,0 +1,420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rap/pom.xml b/security/eclipse/plugins/org.argeo.security.ui.rap/pom.xml new file mode 100644 index 000000000..1cbb1a457 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rap/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + + org.argeo.commons.security + 0.2.2-SNAPSHOT + plugins + .. + + org.argeo.security.ui.rap + Commons Security UI RAP + jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.argeo.maven.plugins + maven-argeo-osgi-plugin + + + resolve-pde-sources + + pde-sources + + generate-resources + + + generate-descriptors + + descriptors + + generate-resources + + + check-osgi + test + + equinox + + + true + + -clean + + + + + + + + + + org.argeo.commons.security + org.argeo.security.ui.rcp + 0.2.2-SNAPSHOT + pom + + + org.argeo.commons.eclipse + org.argeo.eclipse.dep.rcp + + + + + + org.argeo.commons.eclipse + org.argeo.eclipse.dep.rap + 0.2.2-SNAPSHOT + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/.classpath b/security/eclipse/plugins/org.argeo.security.ui.rcp/.classpath new file mode 100644 index 000000000..92f19d2ff --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/.project b/security/eclipse/plugins/org.argeo.security.ui.rcp/.project new file mode 100644 index 000000000..feeafcf5b --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/.project @@ -0,0 +1,28 @@ + + + org.argeo.security.ui.rcp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/.settings/org.eclipse.jdt.core.prefs b/security/eclipse/plugins/org.argeo.security.ui.rcp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..1f382cb9d --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Sat Jan 15 17:51:30 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/SecureRCP.product b/security/eclipse/plugins/org.argeo.security.ui.rcp/SecureRCP.product new file mode 100644 index 000000000..f64b05182 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/SecureRCP.product @@ -0,0 +1,122 @@ + + + + + + + + + + -console -clean + -Dlog4j.configuration=file:/home/mbaudier/dev/src/commons/security/eclipse/plugins/org.argeo.security.ui.rcp/log4j.properties + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/argeo_security_rap.properties b/security/eclipse/plugins/org.argeo.security.ui.rcp/argeo_security_rap.properties new file mode 100644 index 000000000..355774942 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/argeo_security_rap.properties @@ -0,0 +1,24 @@ +argeo.osgi.start=\ +com.springsource.javax.servlet,\ +org.eclipse.core.runtime,\ +org.eclipse.equinox.common,\ +org.eclipse.equinox.http.jetty,\ +org.eclipse.equinox.http.registry,\ +org.eclipse.equinox.launcher,\ +org.eclipse.rap.demo,\ +org.mortbay.jetty.server,\ +org.springframework.osgi.extender,\ +org.argeo.server.ads.server,\ +org.argeo.security.manager.ldap,\ +org.argeo.security.services,\ +org.argeo.security.equinox,\ +org.argeo.security.ui,\ +org.argeo.security.ui.rcp,\ + +eclipse.ignoreApp=true +osgi.noShutdown=true + +log4j.configuration=file:../../log4j.properties + +org.eclipse.equinox.http.jetty.log.stderr.threshold=debug +org.osgi.service.http.port=9090 diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/build.properties b/security/eclipse/plugins/org.argeo.security.ui.rcp/build.properties new file mode 100644 index 000000000..ac478ab24 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/build.properties @@ -0,0 +1,7 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + log4j.properties,\ + jaas_config.txt diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_about.gif b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_about.gif new file mode 100644 index 000000000..20d9ad2d9 Binary files /dev/null and b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_about.gif differ diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.icns b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.icns new file mode 100644 index 000000000..b77a6a639 Binary files /dev/null and b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.icns differ diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.ico b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.ico new file mode 100644 index 000000000..d548f7109 Binary files /dev/null and b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.ico differ diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.xpm b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.xpm new file mode 100644 index 000000000..b0c139e06 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_launcher.xpm @@ -0,0 +1,307 @@ +/* XPM */ +static char * icon48_xpm[] = { +"48 48 256 2", +" c #4B4B3B3B9090", +". c #0D0D0E0E5454", +"X c #11110E0E5B5B", +"o c #17170F0F6363", +"O c #1D1D13136969", +"+ c #212114146C6C", +"@ c #252514147171", +"# c #282811116C6C", +"$ c #26260D0D6363", +"% c #22220B0B5E5E", +"& c #1C1C0B0B5A5A", +"* c #1C1C0B0B5252", +"= c #1B1B05055353", +"- c #161606064D4D", +"; c #161605054949", +": c #111104044848", +"> c #131304044545", +", c #131305054242", +"< c #141410105E5E", +"1 c #2C2C15157373", +"2 c #2B2B1B1B7575", +"3 c #343416167272", +"4 c #313113136E6E", +"5 c #222209095757", +"6 c #1B1B06064D4D", +"7 c #15150B0B4242", +"8 c #13130C0C5555", +"9 c #2E2E1B1B7878", +"0 c #33331F1F7C7C", +"q c #343418187878", +"w c #3B3B1C1C7575", +"e c #2E2E10106767", +"r c #1B1B07074747", +"t c #18180B0B4646", +"y c #151513136262", +"u c #1A1A15156464", +"i c #34341F1F7777", +"p c #40401E1E8080", +"a c #42421B1B7A7A", +"s c #3B3B15157474", +"d c #2B2B0B0B5B5B", +"f c #222207075252", +"g c #373727277A7A", +"h c #474724248484", +"j c #393915156E6E", +"k c #373711116A6A", +"l c #343413136363", +"z c #232319196E6E", +"x c #292919197070", +"c c #3C3C2C2C8282", +"v c #444431318585", +"b c #494934348A8A", +"n c #505026268A8A", +"m c #3D3D1B1B6E6E", +"M c #31310E0E5C5C", +"N c #2B2B0D0D5353", +"B c #222207074A4A", +"V c #52523C3C9292", +"C c #58583C3C9494", +"Z c #5D5D44449797", +"A c #5C5C2E2E9292", +"S c #676733339595", +"D c #424228287575", +"F c #29290A0A4F4F", +"G c #6C6C4A4A9E9E", +"H c #72725454A7A7", +"J c #8C8C6D6DB2B2", +"K c #343424246E6E", +"L c #3A3A23236A6A", +"P c #3A3A1C1C6767", +"I c #24240A0A4B4B", +"U c #151518186161", +"Y c #76766F6FA5A5", +"T c #ADAD9191CCCC", +"R c #98988989D3D3", +"E c #45453B3B8686", +"W c #3C3C35357979", +"Q c #363631317575", +"! c #32322D2D6B6B", +"~ c #323229296363", +"^ c #30301F1F6262", +"/ c #323218185E5E", +"( c #272707074B4B", +") c #202028286C6C", +"_ c #1E1E1D1D6868", +"` c #9A9A8282BBBB", +"' c #C8C8B3B3D3D3", +"] c #B3B3AFAFE7E7", +"[ c #84847272C6C6", +"{ c #58585757A3A3", +"} c #3F3F3C3C8A8A", +"| c #3B3B3A3A8484", +" . c #414139397D7D", +".. c #3D3D39397A7A", +"X. c #37372E2E6E6E", +"o. c #2C2C21215A5A", +"O. c #2E2E1B1B5B5B", +"+. c #F5F5EFEFF5F5", +"@. c #656566669A9A", +"#. c #47474B4B8E8E", +"$. c #3C3C44447B7B", +"%. c #444442428080", +"&. c #45453E3E8181", +"*. c #40403C3C8181", +"=. c #3D3D33337474", +"-. c #3B3B30306E6E", +";. c #38382D2D6969", +":. c #303026265D5D", +">. c #2C2C15155A5A", +",. c #1F1F1C1C7070", +"<. c #25251E1E7171", +"1. c #59595C5C9191", +"2. c #4D4D53538989", +"3. c #4C4C49498484", +"4. c #484845458585", +"5. c #494941418585", +"6. c #494940408181", +"7. c #2F2F1C1C5353", +"8. c #2B2B28287676", +"9. c #323231317F7F", +"0. c #545452528B8B", +"q. c #51514E4E8989", +"w. c #4E4E4B4B8C8C", +"e. c #4C4C47478686", +"r. c #46463D3D7E7E", +"t. c #434336367A7A", +"y. c #2B2B13135555", +"u. c #47473D3D8D8D", +"i. c #575757578E8E", +"p. c #48483E3E7F7F", +"a. c #46463A3A7D7D", +"s. c #424235357575", +"d. c #404034347171", +"f. c #BFBFCBCBFAFA", +"g. c #B8B8A8A8DDDD", +"h. c #5E5E60609292", +"j. c #565655558C8C", +"k. c #4B4B44448282", +"l. c #454539397B7B", +"z. c #434338387878", +"x. c #3F3F32326D6D", +"c. c #3D3D30306969", +"v. c #3A3A2E2E6363", +"b. c #36362A2A5C5C", +"n. c #343424245555", +"m. c #30301E1E4D4D", +"M. c #49493C3C8282", +"N. c #5E5E4F4F8C8C", +"B. c #56563B3B8B8B", +"V. c #545407078585", +"C. c #424234347272", +"Z. c #9797A4A4F7F7", +"A. c #444436367676", +"S. c #7D7D7979D5D5", +"D. c #464640408A8A", +"F. c #44444B4B8282", +"G. c #414107077777", +"H. c #71716161C1C1", +"J. c #303039397979", +"K. c #8E8E8E8EE6E6", +"L. c #404033338B8B", +"P. c #4A4A45458C8C", +"I. c #46463A3A8080", +"U. c #363629295454", +"Y. c #303022224848", +"T. c #424237377575", +"R. c #2E2E1D1D6363", +"E. c #79798383EAEA", +"W. c #74747B7BE4E4", +"Q. c #6D6D7676D6D6", +"!. c #6A6A7171CECE", +"~. c #66666969C6C6", +"^. c #62626565BCBC", +"/. c #5F5F6060B5B5", +"(. c #5B5B5B5BACAC", +"). c #535353539898", +"_. c #4F4F4F4FA4A4", +"`. c #54544D4DA4A4", +"'. c #323204046B6B", +"]. c #303035357979", +"[. c #313122224343", +"{. c #5A5A5B5BB7B7", +"}. c #484846468080", +"|. c #454541417575", +" X c #4B4B31318282", +".X c #47473C3C8484", +"XX c #3E3E35356E6E", +"oX c #2F2F26264040", +"OX c #2B2B23233A3A", +"+X c #262619195C5C", +"@X c #252515155A5A", +"#X c #55555151B3B3", +"$X c #3C3C2D2D5D5D", +"%X c #39392F2F5656", +"&X c #37372D2D5050", +"*X c #25251F1F3030", +"=X c #24241D1D4343", +"-X c #202013135656", +";X c #41413B3B6C6C", +":X c #444442429696", +">X c #212100005E5E", +",X c #444436367272", +" > , , , ", +" . . X X < < o o O O + @ 1 2 2 1 1 1 1 1 1 1 1 3 4 # # $ $ $ % % % 5 = = 6 6 - ; ; > > , , 7 ", +" . 8 < < < o O O + @ @ 2 9 9 0 0 q q q q q q q w 3 4 4 e e $ $ $ $ % 5 = = 6 6 6 ; ; > > r t ", +" . X < y u O O + @ 1 2 i 0 0 p p p p p p p a a p a s 3 4 4 e e e e d 5 5 f f 6 6 6 ; ; r r t ", +" X < y u O + + @ 2 9 0 g p p h h h h h h h p h h a a s s j k k j l d d 5 5 f f 6 6 r r r r r ", +" X < y O z x x 9 0 g c v b n n n n n n n n n n n h a a s s j j m l M d d N f f B B B B r r r ", +" < y u + z 2 0 c c b V C Z C C A A A A A S S S n h D w w m m m m k l M d d N f F F F B r r r ", +" < y O z z 9 c b V Z G H H H G S G G J J H V v c g g K K K K L P l l l M M N N N N I B B r r ", +" U u + z x i v C H Y J J J J H J T R H V E W W Q Q Q Q ! ! ! ~ ^ ^ / / M M M M M N ( B B r r ", +" ) _ z x 9 g b Z Y ` ' ' ' T T ] [ { } | .........W W Q Q X.! ~ ~ o.O./ / / / N F ( B B B r ", +" ) ) z x i c V G J ' +.+.+.+.] [ @.#.$.%.%.%.&.*. . .....W =.-.X.;.~ :.o.O.^ >.N F ( B B B B ", +" ) ,.<.2 g v C H J ' +.+.+.+.T Y 1.2.3.4.4.4.5.6.&.&. . ...W =.=.-.;.~ :.o.7.>.N F F ( B I I ", +" ) ,.<.8.9.b C H J T +.+.+.' J @.1.0.q.q.w.e.4.5.6.&.r. . .t.W =.=.-.;.~ :.o.7.y.N F ( ( I I ", +" 8.8.8.9.| u.C G J T +.+.' ` Y @.1.i.0.q.q.e.e.5.6.p.r.a. .t.t.s.d.d.-.;.~ :.7.7.y.F F ( I I ", +" 9.c c c v b A S H ' f.g.` Y @.h.1.i.j.0.q.q.e.k.6.p.r.a.l.t.z.s.s.d.x.c.v.b.n.m.7.N F F F I ", +" <.g M.N.B.B.n V.J f.R J @.h.h.1.i.i.j.j.0.q.3.k.6.p.r.a.l.l.z.s.C.d.x.x.c.v.b.n.m.y.N F F F ", +" + x i v B.Z Z G g.Z.[ @.2.i.i.j.j.j.j.j.0.q.3.k.6.p.p.a.l.l.A.s.C.C.d.x.c.v.b.n.m.7.y.N N y. ", +" O # 3 w p n Z ` f.S.H D.F.q.0.0.0.0.j.0.q.q.3.k.6.p.r.a.a.l.A.s.s.C.d.x.x.c.v.b.n.m.y.y.y.y. ", +" O # 4 s a G.V.T Z.H.V J.%.e.w.q.0.0.0.0.q.q.e.k.6.p.r.a.a.l.z.A.s.C.d.d.x.c.v.b.n.m.7.>.y.y. ", +" O # 4 s w G.A f.K.H L...4.P.w.w.w.q.q.q.q.e.e.5.6.M.I.I.a.a.l.z.A.s.d.d.x.c.v.v.U.Y.7.O.>.y. ", +" $ # 4 3 s G.G f.S.Z 9.*.D.P.P.w.w.w.w.w.e.e.5.5.M.M.I.I.a.a.l.z.T.s.d.d.x.x.c.v.U.Y.m.R.>.>. ", +" E.E.W.W.W.W.E.Z.E.W.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.!.!.!.!.!.~.~.~.~.~.~.^.^.^.^.^./././.(.{ { )._.`._. ", +" + # 3 w s '.` f.H.V ].*.D.P.P.P.P.P.P.P.5.5.5.M.M.M.I.I.a.l.z.z.T.T.s.d.d.x.c.v.U.Y.[.^ O.>. ", +" ~.~.~.~.~.~.K.Z.S.~.{.^.^.^.^.^.^.^.^././././././.(.(.(.(.(.(.{ { { { { ).).).w.w.}.|.P.u.} ", +" .I.6. X X XT f.H.b ].*.E D.D.D.D.5.5..X.XM.M.I.I.a.a.l.l.z.z.T.T.T.d.XXx.c.v.b.U.oXOXR.+X@X ", +" E.E.E.W.W.W.K.Z.E.W.Q.Q.Q.Q.Q.Q.Q.Q.!.!.!.!.!.!.~.~.~.~.~.~.^.^.^.^.^./././.(.{ { ).).#X_._. ", +" & % $ e '.= H f.H.b 8.W *.E E E .X.X.XI.I.I.I.a.a.l.l.z.z.T.T.T.C.XXXXc.v.$X%X&XY.*X=X2 @X-X ", +" {.{.{.{.{.#X~.Z.W.~.{.{./././././././././.(.(.(.(.(.(.(.{ { { { { { ).).).w.w.3.}.;X%.:X} } ", +" & & % $ e >XV.f.S.C K X.W t. . .l.l.t.t.t.t.A.A.A.,X,X,X,X,XX7X` Z.Z D ! =.=.s.t.t.t.A.A.s.A.,X,X,X,X > > t t t cX ", +" nXbXbXzXzXlXaXXXY +Xf = f = 7XtXR R mXn.Y.[.[.[.[.OX*X*X8X5X*X=X,.u vXvX; > > MXMX, 7 t t ", +" nXnXnXbXzXvX-.Y +XcX6 6 = = = d L B.G H `.X.:.7.m.=X=X=X=X=X6X,.u cXvXNX: BX> MXVXCXVX7 7 7 ", +" ZXZXnXbXAXgX@.+XvX; - - - - * @XR.>.sX>.R.i 0 x eXeXeXeXO hXaXcXvXNX: BXMXMXMXVXCXCXCXVX7 7 ", +" SXZXZXAXgXN.aXNX: : NXNXNX- * +X+X* 6 6 6 * * * * * * * vXvX- NX: DXBXMXMXFXCXCXCXCXGXVXVX7 ", +" SXSXHXgX0.JXKXLXKXKXDX: : NX* @X-X- - - - - - - - - - - NX: DXDXDXMXMXFXFXCXCXCXCXGXGXGXVXVX ", +" SXHXPX3.JXnXnXnXnXbXLXKXKXNXaX-XvX: : NX: : : : : : : BXDXDXLXMXMXFXFXCXCXCXCXGXGXGXGXGXGXGX ", +" IXUX$.AXZXZXZXZXnXnXnXLXLXNXJXvXBXDXBXBXBXBXDXDXDXDXLXDXLXLXFXFXFXFXCXCXCXCXGXGXGXGXGXGXGXGX ", +" "}; diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_window_16.gif b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_window_16.gif new file mode 100644 index 000000000..05626b17d Binary files /dev/null and b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_window_16.gif differ diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_window_32.gif b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_window_32.gif new file mode 100644 index 000000000..b432f8833 Binary files /dev/null and b/security/eclipse/plugins/org.argeo.security.ui.rcp/icons/alt_window_32.gif differ diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/log4j.properties b/security/eclipse/plugins/org.argeo.security.ui.rcp/log4j.properties new file mode 100644 index 000000000..8a89a4aa3 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/log4j.properties @@ -0,0 +1,24 @@ +log4j.rootLogger=WARN, console + +## Levels +log4j.logger.org.argeo=DEBUG +log4j.logger.org.springframework.security=DEBUG + +log4j.logger.org.apache.catalina=INFO +log4j.logger.org.apache.coyote=INFO +log4j.logger.org.apache.tomcat=INFO + +log4j.logger.org.apache.directory.server=INFO +log4j.logger.org.apache.directory.server.core.partition=ERROR +log4j.logger.org.apache.directory.server.core.schema.bootstrap.BootstrapAttributeTypeRegistry=ERROR + +log4j.logger.org.apache.jackrabbit=WARN +log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR + +## Appenders +# console is set to be a ConsoleAppender. +log4j.appender.console=org.apache.log4j.ConsoleAppender + +# console uses PatternLayout. +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/plugin.xml b/security/eclipse/plugins/org.argeo.security.ui.rcp/plugin.xml new file mode 100644 index 000000000..b1829e6f0 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/plugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/pom.xml b/security/eclipse/plugins/org.argeo.security.ui.rcp/pom.xml new file mode 100644 index 000000000..f711c69ab --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/pom.xml @@ -0,0 +1,159 @@ + + 4.0.0 + + org.argeo.commons.security + 0.2.2-SNAPSHOT + plugins + .. + + org.argeo.security.ui.rcp + Commons Security UI RCP + jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.felix + maven-bundle-plugin + ${version.maven-bundle-plugin} + + + lazy + org.eclipse.ui;resolution:=optional,org.eclipse.rap.ui;resolution:=optional,org.eclipse.core.runtime + * + + + + + org.argeo.maven.plugins + maven-argeo-osgi-plugin + + + resolve-pde-sources + + pde-sources + + generate-resources + + + generate-descriptors + + descriptors + + generate-resources + + + check-osgi + test + + equinox + + + true + + -clean + + + + + + + + + + + org.argeo.commons.security + org.argeo.security.equinox + 0.2.2-SNAPSHOT + + + org.argeo.commons.security + org.argeo.security.ui + 0.2.2-SNAPSHOT + + + org.argeo.commons.server + org.argeo.server.dep.ads + 0.2.2-SNAPSHOT + pom + + + org.argeo.commons.server + org.argeo.server.ads.server + 0.2.2-SNAPSHOT + + + org.argeo.commons.security + org.argeo.security.services + 0.2.2-SNAPSHOT + + + org.argeo.commons.security + org.argeo.security.manager.ldap + 0.2.2-SNAPSHOT + + + org.argeo.commons.server + org.argeo.server.ads + 0.2.2-SNAPSHOT + + + org.argeo.dep.osgi + org.argeo.dep.osgi.springframework.ldap + + + + + org.argeo.commons.eclipse + org.argeo.eclipse.dep.rcp + 0.2.2-SNAPSHOT + + + + + org.argeo.commons.server + org.argeo.server.json + 0.2.2-SNAPSHOT + + + + + org.eclipse.ui + org.eclipse.ui + provided + + + + + org.argeo.commons.basic + org.argeo.basic.nodeps + 0.2.2-SNAPSHOT + + + + + + org.slf4j + com.springsource.slf4j.org.apache.commons.logging + + + + org.argeo.commons.basic + org.argeo.basic.dep.log4j + 0.2.2-SNAPSHOT + pom + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/RapSecureWorkbenchWindowAdvisor.java b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/RapSecureWorkbenchWindowAdvisor.java new file mode 100644 index 000000000..616858a02 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/RapSecureWorkbenchWindowAdvisor.java @@ -0,0 +1,31 @@ +package org.argeo.security.ui.rcp; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; + +public class RapSecureWorkbenchWindowAdvisor extends + SecureWorkbenchWindowAdvisor { + + public RapSecureWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); +// configurer.setInitialSize(new Point(800, 600)); + configurer.setShowCoolBar(false); + configurer.setShowMenuBar(true); + configurer.setShowStatusLine(true); + configurer.setShowPerspectiveBar(true); + configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$ + // Full screen, see + // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html +// configurer.setShellStyle(SWT.NONE); +// Rectangle bounds = Display.getDefault().getBounds(); +// configurer.setInitialSize(new Point(bounds.width, bounds.height)); + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureActionBarAdvisor.java b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureActionBarAdvisor.java new file mode 100644 index 000000000..d5978888f --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureActionBarAdvisor.java @@ -0,0 +1,63 @@ +package org.argeo.security.ui.rcp; + +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; + +public class SecureActionBarAdvisor extends ActionBarAdvisor { + private IWorkbenchAction exitAction; + // private IWorkbenchAction aboutAction; + private IWorkbenchAction newWindowAction; + private IWorkbenchAction preferences = null; + + public SecureActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(IWorkbenchWindow window) { + preferences = ActionFactory.PREFERENCES.create(window); + register(preferences); + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + + // aboutAction = ActionFactory.ABOUT.create(window); + // register(aboutAction); + + newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); + register(newWindowAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + MenuManager fileMenu = new MenuManager("&File", + IWorkbenchActionConstants.M_FILE); + MenuManager editMenu = new MenuManager("&Edit", + IWorkbenchActionConstants.M_EDIT); + MenuManager helpMenu = new MenuManager("&Help", + IWorkbenchActionConstants.M_HELP); + + menuBar.add(fileMenu); + menuBar.add(editMenu); + // Add a group marker indicating where action set menus will appear. + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(helpMenu); + + // File + fileMenu.add(newWindowAction); + fileMenu.add(new Separator()); + fileMenu.add(exitAction); + + // Edit + editMenu.add(preferences); + + // Help + // helpMenu.add(aboutAction); + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureRap.java b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureRap.java new file mode 100644 index 000000000..cc494485e --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureRap.java @@ -0,0 +1,103 @@ +package org.argeo.security.ui.rcp; + +import java.security.PrivilegedAction; + +import javax.security.auth.Subject; + +import org.argeo.security.equinox.CurrentUser; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class SecureRap implements IApplication { + public Object start(IApplicationContext context) throws Exception { + String username = CurrentUser.getUsername(); + Integer result = null; + Display display = PlatformUI.createDisplay(); + try { + result = (Integer) Subject.doAs(CurrentUser.getSubject(), + getRunAction(display)); + } catch (Exception e) { + e.printStackTrace(); + } finally { + display.dispose(); + } + return result; + } + + @SuppressWarnings("rawtypes") + private PrivilegedAction getRunAction(final Display display) { + return new PrivilegedAction() { + + public Object run() { + int result = PlatformUI.createAndRunWorkbench(display, + new ApplicationWorkbenchAdvisor()); + return new Integer(result); + } + }; + } + + public void stop() { + final IWorkbench workbench; + try { + workbench = PlatformUI.getWorkbench(); + } catch (Exception e) { + return; + } + if (workbench == null) + return; + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } + + class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + private static final String PERSPECTIVE_ID = "org.argeo.security.ui.securityPerspective"; + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( + IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return PERSPECTIVE_ID; + } + } + + class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + public ApplicationWorkbenchWindowAdvisor( + IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public ActionBarAdvisor createActionBarAdvisor( + IActionBarConfigurer configurer) { + return new ActionBarAdvisor(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(500, 300)); + configurer.setShowCoolBar(false); + configurer.setShowMenuBar(false); + configurer.setShowStatusLine(false); + configurer.setTitle("Equinox Security on RAP"); + } + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureRcp.java b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureRcp.java new file mode 100644 index 000000000..47a535984 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureRcp.java @@ -0,0 +1,70 @@ +package org.argeo.security.ui.rcp; + +import java.security.PrivilegedAction; + +import javax.security.auth.Subject; + +import org.argeo.security.equinox.CurrentUser; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + +public class SecureRcp implements IApplication { + public Object start(IApplicationContext context) throws Exception { + String username = CurrentUser.getUsername(); + Integer returnCode = null; + Display display = PlatformUI.createDisplay(); + try { + returnCode = (Integer) Subject.doAs(CurrentUser.getSubject(), + getRunAction(display)); + if (returnCode == PlatformUI.RETURN_RESTART) + return IApplication.EXIT_RESTART; + else + return IApplication.EXIT_OK; + } catch (Exception e) { + // e.printStackTrace(); + IStatus status = new Status(IStatus.ERROR, + "org.eclipse.rap.security.demo", "Login failed", e); + ErrorDialog.openError(null, "Error", "Login failed", status); + } finally { + display.dispose(); + } + return returnCode; + } + + private PrivilegedAction getRunAction(final Display display) { + return new PrivilegedAction() { + + public Object run() { + int result = PlatformUI.createAndRunWorkbench(display, + new SecureWorkbenchAdvisor()); + return new Integer(result); + } + }; + } + + public void stop() { + final IWorkbench workbench; + try { + workbench = PlatformUI.getWorkbench(); + } catch (Exception e) { + return; + } + if (workbench == null) + return; + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureWorkbenchAdvisor.java b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureWorkbenchAdvisor.java new file mode 100644 index 000000000..d39bf84d6 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureWorkbenchAdvisor.java @@ -0,0 +1,18 @@ +package org.argeo.security.ui.rcp; + +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class SecureWorkbenchAdvisor extends WorkbenchAdvisor { + + static final String PERSPECTIVE_ID = "org.argeo.security.ui.securityPerspective"; //$NON-NLS-1$ + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new SecureWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return PERSPECTIVE_ID; + } +} diff --git a/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureWorkbenchWindowAdvisor.java b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureWorkbenchWindowAdvisor.java new file mode 100644 index 000000000..146ac8f10 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/SecureWorkbenchWindowAdvisor.java @@ -0,0 +1,30 @@ +package org.argeo.security.ui.rcp; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class SecureWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + public SecureWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public ActionBarAdvisor createActionBarAdvisor( + IActionBarConfigurer configurer) { + return new SecureActionBarAdvisor(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(800, 600)); + configurer.setShowCoolBar(false); + configurer.setShowMenuBar(true); + configurer.setShowStatusLine(true); + configurer.setShowPerspectiveBar(true); + configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$ + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui/.classpath b/security/eclipse/plugins/org.argeo.security.ui/.classpath new file mode 100644 index 000000000..92f19d2ff --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui/.project b/security/eclipse/plugins/org.argeo.security.ui/.project new file mode 100644 index 000000000..a052e9a57 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/.project @@ -0,0 +1,28 @@ + + + org.argeo.security.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/security/eclipse/plugins/org.argeo.security.ui/.settings/org.eclipse.jdt.core.prefs b/security/eclipse/plugins/org.argeo.security.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..aef0f5291 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Sat Jan 15 13:25:02 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/security/eclipse/plugins/org.argeo.security.ui/.settings/org.eclipse.pde.core.prefs b/security/eclipse/plugins/org.argeo.security.ui/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..dfa507d81 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +#Sat Jan 15 18:15:48 CET 2011 +eclipse.preferences.version=1 +resolve.requirebundle=false diff --git a/security/eclipse/plugins/org.argeo.security.ui/META-INF/MANIFEST.MF b/security/eclipse/plugins/org.argeo.security.ui/META-INF/MANIFEST.MF new file mode 100644 index 000000000..30b48d92d --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/META-INF/MANIFEST.MF @@ -0,0 +1,37 @@ +Manifest-Version: 1.0 +Export-Package: org.argeo.security.ui;uses:="org.eclipse.ui,org.eclips + e.ui.plugin,org.osgi.framework";version="0.2.2.SNAPSHOT-r20110116_215 + 742",org.argeo.security.ui.dialogs;uses:="org.eclipse.swt.events,java + x.security.auth.callback,org.eclipse.swt.widgets,org.eclipse.jface.op + eration,org.eclipse.core.runtime,org.eclipse.jface.dialogs,org.eclips + e.swt.graphics,org.eclipse.swt.layout";version="0.2.2.SNAPSHOT-r20110 + 116_215742",org.argeo.security.ui.views;uses:="org.argeo.security.equ + inox,org.eclipse.jface.viewers,org.eclipse.swt.graphics,org.eclipse.u + i,org.eclipse.ui.part,org.eclipse.swt.widgets,org.argeo.security,org. + argeo";version="0.2.2.SNAPSHOT-r20110116_215742" +Private-Package: .;version="0.2.2-SNAPSHOT-r20110116_215742" +Bundle-ActivationPolicy: lazy +Tool: Bnd-0.0.357 +Bundle-Name: Commons Security UI +Created-By: 1.6.0_0 (Sun Microsystems Inc.) +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.ui;resolution:=optional,org.eclipse.rap.ui + ;resolution:=optional,org.eclipse.core.runtime +Bundle-Vendor: Argeo +Bundle-Version: 0.2.2.SNAPSHOT-r20110116_215742 +Bundle-Activator: org.argeo.security.ui.SecurityUiPlugin +Bundle-ManifestVersion: 2 +Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt +Import-Package: javax.security.auth.callback,org.argeo;version="0.2",o + rg.argeo.eclipse.spring;version="0.2",org.argeo.security;version="0.2 + ",org.argeo.security.equinox;version="0.2",org.argeo.security.ui;vers + ion="0.2",org.argeo.security.ui.dialogs;version="0.2",org.argeo.secur + ity.ui.views;version="0.2",org.eclipse.core.runtime;registry=split;ve + rsion="3.4",org.eclipse.jface.dialogs,org.eclipse.jface.operation,org + .eclipse.jface.viewers,org.eclipse.swt.events,org.eclipse.swt.graphic + s,org.eclipse.swt.layout,org.eclipse.swt.widgets,org.eclipse.ui;ui.wo + rkbench=split,org.eclipse.ui.part;ui.workbench=split,org.eclipse.ui.p + lugin,org.osgi.framework;version="1.5" +Bundle-SymbolicName: org.argeo.security.ui;singleton:=true +Bundle-DocURL: http://www.argeo.org + diff --git a/security/eclipse/plugins/org.argeo.security.ui/META-INF/spring/osgi.xml b/security/eclipse/plugins/org.argeo.security.ui/META-INF/spring/osgi.xml new file mode 100644 index 000000000..6574cf125 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/META-INF/spring/osgi.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/security/eclipse/plugins/org.argeo.security.ui/META-INF/spring/views.xml b/security/eclipse/plugins/org.argeo.security.ui/META-INF/spring/views.xml new file mode 100644 index 000000000..2cd8d033f --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/META-INF/spring/views.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui/build.properties b/security/eclipse/plugins/org.argeo.security.ui/build.properties new file mode 100644 index 000000000..7b6db787b --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/build.properties @@ -0,0 +1,5 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/security/eclipse/plugins/org.argeo.security.ui/plugin.xml b/security/eclipse/plugins/org.argeo.security.ui/plugin.xml new file mode 100644 index 000000000..b99ba652f --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/plugin.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui/pom.xml b/security/eclipse/plugins/org.argeo.security.ui/pom.xml new file mode 100644 index 000000000..a2f77c79d --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/pom.xml @@ -0,0 +1,101 @@ + + 4.0.0 + + org.argeo.commons.security + 0.2.2-SNAPSHOT + plugins + .. + + org.argeo.security.ui + Commons Security UI + jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.felix + maven-bundle-plugin + ${version.maven-bundle-plugin} + + + lazy + org.argeo.security.ui.SecurityUiPlugin + org.eclipse.ui;resolution:=optional,org.eclipse.rap.ui;resolution:=optional,org.eclipse.core.runtime + *,org.argeo.eclipse.spring + + + + + + + + + org.argeo.commons.security + org.argeo.security.core + 0.2.2-SNAPSHOT + + + org.argeo.commons.security + org.argeo.security.equinox + 0.2.2-SNAPSHOT + + + + + org.argeo.commons.eclipse + org.argeo.eclipse.ui + 0.2.2-SNAPSHOT + + + + + org.argeo.commons.eclipse + org.argeo.eclipse.dep.common + 0.2.2-SNAPSHOT + + + + + org.argeo.commons.eclipse + org.argeo.eclipse.dep.rcp + 0.2.2-SNAPSHOT + + + org.eclipse.ui + org.eclipse.ui + provided + + + + + org.argeo.commons.basic + org.argeo.basic.nodeps + 0.2.2-SNAPSHOT + + + + + org.springframework.security + org.springframework.security.core + + + + + org.slf4j + com.springsource.slf4j.org.apache.commons.logging + + + + diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java new file mode 100644 index 000000000..1a630dd17 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java @@ -0,0 +1,23 @@ +package org.argeo.security.ui; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class SecurityPerspective implements IPerspectiveFactory { + + public void createInitialLayout(IPageLayout layout) { + String editorArea = layout.getEditorArea(); + layout.setEditorAreaVisible(false); + layout.setFixed(false); + + IFolderLayout main = layout.createFolder("main", IPageLayout.RIGHT, + 0.3f, editorArea); + IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, + 0.3f, editorArea); + + left.addView("org.argeo.security.ui.usersView"); + main.addView("org.argeo.security.ui.currentUserView"); + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityUiPlugin.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityUiPlugin.java new file mode 100644 index 000000000..5e165ad4f --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityUiPlugin.java @@ -0,0 +1,50 @@ +package org.argeo.security.ui; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class SecurityUiPlugin extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.argeo.security.ui"; //$NON-NLS-1$ + + // The shared instance + private static SecurityUiPlugin plugin; + + /** + * The constructor + */ + public SecurityUiPlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static SecurityUiPlugin getDefault() { + return plugin; + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/AbstractLoginDialog.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/AbstractLoginDialog.java new file mode 100644 index 000000000..d13414e13 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/AbstractLoginDialog.java @@ -0,0 +1,118 @@ +package org.argeo.security.ui.dialogs; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.operation.ModalContext; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public abstract class AbstractLoginDialog extends TitleAreaDialog implements + CallbackHandler { + + boolean processCallbacks = false; + boolean isCancelled = false; + Callback[] callbackArray; + + protected final Callback[] getCallbacks() { + return this.callbackArray; + } + + public abstract void internalHandle(); + + public boolean isCancelled() { + return isCancelled; + } + + protected AbstractLoginDialog(Shell parentShell) { + super(parentShell); + } + + /* + * (non-Javadoc) + * + * @see + * javax.security.auth.callback.CallbackHandler#handle(javax.security.auth + * .callback.Callback[]) + */ + public void handle(final Callback[] callbacks) throws IOException { + this.callbackArray = callbacks; + final Display display = Display.getDefault(); + display.syncExec(new Runnable() { + + public void run() { + isCancelled = false; + setBlockOnOpen(false); + open(); + final Button okButton = getButton(IDialogConstants.OK_ID); + okButton.setText("Login"); + okButton.addSelectionListener(new SelectionListener() { + + public void widgetSelected(final SelectionEvent event) { + processCallbacks = true; + } + + public void widgetDefaultSelected(final SelectionEvent event) { + // nothing to do + } + }); + final Button cancel = getButton(IDialogConstants.CANCEL_ID); + cancel.addSelectionListener(new SelectionListener() { + + public void widgetSelected(final SelectionEvent event) { + isCancelled = true; + processCallbacks = true; + } + + public void widgetDefaultSelected(final SelectionEvent event) { + // nothing to do + } + }); + } + }); + try { + ModalContext.setAllowReadAndDispatch(true); // Works for now. + ModalContext.run(new IRunnableWithProgress() { + + public void run(final IProgressMonitor monitor) { + // Wait here until OK or cancel is pressed, then let it rip. + // The event + // listener + // is responsible for closing the dialog (in the + // loginSucceeded + // event). + while (!processCallbacks) { + try { + Thread.sleep(100); + } catch (final Exception e) { + // do nothing + } + } + processCallbacks = false; + // Call the adapter to handle the callbacks + if (!isCancelled()) + internalHandle(); + } + }, true, new NullProgressMonitor(), Display.getDefault()); + } catch (final Exception e) { + final IOException ioe = new IOException(); + ioe.initCause(e); + throw ioe; + } + } + + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText("Login"); + } +} diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/DefaultLoginDialog.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/DefaultLoginDialog.java new file mode 100644 index 000000000..b0a7e0507 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/DefaultLoginDialog.java @@ -0,0 +1,110 @@ +package org.argeo.security.ui.dialogs; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.TextOutputCallback; + +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class DefaultLoginDialog extends AbstractLoginDialog { + + public DefaultLoginDialog() { + this(Display.getDefault().getActiveShell()); + } + + protected DefaultLoginDialog(Shell parentShell) { + super(parentShell); + } + + protected Point getInitialSize() { + return new Point(300, 280); + } + + protected Control createDialogArea(Composite parent) { + Composite dialogarea = (Composite) super.createDialogArea(parent); + dialogarea.setLayoutData(new GridData(GridData.FILL_BOTH)); + Composite composite = new Composite(dialogarea, SWT.NONE); + composite.setLayout(new GridLayout(2, false)); + createCallbackHandlers(composite); + return composite; + } + + private void createCallbackHandlers(Composite composite) { + Callback[] callbacks = getCallbacks(); + for (int i = 0; i < callbacks.length; i++) { + Callback callback = callbacks[i]; + if (callback instanceof TextOutputCallback) { + createTextoutputHandler(composite, + (TextOutputCallback) callback); + } else if (callback instanceof NameCallback) { + createNameHandler(composite, (NameCallback) callback); + } else if (callback instanceof PasswordCallback) { + createPasswordHandler(composite, (PasswordCallback) callback); + } + } + } + + private void createPasswordHandler(Composite composite, + final PasswordCallback callback) { + Label label = new Label(composite, SWT.NONE); + label.setText(callback.getPrompt()); + final Text passwordText = new Text(composite, SWT.SINGLE | SWT.LEAD + | SWT.PASSWORD | SWT.BORDER); + //passwordText.setLayoutData(new GridData(GridData.FILL_BOTH)); + passwordText.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent event) { + callback.setPassword(passwordText.getText().toCharArray()); + } + }); + } + + private void createNameHandler(Composite composite, + final NameCallback callback) { + Label label = new Label(composite, SWT.NONE); + label.setText(callback.getPrompt()); + final Text text = new Text(composite, SWT.SINGLE | SWT.LEAD + | SWT.BORDER); + //text.setLayoutData(new GridData(GridData.FILL_BOTH)); + text.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent event) { + callback.setName(text.getText()); + } + }); + } + + private void createTextoutputHandler(Composite composite, + TextOutputCallback callback) { + int messageType = callback.getMessageType(); + int dialogMessageType = IMessageProvider.NONE; + switch (messageType) { + case TextOutputCallback.INFORMATION: + dialogMessageType = IMessageProvider.INFORMATION; + break; + case TextOutputCallback.WARNING: + dialogMessageType = IMessageProvider.WARNING; + break; + case TextOutputCallback.ERROR: + dialogMessageType = IMessageProvider.ERROR; + break; + } + setMessage(callback.getMessage(), dialogMessageType); + } + + public void internalHandle() { + } +} diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/views/CurrentUserView.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/views/CurrentUserView.java new file mode 100644 index 000000000..263a722e7 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/views/CurrentUserView.java @@ -0,0 +1,129 @@ +package org.argeo.security.ui.views; + +import org.argeo.security.equinox.CurrentUser; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.part.ViewPart; + +public class CurrentUserView extends ViewPart { + private TableViewer viewer; + + @Override + public void createPartControl(Composite parent) { + + // viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL + // | SWT.V_SCROLL); + viewer = new TableViewer(createTable(parent)); + viewer.setContentProvider(new UsersContentProvider()); + viewer.setLabelProvider(new UsersLabelProvider()); + viewer.setInput(getViewSite()); + // viewer.setInput(SecurityContextHolder.getContext()); + } + + protected Table createTable(Composite parent) { + int style = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL; + + Table table = new Table(parent, style); + + // GridData gridData = new GridData(GridData.FILL_BOTH); + // gridData.grabExcessVerticalSpace = true; + // gridData.grabExcessHorizontalSpace = true; + // gridData.horizontalSpan = 3; + // table.setLayoutData(gridData); + + table.setLinesVisible(true); + table.setHeaderVisible(true); + + TableColumn column = new TableColumn(table, SWT.LEFT, 0); + column.setText("ID"); + column.setWidth(100); + +// column = new TableColumn(table, SWT.LEFT, 1); +// column.setText("Password"); +// column.setWidth(200); + + // column = new TableColumn(table, SWT.LEFT, 2); + // column.setText("Roles"); + // column.setWidth(300); + + return table; + } + + @Override + public void setFocus() { + viewer.getTable().setFocus(); + } + + private class UsersContentProvider implements IStructuredContentProvider { + + public Object[] getElements(Object inputElement) { + return getChildren(inputElement); + } + + public Object[] getChildren(Object parentElement) { +// ILoginContext secureContext = LoginContextFactory +// .createContext("SPRING"); +// try { +// secureContext.login(); +// } catch (LoginException e) { +// // login failed +// } +// +// Subject subject = null; +// // subject = Subject.getSubject(AccessController.getContext()); +// try { +// subject = secureContext.getSubject(); +// } catch (Exception e) { +// e.printStackTrace(); +// throw new ArgeoException("Cannot retrieve subject", e); +// } +// +// if (subject == null) +// throw new ArgeoException("No subject found"); +// return subject.getPrincipals().toArray(); + return CurrentUser.roles().toArray(); + } + + public void dispose() { + // TODO Auto-generated method stub + + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + + } + + } + + private class UsersLabelProvider extends LabelProvider implements + ITableLabelProvider { + public String getColumnText(Object element, int columnIndex) { +// Principal argeoUser = (Principal) element; +// switch (columnIndex) { +// case 0: +// return argeoUser.getName(); +// case 1: +// return argeoUser.toString(); +// default: +// throw new ArgeoException("Unmanaged column " + columnIndex); +// } + return element.toString(); + } + + public Image getColumnImage(Object element, int columnIndex) { + // TODO Auto-generated method stub + return null; + } + + } + +} diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/views/UsersView.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/views/UsersView.java new file mode 100644 index 000000000..d54c1a6e7 --- /dev/null +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/views/UsersView.java @@ -0,0 +1,129 @@ +package org.argeo.security.ui.views; + +import org.argeo.ArgeoException; +import org.argeo.security.ArgeoSecurityService; +import org.argeo.security.ArgeoUser; +import org.argeo.security.equinox.CurrentUser; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.part.ViewPart; + +public class UsersView extends ViewPart { + private TableViewer viewer; + private ArgeoSecurityService securityService; + + @Override + public void createPartControl(Composite parent) { + + // viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL + // | SWT.V_SCROLL); + viewer = new TableViewer(createTable(parent)); + viewer.setContentProvider(new UsersContentProvider()); + viewer.setLabelProvider(new UsersLabelProvider()); + viewer.setInput(getViewSite()); + // viewer.setInput(SecurityContextHolder.getContext()); + } + + protected Table createTable(Composite parent) { + int style = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL; + + Table table = new Table(parent, style); + + // GridData gridData = new GridData(GridData.FILL_BOTH); + // gridData.grabExcessVerticalSpace = true; + // gridData.grabExcessHorizontalSpace = true; + // gridData.horizontalSpan = 3; + // table.setLayoutData(gridData); + + table.setLinesVisible(true); + table.setHeaderVisible(true); + + TableColumn column = new TableColumn(table, SWT.LEFT, 0); + column.setText("ID"); + column.setWidth(100); + + column = new TableColumn(table, SWT.LEFT, 1); + column.setText("Password"); + column.setWidth(200); + + // column = new TableColumn(table, SWT.LEFT, 2); + // column.setText("Roles"); + // column.setWidth(300); + + return table; + } + + @Override + public void setFocus() { + viewer.getTable().setFocus(); + } + + private class UsersContentProvider implements IStructuredContentProvider { + + public Object[] getElements(Object inputElement) { + return getChildren(inputElement); + } + + public Object[] getChildren(Object parentElement) { +// try { +// Thread.sleep(3000); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + return securityService.getSecurityDao().listUsers().toArray(); + } + + public void dispose() { + // TODO Auto-generated method stub + + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + + } + + } + + private class UsersLabelProvider extends LabelProvider implements + ITableLabelProvider { + public String getColumnText(Object element, int columnIndex) { + String currentUsername = CurrentUser.getUsername(); + ArgeoUser argeoUser = (ArgeoUser) element; + switch (columnIndex) { + case 0: + String userName = argeoUser.getUsername(); + if (userName.equals(currentUsername)) + userName = userName + "*"; + return userName; + case 1: + return argeoUser.getPassword(); + case 2: + return argeoUser.getRoles().toString(); + default: + throw new ArgeoException("Unmanaged column " + columnIndex); + } + } + + public Image getColumnImage(Object element, int columnIndex) { + // TODO Auto-generated method stub + return null; + } + + } + + public void setSecurityService(ArgeoSecurityService securityService) { + this.securityService = securityService; + } + +} diff --git a/security/eclipse/plugins/pom.xml b/security/eclipse/plugins/pom.xml new file mode 100644 index 000000000..f8d71708e --- /dev/null +++ b/security/eclipse/plugins/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + + org.argeo.commons.security + 0.2.2-SNAPSHOT + eclipse + .. + + plugins + Commons Security Eclipse plugins + pom + + org.argeo.security.equinox + org.argeo.security.ui + org.argeo.security.ui.rcp + org.argeo.security.ui.rap + + + + + src/main/resources + + + . + + plugin.xml + META-INF/** + jaas/** + + + + + + maven-clean-plugin + + + + META-INF + + MANIFEST.MF + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + META-INF/MANIFEST.MF + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.felix + maven-bundle-plugin + + META-INF + + ${pom.artifactId};singleton:=true + + + + + + + + org.argeo.commons.osgi + org.argeo.osgi.boot + 0.2.2-SNAPSHOT + test + + + diff --git a/security/eclipse/pom.xml b/security/eclipse/pom.xml new file mode 100644 index 000000000..86a460103 --- /dev/null +++ b/security/eclipse/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + org.argeo.commons + 0.2.2-SNAPSHOT + argeo-commons + .. + + org.argeo.commons.security + eclipse + Commons Security Eclipse + pom + + + plugins + + \ No newline at end of file diff --git a/security/pom.xml b/security/pom.xml index b54b87386..aadcc35d6 100644 --- a/security/pom.xml +++ b/security/pom.xml @@ -13,6 +13,7 @@ runtime modules + eclipse dep demo diff --git a/server/modules/org.argeo.server.ads.server/.project b/server/modules/org.argeo.server.ads.server/.project new file mode 100644 index 000000000..a191480d8 --- /dev/null +++ b/server/modules/org.argeo.server.ads.server/.project @@ -0,0 +1,22 @@ + + + org.argeo.server.ads.server + + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + + diff --git a/server/modules/org.argeo.server.ads.server/.settings/org.eclipse.pde.core.prefs b/server/modules/org.argeo.server.ads.server/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..5733b3123 --- /dev/null +++ b/server/modules/org.argeo.server.ads.server/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Sun Jan 16 09:58:38 CET 2011 +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/server/modules/org.argeo.server.ads.server/META-INF/spring/ads.xml b/server/modules/org.argeo.server.ads.server/META-INF/spring/ads.xml index b579ee5f8..6762fd33f 100644 --- a/server/modules/org.argeo.server.ads.server/META-INF/spring/ads.xml +++ b/server/modules/org.argeo.server.ads.server/META-INF/spring/ads.xml @@ -5,15 +5,13 @@ - - osgibundle:ads.properties - + osgibundle:ads.properties - + @@ -31,26 +29,17 @@ simple ${argeo.ldap.manager.userdn} ${argeo.ldap.manager.password} - - - - - - + + + + + + diff --git a/server/modules/org.argeo.server.ads.server/build.properties b/server/modules/org.argeo.server.ads.server/build.properties new file mode 100644 index 000000000..5f22cdd44 --- /dev/null +++ b/server/modules/org.argeo.server.ads.server/build.properties @@ -0,0 +1 @@ +bin.includes = META-INF/ diff --git a/server/runtime/org.argeo.server.core/pom.xml b/server/runtime/org.argeo.server.core/pom.xml index 9cde2f459..01dec5f22 100644 --- a/server/runtime/org.argeo.server.core/pom.xml +++ b/server/runtime/org.argeo.server.core/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.argeo.commons.server @@ -65,6 +66,10 @@ javax.servlet com.springsource.javax.servlet + + javax.xml.stream + com.springsource.javax.xml.stream + diff --git a/server/runtime/org.argeo.server.jackrabbit/build.properties b/server/runtime/org.argeo.server.jackrabbit/build.properties index fdf424dbc..cd05956ed 100644 --- a/server/runtime/org.argeo.server.jackrabbit/build.properties +++ b/server/runtime/org.argeo.server.jackrabbit/build.properties @@ -7,6 +7,4 @@ additional.bundles = com.springsource.slf4j.api,\ com.springsource.org.apache.lucene,\ org.springframework.context source.. = src/main/java/,\ - src/test/java/,\ - src/test/resources/,\ src/main/resources/