@Override
  public Session getSession() throws PortalException, RepositoryException {
    Map<String, String> parameters = new HashMap<String, String>();

    parameters.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());
    parameters.put(SessionParameter.COMPRESSION, Boolean.TRUE.toString());

    Locale locale = LocaleUtil.getDefault();

    parameters.put(SessionParameter.LOCALE_ISO3166_COUNTRY, locale.getCountry());
    parameters.put(SessionParameter.LOCALE_ISO639_LANGUAGE, locale.getLanguage());

    String password = PrincipalThreadLocal.getPassword();

    parameters.put(SessionParameter.PASSWORD, password);

    String login = getLogin();

    parameters.put(SessionParameter.USER, login);

    parameters.put(
        SessionParameter.WEBSERVICES_ACL_SERVICE, getTypeSettingsValue(_WEBSERVICES_ACL_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_DISCOVERY_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_DISCOVERY_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_MULTIFILING_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_MULTIFILING_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_NAVIGATION_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_NAVIGATION_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_OBJECT_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_OBJECT_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_POLICY_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_POLICY_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_RELATIONSHIP_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_REPOSITORY_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_REPOSITORY_SERVICE));
    parameters.put(
        SessionParameter.WEBSERVICES_VERSIONING_SERVICE,
        getTypeSettingsValue(_WEBSERVICES_VERSIONING_SERVICE));

    CMISRepositoryUtil.checkRepository(
        getRepositoryId(), parameters, getTypeSettingsProperties(), _REPOSITORY_ID);

    return CMISRepositoryUtil.createSession(parameters);
  }
  protected String getTypeSettingsValue(String typeSettingsKey) throws InvalidRepositoryException {

    UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();

    return CMISRepositoryUtil.getTypeSettingsValue(typeSettingsProperties, typeSettingsKey);
  }