1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package au.csiro.pidclient.business;
21
22 import java.text.MessageFormat;
23
24
25
26
27
28
29
30
31
32 public class AndsPidIdentity
33 {
34
35
36
37 private String appId;
38
39
40
41
42 private String identifier;
43
44
45
46
47 private String authDomain;
48
49
50
51
52 public AndsPidIdentity()
53 {
54 }
55
56
57
58
59
60
61
62
63
64
65
66 @SuppressWarnings(value = "all")
67 public AndsPidIdentity(String appId, String identifier, String authDomain)
68 {
69 this.setAppId(appId);
70 this.setIdentifier(identifier);
71 this.setAuthDomain(authDomain);
72 }
73
74
75
76
77 public String getAppId()
78 {
79 return escape(appId);
80 }
81
82
83
84
85
86 public void setAppId(String appId)
87 {
88 this.appId = appId;
89 }
90
91
92
93
94 public String getIdentifier()
95 {
96 return escape(identifier);
97 }
98
99
100
101
102
103 public void setIdentifier(String identifier)
104 {
105 this.identifier = identifier;
106 }
107
108
109
110
111 public String getAuthDomain()
112 {
113 return escape(authDomain);
114 }
115
116
117
118
119
120 public void setAuthDomain(String authDomain)
121 {
122 this.authDomain = authDomain;
123 }
124
125
126
127
128
129
130
131
132 @SuppressWarnings(value = "all")
133 public String toXML(String methodName)
134 {
135 return MessageFormat.format("<request name=\"{0}\">"
136 + "<properties>"
137 + "<property name=\"appId\" value=\"" + this.getAppId() + "\"/>"
138 + "<property name=\"identifier\" value=\"" + this.getIdentifier() + "\"/>"
139 + "<property name=\"authDomain\" value=\"" + this.getAuthDomain() + "\"/>"
140 + "</properties>"
141 + "</request>",
142 new Object[] { methodName });
143 }
144
145
146
147
148
149
150 @Override
151 public String toString()
152 {
153 return "RequestorIdentity [appId=" + appId + ", authDomain=" + authDomain + ", identifier=" + identifier + "]";
154 }
155
156
157
158
159
160
161
162
163 public String escape(String in)
164 {
165 if(in == null)
166 {
167 return in;
168 }
169
170 StringBuffer buffer = new StringBuffer();
171 for (int i = 0; i < in.length(); i++)
172 {
173 char c = in.charAt(i);
174 if (c == '<')
175 {
176 buffer.append("<");
177 }
178 else if (c == '>')
179 {
180 buffer.append(">");
181 }
182 else if (c == '&')
183 {
184 buffer.append("&");
185 }
186 else if (c == '"')
187 {
188 buffer.append(""");
189 }
190 else if (c == '\'')
191 {
192 buffer.append("'");
193 }
194 else
195 {
196 buffer.append(c);
197 }
198 }
199 return buffer.toString();
200 }
201
202 }