summaryrefslogtreecommitdiff
path: root/qpid/wcf/src/Apache/Qpid/Channel/AmqpTransportSecurity.cs
blob: b722983eadd7cf407cbfb2f84e5bb2aa858f3303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* 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.
*/

namespace Apache.Qpid.Channel
{
    /// <summary>
    /// This class is used by the AMQP Transport to set transport-level security settings for a binding
    /// </summary>
    public sealed class AmqpTransportSecurity
    {
        private AmqpCredentialType credentialType;

        // WCF frowns on unencrypted credentials on the wire, but AMQP is agnostic.
        // For interoperability, allow SSL to be turned on/off independentaly.
        private bool useSSL;

        // Allow per channel credentials, but also ease the common case where
        // credentials are shared and wish to be globally set in a config file.
        private AmqpCredential defaultCredential;

        // if true, do not look at context for ServiceModel.Description.ClientCredentials.
        // ClientCredentials will be place of choice for WCF traditionalists
        // to specify auth tokens to the AMQP server when Windows and SASL tokens
        // look the same.  At other times it makes no sense and sometimes it is
        // confusing with Message-level credentials.
        private bool ignoreEndpointClientCredentials;


        internal AmqpTransportSecurity()
        {
            this.credentialType = AmqpCredentialType.Anonymous;
            this.useSSL = true;
        }

        /// <summary>
        /// gets or sets the SASL mechanism for AMQP authentication between client and server.
        /// </summary>
        public AmqpCredentialType CredentialType
        {
            get { return this.credentialType; }

            set { this.credentialType = value; }
        }

        /// <summary>
        /// gets or sets the flag that controls the use of SSL encryption
        /// over the network connection.
        /// </summary>
        public bool UseSSL
        {
            get { return this.useSSL; }
            set { this.useSSL = value; }
        }

        /// <summary>
        /// gets the default credential object for authentication with the AMQP server.
        /// </summary>
        public AmqpCredential DefaultCredential
        {
            get { return this.defaultCredential; }
            set { this.defaultCredential = value; }
        }

        /// <summary>
        /// gets or sets the endpoint ClientCredentials search parameter.  If true,
        /// only AmqpCredential objects are searched for in the surrounding context.
        /// </summary>
        public bool IgnoreEndpointClientCredentials
        {
            get { return this.ignoreEndpointClientCredentials; }
            set { this.ignoreEndpointClientCredentials = value; }
        }

        internal AmqpTransportSecurity Clone()
        {
            AmqpTransportSecurity sec = (AmqpTransportSecurity)this.MemberwiseClone();
            if (this.defaultCredential != null)
            {
                sec.defaultCredential = this.defaultCredential.Clone();
            }

            return sec;
        }
    }
}