Codota Logo
LDAPUserInfoImpl
Code IndexAdd Codota to your IDE (free)

How to use
LDAPUserInfoImpl
in
org.jbpm.services.task.identity

Best Java code snippets using org.jbpm.services.task.identity.LDAPUserInfoImpl (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: kiegroup/jbpm

private String extractEntityId(OrganizationalEntity entity) {
  if (!isEntityIdDn()) {
    return entity.getId();
  }
    String entityAttrId = null;
  if (entity instanceof User) {
    entityAttrId = getConfigProperty(USER_ATTR_ID, DEFAULT_USER_ATTR_ID);
  } else if (entity instanceof Group) {
    entityAttrId = getConfigProperty(ROLE_ATTR_ID, DEFAULT_ROLE_ATTR_ID);
  }
  
  return extractAttribute(entity.getId(), entityAttrId);
}

origin: kiegroup/jbpm

private String getAttributeValueForEntity(OrganizationalEntity entity, String attributeName, String defaultValue) {
  String context = getConfigPropertyByEntity(entity, USER_CTX, ROLE_CTX);
  String filter = getConfigPropertyByEntity(entity, USER_FILTER, ROLE_FILTER);
  String attrId = getConfigProperty(attributeName, defaultValue);
  String entityId = extractEntityId(entity);
  return ldapSearcher.search(context, filter, entityId).getSingleAttributeResult(attrId);
}
origin: kiegroup/jbpm

@Override
public String getLanguageForEntity(OrganizationalEntity entity) {
  String result = getAttributeValueForEntity(entity, LANG_ATTR_ID, DEFAULT_LANG_ATTR_ID);
  return result == null ? DEFAULT_LOCALE : result;
}
origin: kiegroup/jbpm

@Override
public Iterator<OrganizationalEntity> getMembersForGroup(Group group) {
  String roleContext = getConfigProperty(ROLE_CTX);
  String roleFilter = getConfigProperty(ROLE_MEMBERS_FILTER, getConfigProperty(ROLE_FILTER));
  String roleAttrId = getConfigProperty(MEMBER_ATTR_ID, DEFAULT_MEMBER_ATTR_ID);
  String entityId = extractEntityId(group);
  List<String> memberIds = ldapSearcher.search(roleContext, roleFilter, entityId).getAttributeResults(roleAttrId);
  return memberIds.stream()
      .filter(memberId -> memberId != null)
      .map(memberId -> (OrganizationalEntity) TaskModelProvider.getFactory().newUser(memberId))
      .collect(Collectors.toList())
      .iterator();
}
origin: kiegroup/jbpm

private UserInfo createLdapUserInfoUid(Properties properties) {
  properties.setProperty(LDAPUserInfoImpl.NAME_ATTR_ID, "uid");
  return new LDAPUserInfoImpl(properties);
}
origin: kiegroup/jbpm

@Override
public String getEntityForEmail(String email) {        
  String context = getConfigProperty(USER_CTX);
  String filter = getConfigProperty(EMAIL_FILTER);
  String attributeId = getConfigProperty(USER_ATTR_ID, DEFAULT_USER_ATTR_ID);
  LdapSearcher searcher = ldapSearcher.search(context, filter, email);
  if (searcher.getSearchResults().isEmpty()) {
    return null;
  }
  
  if (isEntityIdDn()) {
    return searcher.getSingleSearchResult().getNameInNamespace();
  }
  
  return searcher.getSingleAttributeResult(attributeId);
}
origin: kiegroup/jbpm

private String getConfigPropertyByEntity(OrganizationalEntity entity, String userKey, String roleKey) {
  if (entity instanceof User) {
    return getConfigProperty(userKey);
  } else if (entity instanceof Group) {
    return getConfigProperty(roleKey);
  } else {
    throw new IllegalArgumentException("Unknown organizational entity: " + entity);
  }
}
origin: kiegroup/jbpm

@Override
public boolean hasEmail(Group group) {
  return getEmailForEntity(group) != null;
}
origin: kiegroup/jbpm

private UserInfo createLdapUserInfoCn(Properties properties) {
  properties.setProperty(LDAPUserInfoImpl.NAME_ATTR_ID, "cn");
  return new LDAPUserInfoImpl(properties);
}
origin: kiegroup/jbpm

private boolean isEntityIdDn() {
  return Boolean.parseBoolean(getConfigProperty(IS_ENTITY_ID_DN, DEFAULT_ENTITY_ID_DN));
}
origin: kiegroup/jbpm

  public static UserInfo getUserInfo() {
    UserInfo userInfo = new DefaultUserInfo(true);
    
    if ("ldap".equalsIgnoreCase(USER_INFO_IMPL)) {
      userInfo = new LDAPUserInfoImpl(true);
    } else if ("db".equalsIgnoreCase(USER_INFO_IMPL)) {
      userInfo = new DBUserInfoImpl(true);
    } else if ("props".equalsIgnoreCase(USER_INFO_IMPL)) {
      userInfo = new PropertyUserInfoImpl(true);
    } else if ("custom".equalsIgnoreCase(USER_INFO_IMPL)) {
      try {
        userInfo = (UserInfo) Class.forName(CUSTOM_USER_INFO_IMPL).newInstance();
      } catch (Exception e) {
        throw new RuntimeException("Unable to create instance of custom user info impl", e);
      }
    }
    
    return userInfo;
  }
}
origin: kiegroup/jbpm

