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