alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-2016 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.cordmcast; |
| 17 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 18 | import com.fasterxml.jackson.databind.node.ObjectNode; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 19 | import com.google.common.collect.Maps; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 20 | import com.sun.jersey.api.client.Client; |
| 21 | import com.sun.jersey.api.client.WebResource; |
| 22 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Activate; |
| 24 | import org.apache.felix.scr.annotations.Component; |
| 25 | import org.apache.felix.scr.annotations.Deactivate; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 26 | import org.apache.felix.scr.annotations.Modified; |
| 27 | import org.apache.felix.scr.annotations.Property; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 28 | import org.apache.felix.scr.annotations.Reference; |
| 29 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 30 | import org.onlab.packet.Ethernet; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 31 | import org.onlab.packet.IpAddress; |
| 32 | import org.onlab.packet.VlanId; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 33 | import org.onosproject.cfg.ComponentConfigService; |
| 34 | import org.onosproject.codec.CodecService; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 35 | import org.onosproject.core.ApplicationId; |
| 36 | import org.onosproject.core.CoreService; |
| 37 | import org.onosproject.net.ConnectPoint; |
| 38 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 39 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 40 | import org.onosproject.net.flow.TrafficSelector; |
| 41 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
| 42 | import org.onosproject.net.flowobjective.DefaultNextObjective; |
| 43 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 44 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 45 | import org.onosproject.net.flowobjective.NextObjective; |
| 46 | import org.onosproject.net.flowobjective.Objective; |
| 47 | import org.onosproject.net.flowobjective.ObjectiveContext; |
| 48 | import org.onosproject.net.flowobjective.ObjectiveError; |
| 49 | import org.onosproject.net.group.GroupService; |
| 50 | import org.onosproject.net.mcast.McastEvent; |
| 51 | import org.onosproject.net.mcast.McastListener; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 52 | import org.onosproject.net.mcast.McastRoute; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 53 | import org.onosproject.net.mcast.McastRouteInfo; |
| 54 | import org.onosproject.net.mcast.MulticastRouteService; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 55 | import org.onosproject.rest.AbstractWebResource; |
| 56 | import org.osgi.service.component.ComponentContext; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 57 | import org.slf4j.Logger; |
| 58 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 59 | import java.util.Dictionary; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 60 | import java.util.Map; |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 61 | import java.util.Properties; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 62 | import java.util.concurrent.atomic.AtomicBoolean; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 63 | import java.util.concurrent.atomic.AtomicInteger; |
| 64 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 65 | import static com.google.common.base.Strings.isNullOrEmpty; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 66 | import static com.google.common.net.MediaType.JSON_UTF_8; |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 67 | import static org.onlab.util.Tools.get; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 68 | import static org.slf4j.LoggerFactory.getLogger; |
| 69 | |
| 70 | /** |
| 71 | * CORD multicast provisoning application. Operates by listening to |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 72 | * events on the multicast rib and provisioning groups to program multicast |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 73 | * flows on the dataplane. |
| 74 | */ |
| 75 | @Component(immediate = true) |
| 76 | public class CordMcast { |
| 77 | |
| 78 | private static final int DEFAULT_PRIORITY = 1000; |
| 79 | private static final short DEFAULT_MCAST_VLAN = 4000; |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 80 | private static final String DEFAULT_SYNC_HOST = "10.90.0.8:8181"; |
| 81 | private static final String DEFAULT_USER = "karaf"; |
| 82 | private static final String DEFAULT_PASSWORD = "karaf"; |
| 83 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 84 | private final Logger log = getLogger(getClass()); |
| 85 | |
| 86 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 87 | protected MulticastRouteService mcastService; |
| 88 | |
| 89 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 90 | protected GroupService groupService; |
| 91 | |
| 92 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 93 | protected FlowObjectiveService flowObjectiveService; |
| 94 | |
| 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 96 | protected CoreService coreService; |
| 97 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 98 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 99 | protected CodecService codecService; |
| 100 | |
| 101 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 102 | protected ComponentConfigService componentConfigService; |
| 103 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 104 | protected McastListener listener = new InternalMulticastListener(); |
| 105 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 106 | //TODO: move this to a ec map |
| 107 | private Map<IpAddress, Integer> groups = Maps.newConcurrentMap(); |
| 108 | |
| 109 | //TODO: move this to distributed atomic long |
| 110 | private AtomicInteger channels = new AtomicInteger(0); |
| 111 | |
| 112 | private ApplicationId appId; |
| 113 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 114 | @Property(name = "mcastVlan", intValue = DEFAULT_MCAST_VLAN, |
| 115 | label = "VLAN for multicast traffic") |
| 116 | private int mcastVlan = DEFAULT_MCAST_VLAN; |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 117 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 118 | @Property(name = "vlanEnabled", boolValue = false, |
| 119 | label = "Use vlan for multicast traffic") |
| 120 | private boolean vlanEnabled = false; |
| 121 | |
| 122 | @Property(name = "priority", intValue = DEFAULT_PRIORITY, |
| 123 | label = "Priority for multicast rules") |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 124 | private int priority = DEFAULT_PRIORITY; |
| 125 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 126 | @Property(name = "syncHost", value = DEFAULT_SYNC_HOST, |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 127 | label = "host:port to synchronize routes to") |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 128 | private String syncHost = DEFAULT_SYNC_HOST; |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 129 | |
| 130 | @Property(name = "username", value = DEFAULT_USER, |
| 131 | label = "Username for REST password authentication") |
| 132 | private String user = DEFAULT_USER; |
| 133 | |
| 134 | @Property(name = "password", value = DEFAULT_PASSWORD, |
| 135 | label = "Password for REST authentication") |
| 136 | private String password = DEFAULT_PASSWORD; |
| 137 | |
| 138 | private String fabricOnosUrl; |
| 139 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 140 | @Activate |
| 141 | public void activate() { |
| 142 | appId = coreService.registerApplication("org.onosproject.cordmcast"); |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 143 | componentConfigService.registerProperties(getClass()); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 144 | mcastService.addListener(listener); |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 145 | |
| 146 | fabricOnosUrl = "http://" + syncHost + "/onos/v1/mcast"; |
| 147 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 148 | //TODO: obtain all existing mcast routes |
| 149 | log.info("Started"); |
| 150 | } |
| 151 | |
| 152 | @Deactivate |
| 153 | public void deactivate() { |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 154 | componentConfigService.unregisterProperties(getClass(), true); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 155 | mcastService.removeListener(listener); |
| 156 | log.info("Stopped"); |
| 157 | } |
| 158 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 159 | @Modified |
| 160 | public void modified(ComponentContext context) { |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 161 | Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties(); |
| 162 | |
| 163 | |
| 164 | try { |
| 165 | String s = get(properties, "username"); |
| 166 | user = isNullOrEmpty(s) ? DEFAULT_USER : s.trim(); |
| 167 | |
| 168 | s = get(properties, "password"); |
| 169 | password = isNullOrEmpty(s) ? DEFAULT_PASSWORD : s.trim(); |
| 170 | |
| 171 | s = get(properties, "mcastVlan"); |
| 172 | mcastVlan = isNullOrEmpty(s) ? DEFAULT_MCAST_VLAN : Short.parseShort(s.trim()); |
| 173 | |
| 174 | s = get(properties, "vlanEnabled"); |
| 175 | vlanEnabled = isNullOrEmpty(s) || Boolean.parseBoolean(s.trim()); |
| 176 | |
| 177 | s = get(properties, "priority"); |
| 178 | priority = isNullOrEmpty(s) ? DEFAULT_PRIORITY : Integer.parseInt(s.trim()); |
| 179 | |
| 180 | s = get(properties, syncHost); |
| 181 | syncHost = isNullOrEmpty(s) ? DEFAULT_SYNC_HOST : s.trim(); |
| 182 | } catch (Exception e) { |
| 183 | user = DEFAULT_USER; |
| 184 | password = DEFAULT_PASSWORD; |
| 185 | syncHost = DEFAULT_SYNC_HOST; |
| 186 | mcastVlan = DEFAULT_MCAST_VLAN; |
| 187 | vlanEnabled = false; |
| 188 | priority = DEFAULT_PRIORITY; |
| 189 | } |
| 190 | |
| 191 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 192 | } |
| 193 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 194 | private class InternalMulticastListener implements McastListener { |
| 195 | @Override |
| 196 | public void event(McastEvent event) { |
| 197 | switch (event.type()) { |
| 198 | case ROUTE_ADDED: |
| 199 | break; |
| 200 | case ROUTE_REMOVED: |
| 201 | break; |
| 202 | case SOURCE_ADDED: |
| 203 | break; |
| 204 | case SINK_ADDED: |
| 205 | provisionGroup(event.subject()); |
| 206 | break; |
| 207 | case SINK_REMOVED: |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 208 | unprovisionGroup(event.subject()); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 209 | break; |
| 210 | default: |
| 211 | log.warn("Unknown mcast event {}", event.type()); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 216 | private void unprovisionGroup(McastRouteInfo info) { |
| 217 | if (!info.sink().isPresent()) { |
| 218 | log.warn("No sink given after sink removed event: {}", info); |
| 219 | return; |
| 220 | } |
| 221 | ConnectPoint loc = info.sink().get(); |
| 222 | |
| 223 | NextObjective next = DefaultNextObjective.builder() |
| 224 | .fromApp(appId) |
| 225 | .addTreatment(DefaultTrafficTreatment.builder().setOutput(loc.port()).build()) |
| 226 | .withType(NextObjective.Type.BROADCAST) |
| 227 | .withId(groups.get(info.route().group())) |
| 228 | .removeFromExisting(new ObjectiveContext() { |
| 229 | @Override |
| 230 | public void onSuccess(Objective objective) { |
| 231 | //TODO: change to debug |
| 232 | log.info("Next Objective {} installed", objective.id()); |
| 233 | } |
| 234 | |
| 235 | @Override |
| 236 | public void onError(Objective objective, ObjectiveError error) { |
| 237 | //TODO: change to debug |
| 238 | log.info("Next Objective {} failed, because {}", |
| 239 | objective.id(), |
| 240 | error); |
| 241 | } |
| 242 | }); |
| 243 | |
| 244 | flowObjectiveService.next(loc.deviceId(), next); |
| 245 | |
| 246 | |
| 247 | } |
| 248 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 249 | private void provisionGroup(McastRouteInfo info) { |
| 250 | if (!info.sink().isPresent()) { |
| 251 | log.warn("No sink given after sink added event: {}", info); |
| 252 | return; |
| 253 | } |
| 254 | ConnectPoint loc = info.sink().get(); |
| 255 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 256 | final AtomicBoolean sync = new AtomicBoolean(false); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 257 | |
| 258 | Integer nextId = groups.computeIfAbsent(info.route().group(), (g) -> { |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 259 | Integer id = allocateId(); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 260 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 261 | NextObjective next = DefaultNextObjective.builder() |
| 262 | .fromApp(appId) |
| 263 | .addTreatment(DefaultTrafficTreatment.builder().setOutput(loc.port()).build()) |
| 264 | .withType(NextObjective.Type.BROADCAST) |
| 265 | .withId(id) |
| 266 | .add(new ObjectiveContext() { |
| 267 | @Override |
| 268 | public void onSuccess(Objective objective) { |
| 269 | //TODO: change to debug |
| 270 | log.info("Next Objective {} installed", objective.id()); |
| 271 | } |
| 272 | |
| 273 | @Override |
| 274 | public void onError(Objective objective, ObjectiveError error) { |
| 275 | //TODO: change to debug |
| 276 | log.info("Next Objective {} failed, because {}", |
| 277 | objective.id(), |
| 278 | error); |
| 279 | } |
| 280 | }); |
| 281 | |
| 282 | flowObjectiveService.next(loc.deviceId(), next); |
| 283 | |
| 284 | TrafficSelector.Builder mcast = DefaultTrafficSelector.builder() |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 285 | .matchEthType(Ethernet.TYPE_IPV4) |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 286 | .matchIPDst(g.toIpPrefix()); |
| 287 | |
| 288 | |
| 289 | if (vlanEnabled) { |
| 290 | mcast.matchVlanId(VlanId.vlanId((short) mcastVlan)); |
| 291 | } |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 292 | |
| 293 | |
| 294 | ForwardingObjective fwd = DefaultForwardingObjective.builder() |
| 295 | .fromApp(appId) |
| 296 | .nextStep(id) |
| 297 | .makePermanent() |
| 298 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
| 299 | .withPriority(priority) |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 300 | .withSelector(mcast.build()) |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 301 | .add(new ObjectiveContext() { |
| 302 | @Override |
| 303 | public void onSuccess(Objective objective) { |
| 304 | //TODO: change to debug |
| 305 | log.info("Forwarding objective installed {}", objective); |
| 306 | } |
| 307 | |
| 308 | @Override |
| 309 | public void onError(Objective objective, ObjectiveError error) { |
| 310 | //TODO: change to debug |
| 311 | log.info("Forwarding objective failed {}", objective); |
| 312 | } |
| 313 | }); |
| 314 | |
| 315 | flowObjectiveService.forward(loc.deviceId(), fwd); |
| 316 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 317 | sync.set(true); |
| 318 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 319 | return id; |
| 320 | }); |
| 321 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 322 | if (!sync.get()) { |
| 323 | NextObjective next = DefaultNextObjective.builder() |
| 324 | .fromApp(appId) |
| 325 | .addTreatment(DefaultTrafficTreatment.builder().setOutput(loc.port()).build()) |
| 326 | .withType(NextObjective.Type.BROADCAST) |
| 327 | .withId(nextId) |
| 328 | .addToExisting(new ObjectiveContext() { |
| 329 | @Override |
| 330 | public void onSuccess(Objective objective) { |
| 331 | //TODO: change to debug |
| 332 | log.info("Next Objective {} installed", objective.id()); |
| 333 | } |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 334 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 335 | @Override |
| 336 | public void onError(Objective objective, ObjectiveError error) { |
| 337 | //TODO: change to debug |
| 338 | log.info("Next Objective {} failed, because {}", |
| 339 | objective.id(), |
| 340 | error); |
| 341 | } |
| 342 | }); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 343 | |
alshabib | fc1cb03 | 2016-02-17 15:37:56 -0800 | [diff] [blame^] | 344 | flowObjectiveService.next(loc.deviceId(), next); |
| 345 | } |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 346 | |
| 347 | if (sync.get()) { |
| 348 | syncRoute(info); |
| 349 | } |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 352 | private void syncRoute(McastRouteInfo info) { |
| 353 | if (syncHost == null) { |
| 354 | log.warn("No host configured for synchronization; route will be dropped"); |
| 355 | return; |
| 356 | } |
| 357 | |
| 358 | log.debug("Sending route to other ONOS: {}", info.route()); |
| 359 | |
| 360 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); |
| 361 | |
| 362 | ObjectNode json = codecService.getCodec(McastRoute.class) |
| 363 | .encode(info.route(), new AbstractWebResource()); |
| 364 | builder.post(json.toString()); |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 365 | } |
Jonathan Hart | 2827164 | 2016-02-10 16:13:54 -0800 | [diff] [blame] | 366 | |
| 367 | private Integer allocateId() { |
| 368 | return channels.getAndIncrement(); |
| 369 | } |
| 370 | |
| 371 | private WebResource.Builder getClientBuilder(String uri) { |
| 372 | Client client = Client.create(); |
| 373 | client.addFilter(new HTTPBasicAuthFilter(user, password)); |
| 374 | WebResource resource = client.resource(uri); |
| 375 | return resource.accept(JSON_UTF_8.toString()) |
| 376 | .type(JSON_UTF_8.toString()); |
| 377 | } |
| 378 | |
alshabib | 3b1eadc | 2016-02-01 17:57:00 -0800 | [diff] [blame] | 379 | } |