@Override
public String getDisplayName(OrganizationalEntity entity) {
  return getAttributeValueForEntity(entity, NAME_ATTR_ID, DEFAULT_NAME_ATTR_ID);
}
origin: kiegroup/jbpm

private void testGetEntityForEmail(String email, String expected, boolean useDN) {
  Properties properties = createUserInfoProperties();
  if (useDN) {
    properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
  }
  UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
  Assertions.assertThat(ldapUserInfo.getEntityForEmail(email)).isEqualTo(expected);
}

origin: kiegroup/jbpm

@Override
public String getEmailForEntity(OrganizationalEntity entity) {
  return getAttributeValueForEntity(entity, EMAIL_ATTR_ID, DEFAULT_EMAIL_ATTR_ID);
}
origin: kiegroup/jbpm

private void testHasEmail(Group group, boolean hasEmail, boolean customAttribute) {
  Properties properties = createUserInfoProperties();
  if (customAttribute) {
    properties.setProperty(LDAPUserInfoImpl.EMAIL_ATTR_ID, "email");
  }
  if (group.getId().startsWith("cn=")) {
    properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
  }
  UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
  Assertions.assertThat(ldapUserInfo.hasEmail(group)).isEqualTo(hasEmail);
}
origin: kiegroup/jbpm

private void testGetEmailForEntity(OrganizationalEntity entity, String email, boolean customAttribute) {
  Properties properties = createUserInfoProperties();
  if (customAttribute) {
    properties.setProperty(LDAPUserInfoImpl.EMAIL_ATTR_ID, "email");
  }
  if (entity.getId().startsWith("uid=") || entity.getId().startsWith("cn=")) {
    properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
  }
  UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
  Assertions.assertThat(ldapUserInfo.getEmailForEntity(entity)).isEqualTo(email);
}
origin: kiegroup/jbpm

private void testGetLanguageForEntity(OrganizationalEntity entity, String language, boolean customAttribute) {
  Properties properties = createUserInfoProperties();
  if (customAttribute) {
    properties.setProperty(LDAPUserInfoImpl.LANG_ATTR_ID, "language");
  }
  if (entity.getId().startsWith("uid=") || entity.getId().startsWith("cn=")) {
    properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
  }
  UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
  Assertions.assertThat(ldapUserInfo.getLanguageForEntity(entity)).isEqualTo(language);
}
origin: kiegroup/jbpm

private void testGetDisplayName(OrganizationalEntity entity, String expectedName, boolean customAttribute) {
  Properties properties = createUserInfoProperties();
  if (customAttribute) {
    properties.setProperty(LDAPUserInfoImpl.NAME_ATTR_ID, "name");
  }
  if (entity.getId().startsWith("uid=") || entity.getId().startsWith("cn=")) {
    properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
  }
  UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
  String name = ldapUserInfo.getDisplayName(entity);
  Assertions.assertThat(name).isNotNull();
  Assertions.assertThat(name).isEqualTo(expectedName);
}
origin: kiegroup/jbpm

private void testGetMembersForGroup(boolean emptyGroup, boolean customAttribute, boolean distinguishedName) {
  Properties properties = createUserInfoProperties();
  if (customAttribute) {
    properties.setProperty(LDAPUserInfoImpl.MEMBER_ATTR_ID, "representative");
  }
  if (distinguishedName) {
    properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
  }
  UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
  Group group;
  if (distinguishedName) {
    group = emptyGroup ? USER_DN : MANAGER_DN;
  } else {
    group = emptyGroup ? USER : MANAGER;
  }
  Iterator<OrganizationalEntity> iterator = ldapUserInfo.getMembersForGroup(group);
  if (emptyGroup) {
    Assertions.assertThat(iterator.hasNext()).isFalse();
    return;
  }
  Assertions.assertThat(iterator.hasNext()).isTrue();
  User user = (User) iterator.next();
  if (customAttribute) {
    Assertions.assertThat(user.getId()).isEqualTo(MARY_DN.getId());
  } else {
    Assertions.assertThat(user.getId()).isEqualTo(JOHN_DN.getId());
  }
  Assertions.assertThat(iterator.hasNext()).isFalse();
}
origin: org.jbpm/jbpm-runtime-manager

  public static UserInfo getUserInfo() {
    UserInfo userInfo = new DefaultUserInfo(true);
    
    if ("ldap".equalsIgnoreCase(USER_INFO_IMPL)) {
      userInfo = new LDAPUserInfoImpl(true);
    } else if ("db".equalsIgnoreCase(USER_INFO_IMPL)) {
      userInfo = new DBUserInfoImpl(true);
    } else if ("props".equalsIgnoreCase(USER_INFO_IMPL)) {
      userInfo = new PropertyUserInfoImpl(true);
    } else if ("custom".equalsIgnoreCase(USER_INFO_IMPL)) {
      try {
        userInfo = (UserInfo) Class.forName(CUSTOM_USER_INFO_IMPL).newInstance();
      } catch (Exception e) {
        throw new RuntimeException("Unable to create instance of custom user info impl", e);
      }
    }
    
    return userInfo;
  }
}
org.jbpm.services.task.identityLDAPUserInfoImpl

Most used methods

  • <init>
  • extractAttribute
  • extractEntityId
  • getAttributeValueForEntity
  • getConfigProperty
  • getConfigPropertyByEntity
  • getEmailForEntity
  • isEntityIdDn

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now