2016-02-03 10:20:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
|
|
|
* and other contributors as indicated by the @author tags.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2014-06-23 21:19:15 +00:00
|
|
|
package org.keycloak.models;
|
2014-03-18 17:59:22 +00:00
|
|
|
|
2016-02-19 17:02:39 +00:00
|
|
|
import java.util.Map;
|
|
|
|
|
2014-03-18 17:59:22 +00:00
|
|
|
/**
|
|
|
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
|
|
|
*/
|
2014-06-23 21:19:15 +00:00
|
|
|
public class LDAPConstants {
|
2014-03-18 17:59:22 +00:00
|
|
|
|
2015-06-08 10:28:59 +00:00
|
|
|
public static final String LDAP_PROVIDER = "ldap";
|
2016-01-04 22:25:40 +00:00
|
|
|
public static final String MSAD_USER_ACCOUNT_CONTROL_MAPPER = "msad-user-account-control-mapper";
|
2015-06-08 10:28:59 +00:00
|
|
|
|
2014-06-06 07:45:47 +00:00
|
|
|
public static final String VENDOR = "vendor";
|
|
|
|
public static final String VENDOR_RHDS = "rhds";
|
|
|
|
public static final String VENDOR_ACTIVE_DIRECTORY = "ad";
|
|
|
|
public static final String VENDOR_OTHER = "other";
|
2014-11-13 21:17:40 +00:00
|
|
|
public static final String VENDOR_TIVOLI = "tivoli";
|
2015-04-16 10:47:17 +00:00
|
|
|
public static final String VENDOR_NOVELL_EDIRECTORY="edirectory" ;
|
2014-06-06 07:45:47 +00:00
|
|
|
|
2014-06-23 15:54:11 +00:00
|
|
|
public static final String USERNAME_LDAP_ATTRIBUTE = "usernameLDAPAttribute";
|
2015-05-13 06:41:55 +00:00
|
|
|
public static final String RDN_LDAP_ATTRIBUTE = "rdnLDAPAttribute";
|
2015-05-22 19:05:47 +00:00
|
|
|
public static final String UUID_LDAP_ATTRIBUTE = "uuidLDAPAttribute";
|
2014-06-25 05:59:58 +00:00
|
|
|
public static final String USER_OBJECT_CLASSES = "userObjectClasses";
|
2014-06-23 15:54:11 +00:00
|
|
|
|
2014-03-18 17:59:22 +00:00
|
|
|
public static final String CONNECTION_URL = "connectionUrl";
|
2015-06-02 14:58:32 +00:00
|
|
|
public static final String BASE_DN = "baseDn"; // used for tests only
|
2015-06-01 12:14:06 +00:00
|
|
|
public static final String USERS_DN = "usersDn";
|
2014-03-18 17:59:22 +00:00
|
|
|
public static final String BIND_DN = "bindDn";
|
|
|
|
public static final String BIND_CREDENTIAL = "bindCredential";
|
2014-07-18 11:54:23 +00:00
|
|
|
|
2015-05-28 17:20:31 +00:00
|
|
|
public static final String AUTH_TYPE = "authType";
|
|
|
|
public static final String AUTH_TYPE_NONE = "none";
|
|
|
|
public static final String AUTH_TYPE_SIMPLE = "simple";
|
|
|
|
|
2016-02-19 17:02:39 +00:00
|
|
|
public static final String USE_TRUSTSTORE_SPI = "useTruststoreSpi";
|
|
|
|
public static final String USE_TRUSTSTORE_ALWAYS = "always";
|
|
|
|
public static final String USE_TRUSTSTORE_NEVER = "never";
|
|
|
|
public static final String USE_TRUSTSTORE_LDAPS_ONLY = "ldapsOnly";
|
|
|
|
|
2015-05-13 06:41:55 +00:00
|
|
|
public static final String SEARCH_SCOPE = "searchScope";
|
2014-08-08 10:09:08 +00:00
|
|
|
public static final String CONNECTION_POOLING = "connectionPooling";
|
|
|
|
public static final String PAGINATION = "pagination";
|
|
|
|
|
2015-02-19 19:45:45 +00:00
|
|
|
public static final String EDIT_MODE = "editMode";
|
|
|
|
|
2014-08-08 19:01:34 +00:00
|
|
|
// Count of users processed per single transaction during sync process
|
|
|
|
public static final String BATCH_SIZE_FOR_SYNC = "batchSizeForSync";
|
|
|
|
public static final int DEFAULT_BATCH_SIZE_FOR_SYNC = 1000;
|
|
|
|
|
2015-04-07 21:10:23 +00:00
|
|
|
// Config option to specify if registrations will be synced or not
|
|
|
|
public static final String SYNC_REGISTRATIONS = "syncRegistrations";
|
|
|
|
|
2015-12-14 11:50:15 +00:00
|
|
|
// Custom user search filter
|
|
|
|
public static final String CUSTOM_USER_SEARCH_FILTER = "customUserSearchFilter";
|
|
|
|
|
2015-04-07 21:10:23 +00:00
|
|
|
// Custom attributes on UserModel, which is mapped to LDAP
|
|
|
|
public static final String LDAP_ID = "LDAP_ID";
|
|
|
|
public static final String LDAP_ENTRY_DN = "LDAP_ENTRY_DN";
|
|
|
|
|
|
|
|
// Those are forked from Picketlink
|
2015-06-05 06:51:56 +00:00
|
|
|
public static final String GIVENNAME = "givenName";
|
2015-04-07 21:10:23 +00:00
|
|
|
public static final String CN = "cn";
|
|
|
|
public static final String SN = "sn";
|
2015-05-22 13:04:28 +00:00
|
|
|
public static final String SAM_ACCOUNT_NAME = "sAMAccountName";
|
2015-04-07 21:10:23 +00:00
|
|
|
public static final String EMAIL = "mail";
|
2015-05-13 06:41:55 +00:00
|
|
|
public static final String POSTAL_CODE = "postalCode";
|
2015-06-29 17:25:27 +00:00
|
|
|
public static final String STREET = "street";
|
2015-04-07 21:10:23 +00:00
|
|
|
public static final String MEMBER = "member";
|
|
|
|
public static final String MEMBER_OF = "memberOf";
|
|
|
|
public static final String OBJECT_CLASS = "objectclass";
|
|
|
|
public static final String UID = "uid";
|
|
|
|
public static final String USER_PASSWORD_ATTRIBUTE = "userpassword";
|
2015-06-04 16:29:51 +00:00
|
|
|
public static final String GROUP = "group";
|
2015-04-07 21:10:23 +00:00
|
|
|
public static final String GROUP_OF_NAMES = "groupOfNames";
|
|
|
|
public static final String GROUP_OF_ENTRIES = "groupOfEntries";
|
|
|
|
public static final String GROUP_OF_UNIQUE_NAMES = "groupOfUniqueNames";
|
2016-01-04 22:25:40 +00:00
|
|
|
public static final String USER_ACCOUNT_CONTROL = "userAccountControl";
|
|
|
|
public static final String PWD_LAST_SET = "pwdLastSet";
|
2015-04-07 21:10:23 +00:00
|
|
|
|
|
|
|
public static final String COMMA = ",";
|
|
|
|
public static final String EQUAL = "=";
|
2015-05-13 06:41:55 +00:00
|
|
|
public static final String EMPTY_ATTRIBUTE_VALUE = " ";
|
2015-07-23 15:10:14 +00:00
|
|
|
public static final String EMPTY_MEMBER_ATTRIBUTE_VALUE = "cn=empty-membership-placeholder";
|
2015-04-07 21:10:23 +00:00
|
|
|
|
|
|
|
public static final String CUSTOM_ATTRIBUTE_ENABLED = "enabled";
|
|
|
|
public static final String CUSTOM_ATTRIBUTE_CREATE_DATE = "createDate";
|
|
|
|
public static final String CUSTOM_ATTRIBUTE_EXPIRY_DATE = "expiryDate";
|
|
|
|
public static final String ENTRY_UUID = "entryUUID";
|
|
|
|
public static final String OBJECT_GUID = "objectGUID";
|
2015-05-27 08:51:16 +00:00
|
|
|
public static final String CREATE_TIMESTAMP = "createTimestamp";
|
|
|
|
public static final String MODIFY_TIMESTAMP = "modifyTimestamp";
|
2015-06-08 10:28:59 +00:00
|
|
|
|
2015-12-14 22:21:11 +00:00
|
|
|
public static final String LDAP_MATCHING_RULE_IN_CHAIN = ":1.2.840.113556.1.4.1941:";
|
|
|
|
|
2015-06-08 10:28:59 +00:00
|
|
|
public static String getUuidAttributeName(String vendor) {
|
|
|
|
if (vendor != null) {
|
|
|
|
switch (vendor) {
|
|
|
|
case VENDOR_RHDS:
|
|
|
|
return "nsuniqueid";
|
|
|
|
case VENDOR_TIVOLI:
|
|
|
|
return "uniqueidentifier";
|
|
|
|
case VENDOR_NOVELL_EDIRECTORY:
|
|
|
|
return "guid";
|
|
|
|
case VENDOR_ACTIVE_DIRECTORY:
|
|
|
|
return OBJECT_GUID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ENTRY_UUID;
|
|
|
|
}
|
2016-02-19 17:02:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void setTruststoreSpiIfNeeded(String useTruststoreSpi, String url, Map<String, Object> env) {
|
|
|
|
boolean shouldSetTruststore;
|
|
|
|
if (useTruststoreSpi != null && useTruststoreSpi.equals(LDAPConstants.USE_TRUSTSTORE_ALWAYS)) {
|
|
|
|
shouldSetTruststore = true;
|
|
|
|
} else if (useTruststoreSpi != null && useTruststoreSpi.equals(LDAPConstants.USE_TRUSTSTORE_NEVER)) {
|
|
|
|
shouldSetTruststore = false;
|
|
|
|
} else {
|
|
|
|
shouldSetTruststore = (url != null && url.startsWith("ldaps"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldSetTruststore) {
|
|
|
|
env.put("java.naming.ldap.factory.socket", "org.keycloak.truststore.SSLSocketFactory");
|
|
|
|
}
|
|
|
|
}
|
2014-03-18 17:59:22 +00:00
|
|
|
}
|