Example usage for org.apache.shiro.config Ini getSections

List of usage examples for org.apache.shiro.config Ini getSections

Introduction

In this page you can find the example usage for org.apache.shiro.config Ini getSections.

Prototype

public Collection<Section> getSections() 

Source Link

Document

Returns the sections managed by this Ini instance or an empty collection if there are no sections.

Usage

From source file:annis.security.MultipleIniWebEnvironment.java

License:Apache License

@Override
public void init() throws ShiroException {
    Ini ini = new Ini();

    Preconditions.checkNotNull(getConfigLocations());

    for (String p : getConfigLocations()) {
        Ini subIni = new Ini(ini);
        subIni.loadFromPath(p);//from ww  w .  j a  v  a  2 s . c  o  m

        // add all values from the sub file to the main configuration
        for (Section section : subIni.getSections()) {
            Section existing = ini.getSection(section.getName());
            if (existing == null) {
                existing = ini.addSection(section.getName());
            }
            existing.putAll(section);
        }
    }

    setIni(ini);
    configure();
}

From source file:org.killbill.billing.util.security.shiro.realm.KillBillJndiLdapRealm.java

License:Apache License

@Inject
public KillBillJndiLdapRealm(final SecurityConfig securityConfig) {
    super();//from   ww w. j  a va  2s  .  c  o  m

    if (securityConfig.getShiroLDAPUserDnTemplate() != null) {
        setUserDnTemplate(securityConfig.getShiroLDAPUserDnTemplate());
    }

    final JndiLdapContextFactory contextFactory = (JndiLdapContextFactory) getContextFactory();
    if (securityConfig.disableShiroLDAPSSLCheck()) {
        contextFactory.getEnvironment().put("java.naming.ldap.factory.socket",
                SkipSSLCheckSocketFactory.class.getName());
    }
    if (securityConfig.getShiroLDAPUrl() != null) {
        contextFactory.setUrl(securityConfig.getShiroLDAPUrl());
    }
    if (securityConfig.getShiroLDAPSystemUsername() != null) {
        contextFactory.setSystemUsername(securityConfig.getShiroLDAPSystemUsername());
    }
    if (securityConfig.getShiroLDAPSystemPassword() != null) {
        contextFactory.setSystemPassword(securityConfig.getShiroLDAPSystemPassword());
    }
    if (securityConfig.getShiroLDAPAuthenticationMechanism() != null) {
        contextFactory.setAuthenticationMechanism(securityConfig.getShiroLDAPAuthenticationMechanism());
    }
    setContextFactory(contextFactory);

    searchBase = securityConfig.getShiroLDAPSearchBase();
    groupSearchFilter = securityConfig.getShiroLDAPGroupSearchFilter();
    groupNameId = securityConfig.getShiroLDAPGroupNameID();

    if (securityConfig.getShiroLDAPPermissionsByGroup() != null) {
        final Ini ini = new Ini();
        // When passing properties on the command line, \n can be escaped
        ini.load(securityConfig.getShiroLDAPPermissionsByGroup().replace("\\n", "\n"));
        for (final Section section : ini.getSections()) {
            for (final String role : section.keySet()) {
                final Collection<String> permissions = ImmutableList
                        .<String>copyOf(SPLITTER.split(section.get(role)));
                permissionsByGroup.put(role, permissions);
            }
        }
    }
}

From source file:org.killbill.billing.util.security.shiro.realm.KillBillOktaRealm.java

License:Apache License

@Inject
public KillBillOktaRealm(final SecurityConfig securityConfig) {
    this.securityConfig = securityConfig;
    this.httpClient = new AsyncHttpClient(
            new AsyncHttpClientConfig.Builder().setRequestTimeout(DEFAULT_TIMEOUT_SECS * 1000).build());

    if (securityConfig.getShiroOktaPermissionsByGroup() != null) {
        final Ini ini = new Ini();
        // When passing properties on the command line, \n can be escaped
        ini.load(securityConfig.getShiroOktaPermissionsByGroup().replace("\\n", "\n"));
        for (final Section section : ini.getSections()) {
            for (final String role : section.keySet()) {
                final Collection<String> permissions = ImmutableList
                        .<String>copyOf(SPLITTER.split(section.get(role)));
                permissionsByGroup.put(role, permissions);
            }/*from www  .  j  a va  2  s.  c o  m*/
        }
    }
}