1
2
3
4
5
6
7
8
9
10
11 package org.mule.endpoint;
12
13 import org.mule.api.endpoint.MalformedEndpointException;
14
15 import java.net.URI;
16 import java.util.Properties;
17
18
19
20
21
22
23 public class UserInfoEndpointURIBuilder extends AbstractEndpointURIBuilder
24 {
25
26
27 protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException
28 {
29
30 if (uri.getHost() == null)
31 {
32 if (props.getProperty("address") == null)
33 {
34 throw new MalformedEndpointException(uri.toString());
35 }
36 else
37 {
38 return;
39 }
40 }
41
42
43 address = uri.getHost();
44 int a = address.indexOf(".");
45 int b = (a == -1 ? -1 : address.indexOf(".", a + 1));
46 if (b > -1)
47 {
48 address = address.substring(a + 1);
49 }
50
51 if (uri.getPort() != -1)
52 {
53
54 this.address += ":" + uri.getPort();
55 }
56
57 if (userInfo != null)
58 {
59 int x = userInfo.indexOf(":");
60 if (x > -1)
61 {
62 String user = userInfo.substring(0, x);
63 if (user.indexOf("@") > -1)
64 {
65 address = user;
66 }
67 else
68 {
69 address = user + "@" + address;
70 }
71 }
72 else
73 {
74 if (userInfo.indexOf("@") > -1)
75 {
76 address = userInfo;
77 }
78 else
79 {
80 address = userInfo + "@" + address;
81 }
82 }
83 }
84 }
85 }