Instantiates the proper security provider based on the configuration. The provider can be either "simple", "kerberos" or a canonical class name to load from the class path. Note that this will attempt to authenticate so it will throw an exception if the login failed. @param hbase_client The hbase cl
(final HBaseClient hbase_client)
| 126 | * couldn't instantiate the class. |
| 127 | */ |
| 128 | private void initSecureClientProvider(final HBaseClient hbase_client) { |
| 129 | final String mechanism = config.hasProperty(SECURITY_AUTHENTICATION_KEY) ? |
| 130 | config.getString(SECURITY_AUTHENTICATION_KEY).trim() : "simple"; |
| 131 | |
| 132 | if ("simple".equalsIgnoreCase(mechanism)) { |
| 133 | client_auth_provider = new SimpleClientAuthProvider(hbase_client); |
| 134 | use_wrap = false; |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | if ("kerberos".equalsIgnoreCase(mechanism)) { |
| 139 | client_auth_provider = new KerberosClientAuthProvider(hbase_client); |
| 140 | } else { |
| 141 | try { |
| 142 | final Class<?> clazz = Class.forName(mechanism); |
| 143 | final Constructor<?> ctor = clazz.getConstructor(HBaseClient.class); |
| 144 | client_auth_provider = (ClientAuthProvider)ctor.newInstance(hbase_client); |
| 145 | LOG.info("Successfully instantiated a security provider of type: " + |
| 146 | clazz.getCanonicalName()); |
| 147 | } catch (Exception e) { |
| 148 | throw new IllegalStateException( |
| 149 | "Failed to load specified SecureClientProvider: " + mechanism, e); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | final String qop = parseQOP(); |
| 154 | use_wrap = qop != null && !"auth".equalsIgnoreCase(qop); |
| 155 | |
| 156 | final Map<String, String> props = new HashMap<String, String>(2); |
| 157 | props.put(Sasl.QOP, parseQOP()); |
| 158 | props.put(Sasl.SERVER_AUTH, "true"); |
| 159 | |
| 160 | sasl_client = client_auth_provider.newSaslClient(host_ip, props); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Helper that checks to see if we should encrypt the packets between HBase |
no test coverage detected