/
HelloImpl.java
140 lines (124 loc) · 4.18 KB
/
HelloImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Copyright (c) 2007, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
/*
* $Id$
*/
package com.sun.ts.tests.jaxws.sharedwebservices.hellosecureservice;
import com.sun.ts.lib.util.*;
import com.sun.ts.lib.porting.*;
import com.sun.ts.tests.jaxws.common.*;
import jakarta.xml.ws.*;
import jakarta.xml.ws.handler.*;
import jakarta.xml.ws.wsaddressing.W3CEndpointReference;
import java.security.Principal;
// Service Implementation Class - as outlined in JAX-WS Specification
import jakarta.jws.WebService;
import jakarta.annotation.Resource;
@WebService(portName = "HelloPort", serviceName = "HelloService", targetNamespace = "http://helloservice.org/wsdl", wsdlLocation = "WEB-INF/wsdl/WSHelloSecureService.wsdl", endpointInterface = "com.sun.ts.tests.jaxws.sharedwebservices.hellosecureservice.Hello")
public class HelloImpl implements Hello {
@Resource
protected WebServiceContext wsContext;
public String hello(String s) {
return "Hello, " + s + "!";
}
public boolean getMessageContextTest() {
if (wsContext == null)
return false;
else {
MessageContext v = wsContext.getMessageContext();
System.out.println("MessageContext=" + v);
return true;
}
}
public boolean getUserPrincipalTest() {
if (wsContext == null)
return false;
else {
java.security.Principal v = wsContext.getUserPrincipal();
System.out.println("UserPrincipal=" + v);
return true;
}
}
public boolean isUserInRoleTest(String s) {
if (wsContext == null)
return false;
else
return wsContext.isUserInRole(s);
}
public boolean getEndpointReferenceTest() {
boolean pass = true;
if (wsContext == null) {
pass = false;
} else {
EndpointReference epr = wsContext.getEndpointReference();
TestUtil.logMsg("EndpointReference object=" + epr);
if (epr == null) {
TestUtil.logErr("getEndpointReference() returned null");
pass = false;
} else {
TestUtil.logMsg(
"getEndpointReference() returned EndpointReference object: " + epr);
}
if (epr instanceof W3CEndpointReference) {
TestUtil.logMsg("epr instanceof W3CEndpointReference");
} else {
TestUtil.logErr("epr not instanceof W3CEndpointReference");
pass = false;
}
}
if (!pass) {
return false;
} else {
return true;
}
}
/*
* <T extends EndpointReference> T getEndpointReference(java.lang.Class<T>
* clazz, org.w3c.dom.Element... referenceParameters)
*/
public boolean getEndpointReference2Test() {
boolean pass = true;
if (wsContext == null) {
pass = false;
} else {
// this is what the params needs to be java.lang.Class<T> clazz,
// org.w3c.dom.Element... referenceParameters
// <T extends EndpointReference> T epr=
// wsContext.getEndpointReference(W3CEndpointReference.class);
EndpointReference epr = wsContext
.getEndpointReference(W3CEndpointReference.class);
TestUtil.logMsg("EndpointReference object=" + epr);
if (epr == null) {
TestUtil.logErr("getEndpointReference() returned null");
pass = false;
} else {
TestUtil.logMsg(
"getEndpointReference() returned EndpointReference object: " + epr);
}
if (epr instanceof W3CEndpointReference) {
TestUtil.logMsg("epr instanceof W3CEndpointReference");
} else {
TestUtil.logErr("epr not instanceof W3CEndpointReference");
pass = false;
}
}
if (!pass) {
return false;
} else {
return true;
}
}
}