~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/bindings/javahl/native/RevpropTable.cpp

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * @copyright
3
 
 * ====================================================================
4
 
 *    Licensed to the Apache Software Foundation (ASF) under one
5
 
 *    or more contributor license agreements.  See the NOTICE file
6
 
 *    distributed with this work for additional information
7
 
 *    regarding copyright ownership.  The ASF licenses this file
8
 
 *    to you under the Apache License, Version 2.0 (the
9
 
 *    "License"); you may not use this file except in compliance
10
 
 *    with the License.  You may obtain a copy of the License at
11
 
 *
12
 
 *      http://www.apache.org/licenses/LICENSE-2.0
13
 
 *
14
 
 *    Unless required by applicable law or agreed to in writing,
15
 
 *    software distributed under the License is distributed on an
16
 
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
 
 *    KIND, either express or implied.  See the License for the
18
 
 *    specific language governing permissions and limitations
19
 
 *    under the License.
20
 
 * ====================================================================
21
 
 * @endcopyright
22
 
 *
23
 
 * @file RevpropTable.cpp
24
 
 * @brief Implementation of the class RevpropTable
25
 
 */
26
 
 
27
 
#include "RevpropTable.h"
28
 
#include "JNIUtil.h"
29
 
#include "JNIStringHolder.h"
30
 
#include "Array.h"
31
 
#include <apr_tables.h>
32
 
#include <apr_strings.h>
33
 
#include <apr_hash.h>
34
 
#include "svn_path.h"
35
 
#include "svn_props.h"
36
 
#include <iostream>
37
 
 
38
 
RevpropTable::~RevpropTable()
39
 
{
40
 
  if (m_revpropTable != NULL)
41
 
    JNIUtil::getEnv()->DeleteLocalRef(m_revpropTable);
42
 
}
43
 
 
44
 
const apr_hash_t *RevpropTable::hash(const SVN::Pool &pool)
45
 
{
46
 
  if (m_revprops.size() == 0)
47
 
    return NULL;
48
 
 
49
 
  apr_hash_t *revprop_table = apr_hash_make(pool.getPool());
50
 
 
51
 
  std::map<std::string, std::string>::const_iterator it;
52
 
  for (it = m_revprops.begin(); it != m_revprops.end(); ++it)
53
 
    {
54
 
      const char *propname = apr_pstrdup(pool.getPool(), it->first.c_str());
55
 
      if (!svn_prop_name_is_valid(propname))
56
 
        {
57
 
          const char *msg = apr_psprintf(pool.getPool(),
58
 
                                         "Invalid property name: '%s'",
59
 
                                         propname);
60
 
          JNIUtil::throwNativeException(JAVA_PACKAGE "/ClientException", msg,
61
 
                                        NULL, SVN_ERR_CLIENT_PROPERTY_NAME);
62
 
          return NULL;
63
 
        }
64
 
 
65
 
      svn_string_t *propval = svn_string_create(it->second.c_str(),
66
 
                                                pool.getPool());
67
 
 
68
 
      apr_hash_set(revprop_table, propname, APR_HASH_KEY_STRING, propval);
69
 
    }
70
 
 
71
 
  return revprop_table;
72
 
}
73
 
 
74
 
RevpropTable::RevpropTable(jobject jrevpropTable)
75
 
{
76
 
  m_revpropTable = jrevpropTable;
77
 
 
78
 
  if (jrevpropTable != NULL)
79
 
    {
80
 
      static jmethodID keySet = 0, get = 0;
81
 
      JNIEnv *env = JNIUtil::getEnv();
82
 
 
83
 
      jclass mapClazz = env->FindClass("java/util/Map");
84
 
 
85
 
      if (keySet == 0)
86
 
        {
87
 
          keySet = env->GetMethodID(mapClazz, "keySet",
88
 
                                    "()Ljava/util/Set;");
89
 
          if (JNIUtil::isExceptionThrown())
90
 
            return;
91
 
        }
92
 
 
93
 
      jobject jkeySet = env->CallObjectMethod(jrevpropTable, keySet);
94
 
      if (JNIUtil::isExceptionThrown())
95
 
        return;
96
 
 
97
 
      if (get == 0)
98
 
        {
99
 
          get = env->GetMethodID(mapClazz, "get",
100
 
                                 "(Ljava/lang/Object;)Ljava/lang/Object;");
101
 
          if (JNIUtil::isExceptionThrown())
102
 
            return;
103
 
        }
104
 
 
105
 
      Array keyArray(jkeySet);
106
 
      std::vector<jobject> keys = keyArray.vector();
107
 
 
108
 
      for (std::vector<jobject>::const_iterator it = keys.begin();
109
 
            it < keys.end(); ++it)
110
 
        {
111
 
          JNIStringHolder propname((jstring)*it);
112
 
          if (JNIUtil::isExceptionThrown())
113
 
            return;
114
 
 
115
 
          jobject jpropval = env->CallObjectMethod(jrevpropTable, get, *it);
116
 
          if (JNIUtil::isExceptionThrown())
117
 
            return;
118
 
 
119
 
          JNIStringHolder propval((jstring)jpropval);
120
 
          if (JNIUtil::isExceptionThrown())
121
 
            return;
122
 
 
123
 
          m_revprops[std::string(static_cast<const char *>(propname))]
124
 
            = std::string(static_cast<const char *>(propval));
125
 
 
126
 
          JNIUtil::getEnv()->DeleteLocalRef(jpropval);
127
 
        }
128
 
 
129
 
      JNIUtil::getEnv()->DeleteLocalRef(jkeySet);
130
 
    }
131
 
}