karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ioca...@apache.org
Subject svn commit: r1100605 - in /karaf/trunk/jaas/command/src/main: java/org/apache/karaf/jaas/command/completers/ java/org/apache/karaf/jaas/command/completers/RealmCompleter.java resources/OSGI-INF/blueprint/jaas-command.xml
Date Sat, 07 May 2011 19:39:48 GMT
Author: iocanel
Date: Sat May  7 19:39:48 2011
New Revision: 1100605

URL: http://svn.apache.org/viewvc?rev=1100605&view=rev
Log:
[KARAF-623] Added a shell completer for realm. Jaas manage command now uses the realm completer.

Added:
    karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/completers/
    karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/completers/RealmCompleter.java
Modified:
    karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml

Added: karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/completers/RealmCompleter.java
URL: http://svn.apache.org/viewvc/karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/completers/RealmCompleter.java?rev=1100605&view=auto
==============================================================================
--- karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/completers/RealmCompleter.java
(added)
+++ karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/completers/RealmCompleter.java
Sat May  7 19:39:48 2011
@@ -0,0 +1,38 @@
+package org.apache.karaf.jaas.command.completers;
+
+import org.apache.karaf.jaas.config.JaasRealm;
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+
+import java.util.List;
+
+/**
+ * @author: iocanel
+ */
+public class RealmCompleter implements Completer {
+
+    private final StringsCompleter delegate = new StringsCompleter();
+
+    private List<JaasRealm> realms;
+
+    public int complete(String buffer, int cursor, List<String> candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        try {
+            if (realms != null && !realms.isEmpty())
+                for (JaasRealm realm : realms) {
+                    delegate.getStrings().add(realm.getName());
+                }
+        } catch (Exception e) {
+            // Ignore
+        }
+        return delegate.complete(buffer, cursor, candidates);
+    }
+
+    public List<JaasRealm> getRealms() {
+        return realms;
+    }
+
+    public void setRealms(List<JaasRealm> realms) {
+        this.realms = realms;
+    }
+}

Modified: karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml?rev=1100605&r1=1100604&r2=1100605&view=diff
==============================================================================
--- karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml (original)
+++ karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml Sat May
 7 19:39:48 2011
@@ -24,6 +24,9 @@
             <action class="org.apache.karaf.jaas.command.ManageRealmCommand">
                 <property name="realms" ref="realms"/>
             </action>
+            <completers>
+                <ref component-id="realmCompleter" />
+            </completers>
         </command>
         <command name="jaas/update">
             <action class="org.apache.karaf.jaas.command.UpdateCommand">
@@ -71,4 +74,10 @@
     <!-- Backing Engine Factories -->
     <reference-list id="engineFactories" interface="org.apache.karaf.jaas.modules.BackingEngineFactory"
                     availability="optional"/>
+
+    <!-- Completers -->
+    <bean id="realmCompleter" class="org.apache.karaf.jaas.command.completers.RealmCompleter">
+        <property name="realms" ref="realms"/>
+    </bean>
+
 </blueprint>



Mime
View raw message