<?xml version="1.0" encoding="UTF-8"?>
<!--

    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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.

-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
        <command name="jaas/manage">
            <action class="org.apache.karaf.jaas.command.ManageRealmCommand">
                <property name="realms" ref="realms"/>
            </action>
            <optional-completers>
                <entry key="--realm" value-ref="realmCompleter"/>
                <entry key="--module" value-ref="moduleClassNameCompleter"/>
            </optional-completers>
        </command>
        <command name="jaas/update">
            <action class="org.apache.karaf.jaas.command.UpdateCommand">
                <property name="backingEngineService" ref="engineService"/>
            </action>
        </command>
        <command name="jaas/cancel">
            <action class="org.apache.karaf.jaas.command.CancelCommand"/>
        </command>
        <command name="jaas/pending">
            <action class="org.apache.karaf.jaas.command.ListPendingCommand"/>
        </command>
        <command name="jaas/users">
            <action class="org.apache.karaf.jaas.command.ListUsersCommand">
                <property name="backingEngineService" ref="engineService"/>
            </action>
        </command>
        <command name="jaas/realms">
            <action class="org.apache.karaf.jaas.command.ListRealmsCommand">
                <property name="realms" ref="realms"/>
            </action>
        </command>
        <command name="jaas/useradd">
            <action class="org.apache.karaf.jaas.command.UserAddCommand"/>
        </command>
        <command name="jaas/userdel">
            <action class="org.apache.karaf.jaas.command.UserDeleteCommand"/>
        </command>
        <command name="jaas/roleadd">
            <action class="org.apache.karaf.jaas.command.RoleAddCommand"/>
        </command>
        <command name="jaas/roledel">
            <action class="org.apache.karaf.jaas.command.RoleDeleteCommand"/>
        </command>
    </command-bundle>

    <!-- JAAS Realms -->
    <reference-list id="realms" interface="org.apache.karaf.jaas.config.JaasRealm" availability="optional"/>

    <!-- Backing Engine Service -->
    <bean id="engineService" class="org.apache.karaf.jaas.modules.BackingEngineService">
        <property name="engineFactories" ref="engineFactories"/>
    </bean>

    <!-- 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>

    <bean id="moduleClassNameCompleter" class="org.apache.karaf.jaas.command.completers.LoginModuleNameCompleter">
        <property name="realms" ref="realms"/>
    </bean>

</blueprint>
