Tabnine Logo
KillBillJndiLdapRealm
Code IndexAdd Tabnine to your IDE (free)

How to use
KillBillJndiLdapRealm
in
com.ning.billing.util.security.shiro.realm

Best Java code snippets using com.ning.billing.util.security.shiro.realm.KillBillJndiLdapRealm (Showing top 5 results out of 315)

origin: com.ning.billing/killbill-util

@Override
protected AuthorizationInfo queryForAuthorizationInfo(final PrincipalCollection principals, final LdapContextFactory ldapContextFactory) throws NamingException {
  final Set<String> userGroups = findLDAPGroupsForUser(principals, ldapContextFactory);
  final SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(userGroups);
  final Set<String> stringPermissions = groupsPermissions(userGroups);
  simpleAuthorizationInfo.setStringPermissions(stringPermissions);
  return simpleAuthorizationInfo;
}
origin: com.ning.billing/killbill-util

private Set<String> findLDAPGroupsForUser(final PrincipalCollection principals, final LdapContextFactory ldapContextFactory) throws NamingException {
  final String username = (String) getAvailablePrincipal(principals);
  LdapContext systemLdapCtx = null;
  try {
    systemLdapCtx = ldapContextFactory.getSystemLdapContext();
    return findLDAPGroupsForUser(username, systemLdapCtx);
  } catch (AuthenticationException ex) {
    log.info("LDAP authentication exception: " + ex.getLocalizedMessage());
    return ImmutableSet.<String>of();
  } finally {
    LdapUtils.closeContext(systemLdapCtx);
  }
}
origin: com.ning.billing/killbill-util

final ConfigSource customConfigSource = new SimplePropertyConfigSource(props);
final SecurityConfig securityConfig = new ConfigurationObjectFactory(customConfigSource).build(SecurityConfig.class);
final KillBillJndiLdapRealm ldapRealm = new KillBillJndiLdapRealm(securityConfig);
final AuthenticationInfo authenticationInfo = ldapRealm.getAuthenticationInfo(token);
System.out.println(authenticationInfo);
final AuthorizationInfo authorizationInfo = ldapRealm.queryForAuthorizationInfo(principals, ldapRealm.getContextFactory());
System.out.println("Roles: " + authorizationInfo.getRoles());
System.out.println("Permissions: " + authorizationInfo.getStringPermissions());
origin: com.ning.billing/killbill-util

  setUserDnTemplate(securityConfig.getShiroLDAPUserDnTemplate());
final JndiLdapContextFactory contextFactory = (JndiLdapContextFactory) getContextFactory();
if (securityConfig.disableShiroLDAPSSLCheck()) {
  contextFactory.getEnvironment().put("java.naming.ldap.factory.socket", SkipSSLCheckSocketFactory.class.getName());
  contextFactory.setAuthenticationMechanism(securityConfig.getShiroLDAPAuthenticationMechanism());
setContextFactory(contextFactory);
origin: com.ning.billing/killbill-util

@Test(groups = "fast")
public void testCheckConfiguration() throws Exception {
  // Test default configuration (see SecurityConfig)
  final Map<String, Collection<String>> permission = killBillJndiLdapRealm.getPermissionsByGroup();
  Assert.assertEquals(permission.get("admin").size(), 1);
  Assert.assertEquals(permission.get("admin").iterator().next(), "*:*");
  Assert.assertEquals(permission.get("finance").size(), 2);
  Assert.assertEquals(Sets.newHashSet(permission.get("finance")), Sets.newHashSet("invoice:*", "payment:*"));
  Assert.assertEquals(permission.get("support").size(), 2);
  Assert.assertEquals(Sets.newHashSet(permission.get("support")), Sets.newHashSet("entitlement:*", "invoice:item_adjust"));
}
com.ning.billing.util.security.shiro.realmKillBillJndiLdapRealm

Most used methods

  • getContextFactory
  • <init>
  • findLDAPGroupsForUser
  • getAuthenticationInfo
  • getAvailablePrincipal
  • getPermissionsByGroup
  • groupsPermissions
  • queryForAuthorizationInfo
  • setContextFactory
  • setUserDnTemplate

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSupportFragmentManager (FragmentActivity)
  • addToBackStack (FragmentTransaction)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Path (java.nio.file)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Table (org.hibernate.mapping)
    A relational table
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now