* @param securityConfig The Geronimo security configuration.
* @return the default principal
*/
protected JAASJettyPrincipal generateDefaultPrincipal(Security securityConfig) throws GeronimoSecurityException {
DefaultPrincipal defaultPrincipal = securityConfig.getDefaultPrincipal();
if (defaultPrincipal == null) {
AutoMapAssistant config = securityConfig.getAssistant();
try {
if (config != null) {
Set assistants = kernel.listGBeans(new ObjectName("geronimo.security:type=SecurityRealm,realm=" + config.getSecurityRealm()));
if (assistants.size() < 1 || assistants.size() > 1) throw new GeronimoSecurityException("Only one auto mapping assistant should match " + config.getSecurityRealm());
org.apache.geronimo.security.realm.AutoMapAssistant assistant = (org.apache.geronimo.security.realm.AutoMapAssistant) assistants.iterator().next();
org.apache.geronimo.security.deploy.Principal principal = assistant.obtainDefaultPrincipal();
defaultPrincipal = new DefaultPrincipal();
defaultPrincipal.setPrincipal(principal);
defaultPrincipal.setRealmName(((SecurityRealm)assistant).getRealmName());
}
} catch (MalformedObjectNameException e) {
throw new GeronimoSecurityException("Bad object name geronimo.security:type=SecurityRealm,realm=" + config.getSecurityRealm());
}