Skip to content

Commit 853e7bc

Browse files
Rename Secure->Config and rework demo (#279)
1 parent 122f9fe commit 853e7bc

File tree

18 files changed

+157
-102
lines changed

18 files changed

+157
-102
lines changed

cpp/Ice/config/Client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ main(int argc, char* argv[])
2323
}
2424

2525
// Create an Ice communicator to initialize the Ice runtime. The communicator gets its configuration properties from
26-
// file "config.server". The communicator initialization also parses the command-line options to find and set
27-
// additional properties.
26+
// file config.client in the client's current working directory. The communicator initialization also parses the
27+
// command-line options to find and set additional properties.
2828
const Ice::CommunicatorHolder communicatorHolder{argc, argv, "config.client"};
2929
const Ice::CommunicatorPtr& communicator = communicatorHolder.communicator();
3030

31-
// We create a Greeter proxy using the value of the "Greeter.Proxy" property in config.client.
31+
// We create a Greeter proxy using the value of the Greeter.Proxy property in config.client.
3232
// It's nullopt if the property is not set.
3333
std::optional<VisitorCenter::GreeterPrx> greeter =
3434
communicator->propertyToProxy<VisitorCenter::GreeterPrx>("Greeter.Proxy");

cpp/Ice/config/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Config
22

3-
This demo shows how to configure your client and server applications using Ice configuration
4-
files.
3+
This demo shows how to configure your client and server applications using Ice configuration files.
54

65
To build the demo run:
76

cpp/Ice/config/Server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ main(int argc, char* argv[])
1616
Ice::CtrlCHandler ctrlCHandler;
1717

1818
// Create an Ice communicator to initialize the Ice runtime. The communicator gets its configuration properties from
19-
// file "config.server". The communicator initialization also parses the command-line options to find and set
20-
// additional properties.
19+
// file config.server, in the server's current working directory. The communicator initialization also parses the
20+
// command-line options to find and set additional properties.
2121
const Ice::CommunicatorHolder communicatorHolder{argc, argv, "config.server"};
2222
const Ice::CommunicatorPtr& communicator = communicatorHolder.communicator();
2323

File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) ZeroC, Inc.
2+
3+
using System.Diagnostics;
4+
5+
// Slice module VisitorCenter in Greeter.ice maps to C# namespace VisitorCenter.
6+
using VisitorCenter;
7+
8+
// Create an Ice communicator to initialize the Ice runtime. The communicator gets its configuration properties from
9+
// file config.client in the client's current working directory. The communicator initialization also parses the
10+
// command-line options to find and set additional properties.
11+
using Ice.Communicator communicator = Ice.Util.initialize(ref args, "config.client");
12+
13+
// We create a Greeter proxy using the value of the Greeter.Proxy property in config.client.
14+
// It's null if the property is not set.
15+
GreeterPrx? greeter = GreeterPrxHelper.uncheckedCast(communicator.propertyToProxy("Greeter.Proxy"));
16+
Debug.Assert(greeter is not null);
17+
18+
// Send a request to the remote object and get the response.
19+
string greeting = await greeter.GreetAsync(Environment.UserName);
20+
21+
Console.WriteLine(greeting);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Application-specific configuration
3+
#
4+
5+
# The address of the target object. `default` is replaced by the value of Ice.Default.Protocol.
6+
Greeter.Proxy=greeter:default -h localhost -p 4061
7+
8+
#
9+
# Ice configuration
10+
#
11+
12+
# The transport protocol to use for Ice communications when `default` is specified.
13+
# You can set it to tcp, ssl, ws, or wss. Leaving it unset is equivalent to setting it to tcp.
14+
# Make sure you use the same value in config.client and config.server.
15+
Ice.Default.Protocol=ssl
16+
17+
#
18+
# IceSSL configuration
19+
#
20+
21+
# The directory where the application finds certificates and other files.
22+
IceSSL.DefaultDir=../../../../certs
23+
24+
# The certificate authority file.
25+
IceSSL.CAs=cacert.pem
26+
27+
# The client's certificate file.
28+
IceSSL.CertFile=client.p12
29+
30+
# TODO: switch to password-less certificates
31+
IceSSL.Password=password
32+
33+
# Turn on security logging/tracing.
34+
# IceSSL.Trace.Security=1
File renamed without changes.

csharp/Ice/Config/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Config
2+
3+
This demo shows how to configure your client and server applications using Ice configuration files.
4+
5+
To build the demo run:
6+
7+
``` shell
8+
dotnet build
9+
```
10+
11+
First start the Server program:
12+
13+
```shell
14+
cd Server
15+
dotnet run
16+
```
17+
18+
In a separate terminal, start the Client program:
19+
20+
```shell
21+
cd Client
22+
dotnet run
23+
```
24+
25+
You can pass `--Ice` command-line options to set additional properties or override the properties set in the
26+
configuration file. For example:
27+
28+
```shell
29+
cd Server
30+
dotnet run --Ice.Default.Protocol=ws
31+
```
32+
33+
```shell
34+
cd Client
35+
dotnet run --Ice.Default.Protocol=ws --Ice.Trace.Network=2
36+
```

csharp/Ice/Secure/Server/Chatbot.cs renamed to csharp/Ice/Config/Server/Chatbot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using VisitorCenter;
44

5-
namespace SecureServer;
5+
namespace ConfigServer;
66

77
/// <summary>A Chatbot is an Ice servant that implements Slice interface Greeter.</summary>
88
internal class Chatbot : GreeterDisp_
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) ZeroC, Inc.
2+
3+
using ConfigServer;
4+
5+
// Create an Ice communicator to initialize the Ice runtime. The communicator gets its configuration properties from
6+
// file config.server, in the server's current working directory. The communicator initialization also parses the
7+
// command-line options to find and set additional properties.
8+
using Ice.Communicator communicator = Ice.Util.initialize(ref args, "config.server");
9+
10+
// Create an object adapter that listens for incoming requests and dispatches them to servants.
11+
// This adapter is configured through the GreeterAdapter.* properties in config.server.
12+
Ice.ObjectAdapter adapter = communicator.createObjectAdapter("GreeterAdapter");
13+
14+
// Register the Chatbot servant with the adapter.
15+
adapter.add(new Chatbot(), Ice.Util.stringToIdentity("greeter"));
16+
17+
// Start dispatching requests.
18+
adapter.activate();
19+
20+
// Ice.Trace.Network=1 or greater shows on which interface(s) and port(s) the server is listening.
21+
22+
// Wait until the user presses Ctrl+C.
23+
await CancelKeyPressed;
24+
Console.WriteLine("Caught Ctrl+C, exiting...");

0 commit comments

Comments
 (0)