当前位置: 首页>>代码示例>>Java>>正文


Java MessageContext.getProperty方法代码示例

本文整理汇总了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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:37,代码来源:WSS4JUtil.java

示例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;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:POXSecurityHandler.java

示例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;
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:17,代码来源:LoadBalanceSessionFullClient.java

示例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;
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:17,代码来源:LoadbalanceFailoverClient.java

示例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"));

}
 
开发者ID:wso2,项目名称:product-ei,代码行数:15,代码来源:ESBJAVA2262ContentEncodingGzipTestCase.java

示例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);
        }
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:29,代码来源:IntegratorStatefulHandler.java

示例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"));
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:AddressingFaultsHelper.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:25,代码来源:TracerUtils.java

示例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);
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:24,代码来源:MessageContextUtils.java

示例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;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:XFormURLEncodedFormatter.java

示例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);       	
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:24,代码来源:XMPPSender.java

示例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"));
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:AddressingFaultsHelper.java

示例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);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:37,代码来源:POXSecurityHandler.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:11,代码来源:IdentityTenantUtil.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:19,代码来源:MultipleCredentialsUserProxy.java


注:本文中的org.apache.axis2.context.MessageContext.getProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。