title: Removing an unnecessary login module in Apache Karaf
body: <p>This question was originally posted on the karaf users mailing list, but I didn't get an answer:
  <a href="http://karaf.922171.n3.nabble.com/Deleting-an-unnecessary-login-module-td4033321.html" rel="nofollow">http://karaf.922171.n3.nabble.com/Deleting-an-unnecessary-login-module-td4033321.html</a></p>
  
  <p>I would like to remove a login module (PublicKeyLoginModule) from the default jaas karaf realm.</p>
  
  <p>According to the docs:
  <a href="http://karaf.apache.org/manual/latest/developers-guide/security-framework.html" rel="nofollow">http://karaf.apache.org/manual/latest/developers-guide/security-framework.html</a></p>
  
  <p>“So if you want to override the default security configuration in Karaf (which is used by the ssh shell, web console and
  JMX layer), you need to deploy a JAAS configuration with the name name="karaf" and rank="1".”</p>
  
  <p>However, when I do this new modules are added rather than replacing the existing ones.</p>
  
  <p>When the blueprint below is loaded via either the deploy dir or via inclusion in a bundle (created using Maven by including the blueprint from the following path)
  src\main\resources\OSGI-INF\blueprint\context.xml</p>
  
  <p>I get the following:</p>
  
  <pre><code>karaf@root()&gt; jaas:realm-list
  Index | Realm Name | Login Module Class Name
  -----------------------------------------------------------------------------------
  1     | karaf      | org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
  2     | karaf      | org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
  3     | karaf      | org.apache.karaf.jaas.modules.ldap.LDAPLoginModule
  </code></pre>
  
  <p>What I would like to see is either</p>
  
  <pre><code>karaf@root()&gt; jaas:realm-list
  Index | Realm Name | Login Module Class Name
  -----------------------------------------------------------------------------------
  1     | karaf      | org.apache.karaf.jaas.modules.ldap.LDAPLoginModule
  </code></pre>
  
  <p>Or, if there were a way to explicitly delete a module:</p>
  
  <pre><code>karaf@root()&gt; jaas:realm-list
  Index | Realm Name | Login Module Class Name
  -----------------------------------------------------------------------------------
  1     | karaf      | org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
  2     | karaf      | org.apache.karaf.jaas.modules.ldap.LDAPLoginModule
  </code></pre>
  
  <p>This is the blueprint:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
             xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0"
             xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
             xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"&gt;
  
      &lt;type-converters&gt;
          &lt;bean class="org.apache.karaf.jaas.modules.properties.PropertiesConverter"/&gt;
      &lt;/type-converters&gt;
  
      &lt;!-- Allow usage of System properties, especially the karaf.base property --&gt;
      &lt;ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/&gt;
  
      &lt;!-- AdminConfig property place holder for the org.apache.karaf.jaas  --&gt;
      &lt;cm:property-placeholder persistent-id="org.apache.karaf.jaas" update-strategy="none"&gt;
          &lt;cm:default-properties&gt;
              &lt;cm:property name="example.group" value="example-group-value"/&gt;
          &lt;/cm:default-properties&gt;
      &lt;/cm:property-placeholder&gt;
  
      &lt;jaas:config name="karaf" rank="1"&gt;
          &lt;jaas:module className="org.apache.karaf.jaas.modules.ldap.LDAPLoginModule" flags="required"&gt;
              connection.url = ldap://ldap.example.com:389
              user.base.dn = o= example.com
              user.filter = (uid=%u)
              user.search.subtree = true
              role.base.dn = ou=applications,l=global,o= example.com
              role.filter = (&amp;amp;(objectClass=groupOfUniqueNames)(uniqueMember=*uid=%u*)(cn=${ example.group}))
              role.name.attribute = cn
              role.search.subtree = true
              authentication = simple
          &lt;/jaas:module&gt;
      &lt;/jaas:config&gt;
  &lt;/blueprint&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>karaf@root()&gt; shell:info
  Karaf
    Karaf version               3.0.0
    Karaf home                  ***
    Karaf base                  ***
    OSGi Framework              org.apache.felix.framework - 4.2.1
  </code></pre>
  
  <p>Same issue on Karaf 3.0.1</p>
  
  <p>I'd welcome any suggestions. Creating a whole new realm is a possibility, but for policy reasons I'd prefer not to have the PublicKeyLoginModule visible in the runtime at all.</p>