本文整理汇总了Java中org.apache.axis2.context.MessageContext.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getProperty方法的具体用法?Java MessageContext.getProperty怎么用?Java MessageContext.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUsernameTokenPrincipal
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Returns the UsernameTokenPrincipal from the security results.
*
* @param mc The message context of the message
* @return the UsernameTokenPrincipal from the security results as an
* <code>org.apache.ws.security.WSUsernameTokenPrincipal</code>.
* If a wsse:UsernameToken was not present in the wsse:Security header then
* <code>null</code> will be returned.
* @throws Exception If there are no security results.
* @see org.apache.ws.security.WSUsernameTokenPrincipal
*/
public static WSUsernameTokenPrincipal getUsernameTokenPrincipal(
MessageContext mc) throws Exception {
Vector results;
if ((results = (Vector) mc.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
throw new Exception("No security results available in the message context");
} else {
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult = (WSHandlerResult) results.get(i);
Vector wsSecEngineResults = rResult.getResults();
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
(WSSecurityEngineResult) wsSecEngineResults.get(j);
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.UT) {
return (WSUsernameTokenPrincipal) wser
.get(WSSecurityEngineResult.TAG_PRINCIPAL);
}
}
}
}
return null;
}
示例2: getBasicAuthHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Utility method to return basic auth transport headers if present
*
* @return
*/
private String getBasicAuthHeaders(MessageContext msgCtx) {
Map map = (Map) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
if (map == null) {
return null;
}
String tmp = (String) map.get("Authorization");
if (tmp == null) {
tmp = (String) map.get("authorization");
}
if (tmp != null && tmp.trim().startsWith("Basic ")) {
return tmp;
} else {
return null;
}
}
示例3: extractSessionID
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected String extractSessionID(MessageContext axis2MessageContext) {
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o instanceof Map) {
Map headerMap = (Map) o;
String cookie = (String) headerMap.get(SET_COOKIE);
if (cookie == null) {
cookie = (String) headerMap.get(COOKIE);
} else {
cookie = cookie.split(";")[0];
}
return cookie;
}
return null;
}
示例4: extractSessionID
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected String extractSessionID(MessageContext axis2MessageContext) {
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headerMap = (Map) o;
String cookie = (String) headerMap.get(SET_COOKIE);
if (cookie == null) {
cookie = (String) headerMap.get(COOKIE);
} else {
cookie = cookie.split(";")[0];
}
return cookie;
}
return null;
}
示例5: gzipCompressionInsideOutSequenceTest
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "having 'Content-Encoding = gzip' within outsequence")
public void gzipCompressionInsideOutSequenceTest() throws Exception {
ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendingGZIPCompressedPayloadToClient"));
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
Assert.assertTrue(response.toString().contains("GZIP"));
Assert.assertTrue(response.toString().contains("GZIP Company"));
}
示例6: dispatchAndVerify
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Finds axis Service and the Operation for DSS requests
*
* @param msgContext request message context
* @throws AxisFault if any exception occurs while finding axis service or operation
*/
private static void dispatchAndVerify(MessageContext msgContext) throws AxisFault {
requestDispatcher.invoke(msgContext);
AxisService axisService = msgContext.getAxisService();
if (axisService != null) {
httpLocationBasedDispatcher.invoke(msgContext);
if (msgContext.getAxisOperation() == null) {
requestURIOperationDispatcher.invoke(msgContext);
}
AxisOperation axisOperation;
if ((axisOperation = msgContext.getAxisOperation()) != null) {
AxisEndpoint axisEndpoint =
(AxisEndpoint) msgContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
if (axisEndpoint != null) {
AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisEndpoint
.getBinding().getChild(axisOperation.getName());
msgContext.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
}
msgContext.setAxisOperation(axisOperation);
}
}
}
示例7: triggerDestinationUnreachableFault
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static void triggerDestinationUnreachableFault(MessageContext messageContext,
String address) throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("triggerDestinationUnreachableFault: messageContext: " + messageContext +
" address: " + address);
}
String namespace =
(String)messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
if (Submission.WSA_NAMESPACE.equals(namespace)) {
triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_IRI, null,
AddressingConstants.FAULT_ADDRESSING_DESTINATION_UNREACHABLE,
null,
AddressingMessages.getMessage(
"spec.submission.FAULT_ADDRESSING_DESTINATION_UNREACHABLE_REASON"));
} else {
triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_IRI, address,
AddressingConstants.FAULT_ADDRESSING_DESTINATION_UNREACHABLE,
null,
AddressingMessages.getMessage(
"spec.final.FAULT_ADDRESSING_DESTINATION_UNREACHABLE_REASON"));
}
}
示例8: getPrettyString
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Get a prettified XML string from the SOAPEnvelope
*
* @param env The SOAPEnvelope to be prettified
* @param msgContext The MessageContext
* @return prettified XML string from the SOAPEnvelope
*/
public static String getPrettyString(OMElement env, MessageContext msgContext) {
String xml;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
env.serialize(baos);
InputStream xmlIn = new ByteArrayInputStream(baos.toByteArray());
String encoding =
(String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, encoding);
xml = xmlPrettyPrinter.xmlFormat();
} catch (Throwable e) {
String error = "Error occurred while pretty printing message. " + e.getMessage();
log.error(error, e);
xml = error;
}
return xml;
}
示例9: addGeneratedError
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Adds an {@link IEbmsError} that has been generated during message processing to the {@link MessageContext}.
*
* @param mc The {@link MessageContext} to which the error should be added
* @param error The {@link EbmsError} to add
*/
public static void addGeneratedError(final MessageContext mc, final IEbmsError error) {
ArrayList<IEbmsError> errList = null;
try {
errList = (ArrayList<IEbmsError>) mc.getProperty(MessageContextProperties.GENERATED_ERRORS);
} catch (final Exception e) {}
// If the message context does not contain a list of errors already or if
// the returned object is not a list, create new list
if (errList == null) {
errList = new ArrayList<>();
mc.setProperty(MessageContextProperties.GENERATED_ERRORS, errList);
}
// Add the error to the list
errList.add(error);
}
示例10: getTargetAddress
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public URL getTargetAddress(MessageContext messageContext, OMOutputFormat format, URL targetURL)
throws AxisFault {
// Check whether there is a template in the URL, if so we have to replace then with data
// values and create a new target URL.
targetURL = URLTemplatingUtil.getTemplatedURL(targetURL, messageContext, true);
String ignoreUncited =
(String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED);
// Need to have this check here cause
if (ignoreUncited == null || !JavaUtils.isTrueExplicitly(ignoreUncited)) {
String httpMethod = (String) messageContext.getProperty(Constants.Configuration.HTTP_METHOD);
if (Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)) {
targetURL = URLTemplatingUtil.appendQueryParameters(messageContext, targetURL);
}
} else {
messageContext.getEnvelope().getBody().getFirstElement().detach();
}
return targetURL;
}
示例11: processChatMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Process message requests that came in through chat clients
* @param msgCtx
* @throws AxisFault
*/
public static void processChatMessage(MessageContext msgCtx) throws AxisFault {
Object obj = msgCtx.getProperty(XMPPConstants.MESSAGE_FROM_CHAT);
if(obj != null){
String message = (String)obj;
String response = "";
if(message.trim().startsWith("help")){
response = prepareHelpTextForChat();
}else if(message.trim().startsWith("listServices")){
response = prepareServicesList(msgCtx);
}else if (message.trim().startsWith("getOperations")){
response = prepareOperationList(msgCtx,message);
}else{
//TODO add support for more help commands
}
sendChatMessage(msgCtx,response);
}
}
示例12: triggerMissingAddressInEPRFault
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static void triggerMissingAddressInEPRFault(MessageContext messageContext,
String incorrectHeaderName)
throws AxisFault {
log.warn("triggerMissingAddressInEPRFault: messageContext: " + messageContext +
" incorrectHeaderName: " + incorrectHeaderName);
String namespace =
(String)messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
if (Submission.WSA_NAMESPACE.equals(namespace)) {
triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
null, AddressingMessages.getMessage(
"spec.submission.FAULT_INVALID_HEADER_REASON"));
} else {
triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
incorrectHeaderName, Final.FAULT_INVALID_HEADER,
"MissingAddressInEPR",
AddressingMessages.getMessage(
"spec.final.FAULT_INVALID_HEADER_REASON"));
}
}
示例13: setAuthHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void setAuthHeaders(MessageContext msgCtx) throws IOException {
String serverName = ServerConfiguration.getInstance().getFirstProperty("Name");
if (serverName == null || serverName.trim().length() == 0) {
serverName = "WSO2 Carbon";
}
HttpServletResponse response = (HttpServletResponse)
msgCtx.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
// TODO : verify this fix. This is to handle soap fault from UT scenario
if (msgCtx.isFault() && response == null) {
MessageContext originalContext = (MessageContext) msgCtx.getProperty(MessageContext.IN_MESSAGE_CONTEXT);
if (originalContext != null) {
response = (HttpServletResponse)
originalContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
}
}
if (response != null) {
if (msgCtx.getProperty(MESSAGE_TYPE) != null) {
response.setContentType(String.valueOf(msgCtx.getProperty(MESSAGE_TYPE)));
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.addHeader("WWW-Authenticate",
"BASIC realm=\"" + serverName + "\"");
response.flushBuffer();
} else {
// if not servlet transport assume it to be nhttp transport
msgCtx.setProperty("NIO-ACK-Requested", "true");
msgCtx.setProperty("HTTP_SC", HttpServletResponse.SC_UNAUTHORIZED);
Map<String, String> responseHeaders = new HashMap<>();
responseHeaders.put("WWW-Authenticate",
"BASIC realm=\"" + serverName + "\"");
msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, responseHeaders);
}
}
示例14: getHttpSession
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private static HttpSession getHttpSession() {
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
HttpSession httpSess = null;
if (msgCtx != null) {
HttpServletRequest request = (HttpServletRequest) msgCtx
.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
httpSess = request.getSession();
}
return httpSess;
}
示例15: getLoggedInUser
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Gets logged in user of the server
*
* @return user name
*/
private String getLoggedInUser() {
MessageContext context = MessageContext.getCurrentMessageContext();
if (context != null) {
HttpServletRequest request =
(HttpServletRequest) context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
if (request != null) {
HttpSession httpSession = request.getSession(false);
return (String) httpSession.getAttribute(ServerConstants.USER_LOGGED_IN);
}
}
return null;
}