MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / initSecureClientProvider

Method initSecureClientProvider

src/SecureRpcHelper.java:128–161  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

SecureRpcHelperMethod · 0.95

Calls 5

parseQOPMethod · 0.95
putMethod · 0.80
hasPropertyMethod · 0.45
getStringMethod · 0.45
newSaslClientMethod · 0.45

Tested by

no test coverage detected