subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1599255 - in /subversion/trunk/subversion/bindings/javahl/native: AuthnCallback.cpp AuthnCallback.hpp jniwrapper/jni_class_cache.cpp jniwrapper/jni_object.hpp
Date Mon, 02 Jun 2014 16:16:00 GMT
Author: brane
Date: Mon Jun  2 16:15:59 2014
New Revision: 1599255

URL: http://svn.apache.org/r1599255
Log:
Add native wrapper boilerplate for JavaHL's AuthnCallback
and UserPasswordCallback.

[in subversion/bindings/javahl]
* native/AuthnCallback.hpp, native/AuthnCallback.cpp: New.

* native/jniwrapper/jni_object.hpp
  (Java::ClassCache): Declare class objects for AuthnCallback & Co.
* native/jniwrapper/jni_class_cache.cpp
  (Java::ClassCache): Call initializers for AuthnCallback & Co.

Added:
    subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.cpp   (with props)
    subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.hpp   (with props)
Modified:
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp

Added: subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.cpp?rev=1599255&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.cpp (added)
+++ subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.cpp Mon Jun  2 16:15:59
2014
@@ -0,0 +1,168 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you 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.
+ * ====================================================================
+ * @endcopyright
+ */
+
+#include "jniwrapper/jni_stack.hpp"
+
+#include "AuthnCallback.hpp"
+
+namespace JavaHL {
+
+// Class JavaHL::AuthnCallback
+const char* const AuthnCallback::m_class_name =
+  JAVA_PACKAGE"/callback/AuthnCallback";
+
+::Java::MethodID AuthnCallback::m_mid_username_prompt;
+::Java::MethodID AuthnCallback::m_mid_user_password_prompt;
+::Java::MethodID AuthnCallback::m_mid_ssl_server_trust_prompt;
+::Java::MethodID AuthnCallback::m_mid_ssl_client_cert_prompt;
+::Java::MethodID AuthnCallback::m_mid_ssl_client_cert_passphrase_prompt;
+::Java::MethodID AuthnCallback::m_mid_allow_store_plaintext_password;
+::Java::MethodID AuthnCallback::m_mid_allow_store_plaintext_passphrase;
+
+void AuthnCallback::static_init(::Java::Env env)
+{
+  const jclass cls = ::Java::ClassCache::get_authn_cb();
+
+  m_mid_username_prompt =
+    env.GetMethodID(cls, "usernamePrompt",
+                    "(Ljava/lang/String;Z)"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$UsernameResult");
+
+  m_mid_user_password_prompt =
+    env.GetMethodID(cls, "userPasswordPrompt",
+                    "(Ljava/lang/String;"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$SSLServerCertFailures"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$SSLServerCertInfo"
+                    "Z)"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$SSLServerTrustResult");
+
+  m_mid_ssl_server_trust_prompt =
+    env.GetMethodID(cls, "sslServerTrustPrompt",
+                    "(Ljava/lang/String;Ljava/lang/String;Z)"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$UserPasswordResult");
+
+  m_mid_ssl_client_cert_prompt =
+    env.GetMethodID(cls, "sslClientCertPrompt",
+                    "(Ljava/lang/String;Z)"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$SSLClientCertResult");
+
+  m_mid_ssl_client_cert_passphrase_prompt =
+    env.GetMethodID(cls, "sslClientCertPassphrasePrompt",
+                    "(Ljava/lang/String;Z)"
+                    "L"JAVA_PACKAGE"/callback/AuthnCallback"
+                    "$SSLClientCertPassphraseResult");
+
+  m_mid_allow_store_plaintext_password =
+    env.GetMethodID(cls, "allowStorePlaintextPassword",
+                    "(Ljava/lang/String;)Z");
+
+  m_mid_allow_store_plaintext_passphrase =
+    env.GetMethodID(cls, "allowStorePlaintextPassphrase",
+                    "(Ljava/lang/String;)Z");
+}
+
+
+// Class JavaHL::AuthnCallback::AuthnResult
+const char* const AuthnCallback::AuthnResult::m_class_name =
+  JAVA_PACKAGE"/callback/AuthnCallback$AuthnResult";
+
+::Java::FieldID AuthnCallback::AuthnResult::m_fid_save;
+::Java::FieldID AuthnCallback::AuthnResult::m_fid_trust;
+::Java::FieldID AuthnCallback::AuthnResult::m_fid_identity;
+::Java::FieldID AuthnCallback::AuthnResult::m_fid_secret;
+
+void AuthnCallback::AuthnResult::static_init(::Java::Env env)
+{
+  const jclass cls = ::Java::ClassCache::get_authn_result();
+
+  m_fid_save = env.GetFieldID(cls, "save", "Z");
+  m_fid_trust = env.GetFieldID(cls, "trust", "Z");
+  m_fid_identity = env.GetFieldID(cls, "identity", "Ljava/lang/String;");
+  m_fid_secret = env.GetFieldID(cls, "secret", "Ljava/lang/String;");
+}
+
+
+// Class JavaHL::AuthnCallback::SSLServerCertFailures
+const char* const AuthnCallback::SSLServerCertFailures::m_class_name =
+  JAVA_PACKAGE"/callback/AuthnCallback$SSLServerCertFailures";
+
+::Java::MethodID AuthnCallback::SSLServerCertFailures::m_mid_ctor;
+
+void AuthnCallback::SSLServerCertFailures::static_init(::Java::Env env)
+{
+  const jclass cls = ::Java::ClassCache::get_authn_ssl_server_cert_failures();
+
+  m_mid_ctor = env.GetMethodID(cls, "<init>", "(I)V");
+}
+
+AuthnCallback::SSLServerCertFailures::SSLServerCertFailures(
+    ::Java::Env env, jint failures)
+  : ::Java::Object(
+      env,
+      env.NewObject(::Java::ClassCache::get_authn_ssl_server_cert_failures(),
+                    m_mid_ctor, failures))
+{}
+
+
+// Class JavaHL::AuthnCallback::SSLServerCertInfo
+const char* const AuthnCallback::SSLServerCertInfo::m_class_name =
+  JAVA_PACKAGE"/callback/AuthnCallback$SSLServerCertFailures";
+
+::Java::MethodID AuthnCallback::SSLServerCertInfo::m_mid_ctor;
+
+void AuthnCallback::SSLServerCertInfo::static_init(::Java::Env env)
+{
+  const jclass cls = ::Java::ClassCache::get_authn_ssl_server_cert_info();
+
+  m_mid_ctor = env.GetMethodID(cls, "<init>",
+                               "(Ljava/lang/String;"
+                               "Ljava/lang/String;"
+                               "Ljava/lang/String;"
+                               "Ljava/lang/String;"
+                               "Ljava/lang/String;"
+                               "Ljava/lang/String;)V");
+}
+
+AuthnCallback::SSLServerCertInfo::SSLServerCertInfo(
+    ::Java::Env env,
+    const ::Java::String& hostname,
+    const ::Java::String& fingerprint,
+    const ::Java::String& validFrom,
+    const ::Java::String& validUntil,
+    const ::Java::String& issuer,
+    const ::Java::String& der)
+  : ::Java::Object(
+      env,
+      env.NewObject(::Java::ClassCache::get_authn_ssl_server_cert_failures(),
+                    m_mid_ctor, hostname.get(), fingerprint.get(),
+                    validFrom.get(), validUntil.get(),
+                    issuer.get(), der.get()))
+{}
+
+} // namespace JavaHL

Propchange: subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.hpp?rev=1599255&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.hpp (added)
+++ subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.hpp Mon Jun  2 16:15:59
2014
@@ -0,0 +1,292 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you 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.
+ * ====================================================================
+ * @endcopyright
+ */
+
+#ifndef SVN_JAVAHL_AUTHN_CALLBACK_HPP
+#define SVN_JAVAHL_AUTHN_CALLBACK_HPP
+
+#include "svn_auth.h"
+
+#include "Pool.h"
+
+#include "jniwrapper/jni_object.hpp"
+#include "jniwrapper/jni_string.hpp"
+
+namespace JavaHL {
+
+/**
+ * Object wrapper for @c org.apache.subversion.javahl.callback.AuthnCallback.
+ *
+ * @since New in 1.9.
+ */
+class AuthnCallback : public ::Java::Object
+{
+public:
+  /**
+   * Object wrapper for @c ...AuthnCallback$AuthnResult.
+   */
+  class AuthnResult : public ::Java::Object
+  {
+  public:
+    /**
+     * Constructs a wrapper around @a jthis.
+     * The constructor does not verify the class of the wrapped object.
+     */
+    explicit AuthnResult(::Java::Env env, jobject jthis)
+      : ::Java::Object(env, jthis)
+      {}
+
+    bool save() const
+      {
+        return (0 != m_env.GetBooleanField(m_jthis, m_fid_save));
+      }
+
+    bool trust() const
+      {
+        return (0 != m_env.GetBooleanField(m_jthis, m_fid_trust));
+      }
+
+    jstring identity() const
+      {
+        return jstring(m_env.GetObjectField(m_jthis, m_fid_identity));
+      }
+
+    jstring secret() const
+      {
+        return jstring(m_env.GetObjectField(m_jthis, m_fid_secret));
+      }
+
+  private:
+    friend class ::Java::ClassCache;
+    static const char* const m_class_name;
+    static void static_init(::Java::Env env);
+
+    static ::Java::FieldID m_fid_save;
+    static ::Java::FieldID m_fid_trust;
+    static ::Java::FieldID m_fid_identity;
+    static ::Java::FieldID m_fid_secret;
+  };
+
+
+  /**
+   * Object wrapper for @c ...AuthnCallback$SSLServerCertFailures.
+   */
+  class SSLServerCertFailures : public ::Java::Object
+  {
+  public:
+    /**
+     * Creates and initializes a wrapped object;
+     * @a failures is a set of flags.
+     */
+    explicit SSLServerCertFailures(::Java::Env env, jint failures);
+
+  private:
+    friend class ::Java::ClassCache;
+    static const char* const m_class_name;
+    static void static_init(::Java::Env env);
+
+    static ::Java::MethodID m_mid_ctor;
+  };
+
+
+  /**
+   * Object wrapper for @c ...AuthnCallback$SSLServerCertInfo.
+   */
+  class SSLServerCertInfo : public ::Java::Object
+  {
+  public:
+    /**
+     * Creates and initializes a wrapped object;
+     */
+    explicit SSLServerCertInfo(::Java::Env env,
+                               const ::Java::String& hostname,
+                               const ::Java::String& fingerprint,
+                               const ::Java::String& validFrom,
+                               const ::Java::String& validUntil,
+                               const ::Java::String& issuer,
+                               const ::Java::String& der);
+
+  private:
+    friend class ::Java::ClassCache;
+    static const char* const m_class_name;
+    static void static_init(::Java::Env env);
+
+    static ::Java::MethodID m_mid_ctor;
+  };
+
+
+  /**
+   * Constructs a wrapper around @a jthis.
+   * The constructor does not verify the class of the wrapped object.
+   */
+  explicit AuthnCallback(::Java::Env env, jobject jthis)
+    : ::Java::Object(env, jthis)
+    {}
+
+  /**
+   * Invokes the Java method AuthnCallback.usernamePrompt().
+   */
+  jobject username_prompt(const ::Java::String& realm, bool may_save);
+
+
+  /**
+   * Invokes the Java method AuthnCallback.userPasswordPrompt().
+   */
+  jobject user_password_prompt(const ::Java::String& realm,
+                               const ::Java::String& username,
+                               bool may_save);
+
+  /**
+   * Invokes the Java method AuthnCallback.sslServerTrustPrompt().
+   */
+  jobject ssl_server_trust_prompt(const ::Java::String& realm,
+                                  const SSLServerCertFailures& failures,
+                                  const SSLServerCertInfo& info,
+                                  bool may_save);
+
+  /**
+   * Invokes the Java method AuthnCallback.sslClientCertPrompt().
+   */
+  jobject ssl_client_cert_prompt(const ::Java::String& realm, bool may_save);
+
+  /**
+   * Invokes the Java method AuthnCallback.sslClientCertPassphrasePrompt().
+   */
+  jobject ssl_client_cert_passphrase_prompt(const ::Java::String&
+                                            realm, bool may_save);
+
+  /**
+   * Invokes the Java method AuthnCallback.allowStorePlaintextPassword().
+   */
+  bool allow_store_plaintext_password(const ::Java::String& realm);
+
+  /**
+   * Invokes the Java method AuthnCallback.allowStorePlaintextPassphrase().
+   */
+  bool allow_store_plaintext_passphrase(const ::Java::String& realm);
+
+private:
+  friend class ::Java::ClassCache;
+  static const char* const m_class_name;
+  static void static_init(::Java::Env env);
+
+  static ::Java::MethodID m_mid_username_prompt;
+  static ::Java::MethodID m_mid_user_password_prompt;
+  static ::Java::MethodID m_mid_ssl_server_trust_prompt;
+  static ::Java::MethodID m_mid_ssl_client_cert_prompt;
+  static ::Java::MethodID m_mid_ssl_client_cert_passphrase_prompt;
+  static ::Java::MethodID m_mid_allow_store_plaintext_password;
+  static ::Java::MethodID m_mid_allow_store_plaintext_passphrase;
+};
+
+
+/**
+ * Object wrapper for the deprecated interface
+ * @c org.apache.subversion.javahl.callback.UserPasswordCallback.
+ *
+ * @since New in 1.9.
+ */
+class UserPasswordCallback : public ::Java::Object
+{
+public:
+  /**
+   * Constructs a wrapper around @a jthis.
+   * The constructor does not verify the class of the wrapped object.
+   */
+  explicit UserPasswordCallback(::Java::Env env, jobject jthis)
+    : ::Java::Object(env, jthis)
+    {}
+
+  /**
+   * Invokes the Java method UserPasswordCallback.askTrustSSLServer().
+   */
+  jint ask_trust_ssl_server(const ::Java::String& info,
+                            bool allow_permanently);
+
+  /**
+   * Invokes the Java method UserPasswordCallback.prompt().
+   */
+  bool prompt(const ::Java::String& realm,
+              const ::Java::String& username);
+
+  /**
+   * Invokes the Java method UserPasswordCallback.askYesNo().
+   */
+  bool ask_yes_no(const ::Java::String& realm,
+                  const ::Java::String& question,
+                  bool yes_is_default);
+
+  /**
+   * Invokes the Java method UserPasswordCallback.askQuestion().
+   */
+  jstring ask_question(const ::Java::String& realm,
+                       const ::Java::String& question,
+                       bool show_answer);
+
+  /**
+   * Invokes the Java method UserPasswordCallback.getUsername().
+   */
+  jstring get_username();
+
+  /**
+   * Invokes the Java method UserPasswordCallback.getPassword().
+   */
+  jstring get_password();
+
+  /**
+   * Invokes the Java method UserPasswordCallback.prompt().
+   */
+  bool prompt(const ::Java::String& realm,
+              const ::Java::String& username,
+              bool may_save);
+
+  /**
+   * Invokes the Java method UserPasswordCallback.askQuestion().
+   */
+  jstring ask_question(const ::Java::String& realm,
+                       const ::Java::String& question,
+                       bool show_answer, bool may_save);
+
+  /**
+   * Invokes the Java method UserPasswordCallback.userAllowedSave().
+   */
+  bool user_allowed_save();
+
+private:
+  friend class ::Java::ClassCache;
+  static const char* const m_class_name;
+  static void static_init(::Java::Env env);
+
+  static ::Java::MethodID m_mid_ask_trust_ssl_server;
+  static ::Java::MethodID m_mid_prompt_2arg;
+  static ::Java::MethodID m_mid_ask_yes_no;
+  static ::Java::MethodID m_mid_ask_question_3arg;
+  static ::Java::MethodID m_mid_get_username;
+  static ::Java::MethodID m_mid_get_password;
+  static ::Java::MethodID m_mid_prompt;
+  static ::Java::MethodID m_mid_ask_question;
+  static ::Java::MethodID m_mid_user_allowed_save;
+};
+
+} // namespace JavaHL
+
+#endif // SVN_JAVAHL_AUTHN_CALLBACK_HPP

Propchange: subversion/trunk/subversion/bindings/javahl/native/AuthnCallback.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp?rev=1599255&r1=1599254&r2=1599255&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp Mon
Jun  2 16:15:59 2014
@@ -36,6 +36,7 @@
 #include "jni_string_map.hpp"
 
 #include "../SubversionException.hpp"
+#include "../AuthnCallback.hpp"
 #include "../ExternalItem.hpp"
 #include "../EditorCallbacks.hpp"
 
@@ -120,6 +121,18 @@ ClassCache::ClassCache(Env env)
 
     SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(subversion_exception,
                                            ::JavaHL::SubversionException),
+
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(authn_cb,
+                                           ::JavaHL::AuthnCallback),
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(
+        authn_result, ::JavaHL::AuthnCallback::AuthnResult),
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(
+        authn_ssl_server_cert_failures,
+        ::JavaHL::AuthnCallback::SSLServerCertFailures),
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(
+        authn_ssl_server_cert_info,
+        ::JavaHL::AuthnCallback::SSLServerCertInfo),
+
     SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(external_item,
                                            ::JavaHL::ExternalItem),
     SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(editor_provide_base_cb,
@@ -156,7 +169,13 @@ ClassCache::ClassCache(Env env)
   ByteChannel::ByteBuffer::static_init(env);
 
   // no-op: ::JavaHL::SubversionException::static_init(env);
+  ::JavaHL::AuthnCallback::static_init(env);
+  ::JavaHL::AuthnCallback::AuthnResult::static_init(env);
+  ::JavaHL::AuthnCallback::SSLServerCertFailures::static_init(env);
+  ::JavaHL::AuthnCallback::SSLServerCertInfo::static_init(env);
+
   ::JavaHL::ExternalItem::static_init(env);
+
   ::JavaHL::ProvideBaseCallback::static_init(env);
   ::JavaHL::ProvideBaseCallback::ReturnValue::static_init(env);
   ::JavaHL::ProvidePropsCallback::static_init(env);

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp?rev=1599255&r1=1599254&r2=1599255&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp Mon Jun 
2 16:15:59 2014
@@ -124,6 +124,7 @@ private:
  * cache should therefore be kept to a reasonable minimum.
  *
  * @since New in 1.9.
+ * @todo ### Change implementation to load classes at first use.
  */
 class ClassCache
 {
@@ -161,6 +162,12 @@ class ClassCache
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(byte_buffer);
 
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(subversion_exception);
+
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(authn_cb);
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(authn_result);
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(authn_ssl_server_cert_failures);
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(authn_ssl_server_cert_info);
+
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(external_item);
 
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(editor_provide_base_cb);



Mime
View raw message