use of com.bluenimble.platform.api.security.ApiConsumer.Type in project serverless by bluenimble.
the class MgmApiSpi method findConsumer.
@Override
public void findConsumer(Api api, ApiService service, ApiRequest request, ApiConsumer consumer) throws ApiAuthenticationException {
Type type = consumer.type();
if ("container".equals(request.getChannel())) {
consumer.override((ApiConsumer) request.get(ApiRequest.Consumer));
return;
}
if (!this.isSecure(service)) {
return;
}
if (!type.equals(Type.Signature)) {
throw new ApiAuthenticationException("unsupported authentication mechanism");
}
String accessKey = (String) consumer.get(ApiConsumer.Fields.AccessKey);
final JsonObject oConsumer = Json.getObject(consumers, accessKey);
if (oConsumer == null || oConsumer.isEmpty()) {
throw new ApiAuthenticationException("accessKey not found");
}
Iterator<String> keys = oConsumer.keys();
if (keys == null) {
return;
}
while (keys.hasNext()) {
String key = keys.next();
consumer.set(key, oConsumer.get(key));
}
}
Aggregations