geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [geode-examples] branch develop updated: Adds AuthInitialize example.
Date Thu, 19 Oct 2017 05:07:25 GMT
This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-examples.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2c69c57  Adds AuthInitialize example.
2c69c57 is described below

commit 2c69c575e31f6216fa885b9052d90adce6d7e8ae
Author: Jacob Barrett <jbarrett@pivotal.io>
AuthorDate: Thu Oct 19 05:04:53 2017 +0000

    Adds AuthInitialize example.
---
 .../Apache.Geode.Examples.AuthInitialize.csproj    | 62 ++++++++++++++++++++++
 .../ExampleAuthInitialize.cs                       | 31 +++++++++++
 .../Program.cs                                     | 34 ++++++++++++
 .../README.md                                      | 14 ++++-
 .../dotnet/Apache.Geode.Examples.Cache/Program.cs  |  5 +-
 .../dotnet/Apache.Geode.Examples.Cache/README.md   |  8 +++
 native/dotnet/Apache.Geode.Examples.sln            | 14 ++++-
 native/dotnet/README.md                            |  3 +-
 8 files changed, 166 insertions(+), 5 deletions(-)

diff --git a/native/dotnet/Apache.Geode.Examples.AuthInitialize/Apache.Geode.Examples.AuthInitialize.csproj
b/native/dotnet/Apache.Geode.Examples.AuthInitialize/Apache.Geode.Examples.AuthInitialize.csproj
new file mode 100644
index 0000000..f95ca2c
--- /dev/null
+++ b/native/dotnet/Apache.Geode.Examples.AuthInitialize/Apache.Geode.Examples.AuthInitialize.csproj
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Geode.Examples.AuthInitialize</RootNamespace>
+    <AssemblyName>Apache.Geode.Examples.AuthInitialize</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Apache.Geode">
+      <HintPath>Y:\build64\clicache\src\Debug\Apache.Geode.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="Microsoft.CSharp" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ExampleAuthInitialize.cs" />
+    <Compile Include="Program.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="README.md" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and
uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/native/dotnet/Apache.Geode.Examples.AuthInitialize/ExampleAuthInitialize.cs b/native/dotnet/Apache.Geode.Examples.AuthInitialize/ExampleAuthInitialize.cs
new file mode 100644
index 0000000..583ac23
--- /dev/null
+++ b/native/dotnet/Apache.Geode.Examples.AuthInitialize/ExampleAuthInitialize.cs
@@ -0,0 +1,31 @@
+using System;
+using Apache.Geode.Client;
+
+namespace Apache.Geode.Examples.AuthInitialize
+{
+  class ExampleAuthInitialize : IAuthInitialize
+  {
+    public ExampleAuthInitialize()
+    {
+      // TODO initialize your resources here
+      Console.Out.WriteLine("ExampleAuthInitialize::ExampleAuthInitialize called");
+    }
+
+    public void Close()
+    {
+      // TODO close your resources here
+      Console.Out.WriteLine("ExampleAuthInitialize::Close called");
+    }
+
+    public Properties<string, object> GetCredentials(Properties<string, string>
props, string server)
+    {
+      // TODO get your username and password
+      Console.Out.WriteLine("ExampleAuthInitialize::GetCredentials called");
+
+      var credentials = new Properties<string, object>();
+      credentials.Insert("username", "john");
+      credentials.Insert("password", "secret");
+      return credentials;
+    }
+  }
+}
diff --git a/native/dotnet/Apache.Geode.Examples.AuthInitialize/Program.cs b/native/dotnet/Apache.Geode.Examples.AuthInitialize/Program.cs
new file mode 100644
index 0000000..76c8772
--- /dev/null
+++ b/native/dotnet/Apache.Geode.Examples.AuthInitialize/Program.cs
@@ -0,0 +1,34 @@
+using System;
+using Apache.Geode.Client;
+
+namespace Apache.Geode.Examples.AuthInitialize
+{
+  class Program
+  {
+    static void Main(string[] args)
+    {
+      var cacheFactory = CacheFactory.CreateCacheFactory()
+          .Set("log-level", "none")
+          .SetAuthInitialize(new ExampleAuthInitialize());
+
+      var cache = cacheFactory.Create();
+      var poolFactory = cache.GetPoolFactory()
+          .AddLocator("localhost", 10334);
+      poolFactory.Create("pool", cache);
+      var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+          .SetPoolName("pool");
+      var region = regionFactory.Create<string, string>("region");
+
+      region["a"] = "1";
+      region["b"] = "2";
+
+      var a = region["a"];
+      var b = region["b"];
+
+      Console.Out.WriteLine("a = " + a);
+      Console.Out.WriteLine("b = " + b);
+
+      cache.Close();
+    }
+  }
+}
diff --git a/native/dotnet/Apache.Geode.Examples.Cache/README.md b/native/dotnet/Apache.Geode.Examples.AuthInitialize/README.md
similarity index 51%
copy from native/dotnet/Apache.Geode.Examples.Cache/README.md
copy to native/dotnet/Apache.Geode.Examples.AuthInitialize/README.md
index 167eaa4..c82ae7e 100644
--- a/native/dotnet/Apache.Geode.Examples.Cache/README.md
+++ b/native/dotnet/Apache.Geode.Examples.AuthInitialize/README.md
@@ -1,4 +1,6 @@
-# Cache Example
+# AuthInitialize Example
+This example shows how to create and register a custom `IAuthIntialize` authentivation
+handler. 
 
 ## Prerequisits
 * Install [Apache Geode](https://geode.apache.org)
@@ -11,4 +13,12 @@
   gfsh>start server --name=server
   gfsh>create region --name=region --type=PARTITION
   ```
-* Execute `Apache.Geode.Examples.Cache.exe`.
+* Execute `Apache.Geode.Examples.AuthInitialize.exe`.
+  
+  output:
+  ```
+  ExampleAuthInitialize::ExampleAuthInitialize called
+  ExampleAuthInitialize::GetCredentials called
+  a = 1
+  b = 2
+  ```
diff --git a/native/dotnet/Apache.Geode.Examples.Cache/Program.cs b/native/dotnet/Apache.Geode.Examples.Cache/Program.cs
index 52aa3a8..90cbc3f 100644
--- a/native/dotnet/Apache.Geode.Examples.Cache/Program.cs
+++ b/native/dotnet/Apache.Geode.Examples.Cache/Program.cs
@@ -24,7 +24,8 @@ namespace Apache.Geode.Examples.Cache
   {
     static void Main(string[] args)
     {
-      var cacheFactory = CacheFactory.CreateCacheFactory();
+      var cacheFactory = CacheFactory.CreateCacheFactory()
+          .Set("log-level", "none");
       var cache = cacheFactory.Create();
 
       var poolFactory = cache.GetPoolFactory()
@@ -43,6 +44,8 @@ namespace Apache.Geode.Examples.Cache
 
       Console.Out.WriteLine("a = " + a);
       Console.Out.WriteLine("b = " + b);
+
+      cache.Close();
     }
   }
 }
diff --git a/native/dotnet/Apache.Geode.Examples.Cache/README.md b/native/dotnet/Apache.Geode.Examples.Cache/README.md
index 167eaa4..eb78d5f 100644
--- a/native/dotnet/Apache.Geode.Examples.Cache/README.md
+++ b/native/dotnet/Apache.Geode.Examples.Cache/README.md
@@ -1,4 +1,6 @@
 # Cache Example
+This is a very simple example showing how to create a `Cache` using the `CacheFactory`,
+configure a `Pool` with a `PoolFactory`, and configure a `Region` with a `RegionFactory`.
 
 ## Prerequisits
 * Install [Apache Geode](https://geode.apache.org)
@@ -12,3 +14,9 @@
   gfsh>create region --name=region --type=PARTITION
   ```
 * Execute `Apache.Geode.Examples.Cache.exe`.
+  
+  output:
+  ```
+  a = 1
+  b = 2
+  ```
diff --git a/native/dotnet/Apache.Geode.Examples.sln b/native/dotnet/Apache.Geode.Examples.sln
index 88dc3e8..74295f0 100644
--- a/native/dotnet/Apache.Geode.Examples.sln
+++ b/native/dotnet/Apache.Geode.Examples.sln
@@ -1,9 +1,17 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
+
+Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 14
 VisualStudioVersion = 14.0.25420.1
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Geode.Examples.Cache", "Apache.Geode.Examples.Cache\Apache.Geode.Examples.Cache.csproj",
"{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Geode.Examples.AuthInitialize",
"Apache.Geode.Examples.AuthInitialize\Apache.Geode.Examples.AuthInitialize.csproj", "{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CB7AB243-26A9-4B20-8ED9-5D35D12F9FF3}"
+	ProjectSection(SolutionItems) = preProject
+		README.md = README.md
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|x64 = Debug|x64
@@ -14,6 +22,10 @@ Global
 		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Debug|x64.Build.0 = Debug|x64
 		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Release|x64.ActiveCfg = Release|x64
 		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Release|x64.Build.0 = Release|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Debug|x64.ActiveCfg = Debug|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Debug|x64.Build.0 = Debug|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Release|x64.ActiveCfg = Release|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/native/dotnet/README.md b/native/dotnet/README.md
index ef6c1dd..360cbba 100644
--- a/native/dotnet/README.md
+++ b/native/dotnet/README.md
@@ -4,7 +4,8 @@
 * Install [Apache Geode](https://geode.apache.org)
 * Build and install [Apache Geode Native](https://github.com/apache/geode-native)
 
-## Solution Includes
+## Examples
+* [Apache.Geode.Examples.AuthInitialize](Apache.Geode.Examples.Cache/README.md)
 * [Apache.Geode.Examples.Cache](Apache.Geode.Examples.Cache/README.md)
 
 ## Using

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message