1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 /* 21 * XSEC 22 * 23 * XSECAlgorithmMapper := Provides a table of AlgorithmHandlers 24 * Mapped by Type URI 25 * 26 * $Id: XSECAlgorithmMapper.hpp 1826034 2018-03-06 20:08:26Z scantor $ 27 * 28 */ 29 30 #ifndef XSECALGMAPPER_INCLUDE 31 #define XSECALGMAPPER_INCLUDE 32 33 // XSEC Includes 34 35 #include <xsec/framework/XSECDefs.hpp> 36 37 #include <vector> 38 39 class XSECAlgorithmHandler; 40 41 /** 42 * @ingroup internal 43 *\@{*/ 44 45 46 47 /** 48 * @brief Holder class for mapping Algorithms to Handlers 49 * 50 */ 51 52 class XSEC_EXPORT XSECAlgorithmMapper { 53 54 public: 55 56 /** @name Constructors and Destructors */ 57 //@{ 58 59 XSECAlgorithmMapper(void); 60 ~XSECAlgorithmMapper(); 61 62 //@} 63 64 /** @name Default mapping strings */ 65 //@{ 66 67 static const XMLCh s_defaultEncryptionMapping[]; 68 69 /** @name Map Methods */ 70 //@{ 71 72 /** 73 * \brief Map a URI to a handler 74 */ 75 76 const XSECAlgorithmHandler* mapURIToHandler(const XMLCh* URI) const; 77 78 //@} 79 80 /** @name Registration Methods */ 81 //@{ 82 83 /** 84 * \brief Register a new handler 85 */ 86 87 void registerHandler(const XMLCh* URI, const XSECAlgorithmHandler& handler); 88 89 /** 90 * \brief Indicate an algorithm is approved for use, implying others are not. 91 */ 92 93 void whitelistAlgorithm(const XMLCh* URI); 94 95 /** 96 * \brief Indicate an algorithm is not approved for use, implying others are. 97 */ 98 99 void blacklistAlgorithm(const XMLCh* URI); 100 101 //@} 102 103 private: 104 105 struct MapperEntry { 106 107 XMLCh* mp_uri; 108 XSECAlgorithmHandler* mp_handler; 109 110 }; 111 112 MapperEntry* findEntry(const XMLCh* URI) const; 113 114 #if defined(XSEC_NO_NAMESPACES) 115 typedef vector<MapperEntry*> MapperEntryVectorType; 116 typedef vector<XMLCh*> WhitelistVectorType; 117 #else 118 typedef std::vector<MapperEntry*> MapperEntryVectorType; 119 typedef std::vector<XMLCh*> WhitelistVectorType; 120 #endif 121 122 MapperEntryVectorType m_mapping; 123 WhitelistVectorType m_whitelist,m_blacklist; 124 }; 125 126 /*\@}*/ 127 128 #endif /* XSECALGMAPPER_INCLUDE */ 129 130