Home | History | Annotate | Download | only in pairing
      1 // Copyright 2012 Google Inc. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #include "polo/pairing/pairingcontext.h"
     16 
     17 namespace polo {
     18 namespace pairing {
     19 
     20 PairingContext::PairingContext(X509 *local_certificate,
     21                                X509 *peer_certificate,
     22                                bool server)
     23     : local_certificate_(local_certificate),
     24       peer_certificate_(peer_certificate),
     25       server_(server) {
     26 }
     27 
     28 void PairingContext::set_local_certificate(X509* local_certificate) {
     29   local_certificate_ = local_certificate;
     30 }
     31 
     32 void PairingContext::set_peer_certificate(X509* peer_certificate) {
     33   peer_certificate_ = peer_certificate;
     34 }
     35 
     36 X509* PairingContext::client_certificate() const {
     37   return server_ ? peer_certificate_ : local_certificate_;
     38 }
     39 
     40 X509* PairingContext::server_certificate() const {
     41   return server_ ? local_certificate_ : peer_certificate_;
     42 }
     43 
     44 bool PairingContext::is_server() const {
     45   return server_;
     46 }
     47 
     48 bool PairingContext::is_client() const {
     49   return !server_;
     50 }
     51 
     52 }  // namespace pairing
     53 }  // namespace polo
     54