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


Java HTTPConstants类代码示例

本文整理汇总了Java中org.apache.axis2.transport.http.HTTPConstants的典型用法代码示例。如果您正苦于以下问题:Java HTTPConstants类的具体用法?Java HTTPConstants怎么用?Java HTTPConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HTTPConstants类属于org.apache.axis2.transport.http包,在下文中一共展示了HTTPConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initStub

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
private void initStub(Stub stub) throws AxisFault
{
	if( stub != null )
	{
		final ServiceClient client = stub._getServiceClient();

		final Options options = client.getOptions();
		options.setProperty(WSHandlerConstants.PW_CALLBACK_REF, this);
		options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY, ofc.getProperty());
		options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true");
		options.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_11);
		URI uri = URI.create(bbUrl);
		if( uri.getScheme().toLowerCase().startsWith("https") )
		{
			Protocol myhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
			options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, myhttps);
		}
		client.engageModule("rampart-1.5.1");
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:BlackboardConnectorServiceImpl.java

示例2: getStubs

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
private Stubs getStubs(String serverUrl) throws Exception
{
	final ConfigurationContext ctx = getConfiguration();

	final HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties();
	final ProxyDetails proxy = configService.getProxyDetails();
	if( proxy.isConfigured() && !proxy.isHostExcepted(new URL(serverUrl).getHost()) )
	{
		proxyProperties.setProxyName(proxy.getHost());
		proxyProperties.setProxyPort(proxy.getPort());
		ctx.setProperty(HTTPConstants.PROXY, proxyProperties);
	}
	ctx.setProperty(HTTPConstants.SO_TIMEOUT, 120000);
	ctx.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 120000);

	return new Stubs(ctx, serverUrl);
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:BlackboardConnectorServiceImpl.java

示例3: setupValidationService

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * 
 * @param stub
 * @return receives a non prepared stub and set up it
 */
private OAuth2TokenValidationServiceStub setupValidationService(OAuth2TokenValidationServiceStub stub) {
    AuthProperties props = AuthProperties.inst();

    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();

    CarbonUtils.setBasicAccessSecurityHeaders(props.getWso2User(), props.getWso2Password(), true, client);

    options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS);
    options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS);
    options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS);
    options.setCallTransportCleanup(true);
    options.setManageSession(true);

    return stub;
}
 
开发者ID:romulets,项目名称:wso2is-example,代码行数:22,代码来源:TokenValidationService.java

示例4: initMassSpecAPIStub

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
protected MassSpecAPIStub initMassSpecAPIStub() throws Exception {
	MassSpecAPIStub stub = new MassSpecAPIStub();
	stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);
	stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, 3 * 60 * 1000);
	stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, 3 * 60 * 1000);
	stub._getServiceClient().getOptions().setCallTransportCleanup(true);
	//set proxy if available
	if(this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_SERVER) 
			&& this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_PORT)
			&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER) != null 
			&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT) != null) 
	{
		HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
		try {
			pp.setProxyName((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER));
			pp.setProxyPort(Integer.parseInt((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT)));
		} catch(Exception e) {
			e.printStackTrace();
			this.logger.error("Error: Could not set proxy settings. Please check input.");
			throw new Exception();
		}
		stub._getServiceClient().getOptions().setProperty(HTTPConstants.PROXY,pp);
	}
	
	return stub;
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:27,代码来源:OnlineChemSpiderDatabase.java

示例5: initSearchStub

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
protected SearchStub initSearchStub() throws Exception {
	SearchStub searchStub = new SearchStub();
	searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);
	searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, 3 * 60 * 1000);
	searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, 3 * 60 * 1000);
	
	//set proxy if available
	if(this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_SERVER) 
			&& this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_PORT)
			&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER) != null 
			&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT) != null) 
	{
		HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
		try {
			pp.setProxyName((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER));
			pp.setProxyPort(Integer.parseInt((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT)));
		} catch(Exception e) {
			this.logger.error("Error: Could not set proxy settings. Please check input.");
			throw new Exception();
		}
		searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.PROXY,pp);
	}
	
	return searchStub;
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:26,代码来源:OnlineChemSpiderDatabase.java

示例6: ParallelRequestHelper

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * constructor for parallel request helper
 * we can use this for the initial begin boxcarring request as well.(sending sessionCookie null)
 *
 * @param sessionCookie
 * @param operation
 * @param payload
 * @param serviceEndPoint
 * @throws org.apache.axis2.AxisFault
 */
public ParallelRequestHelper(String sessionCookie, String operation, OMElement payload, String serviceEndPoint) throws AxisFault {
    this.payload = payload;
    sender = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(serviceEndPoint));
    options.setProperty("__CHUNKED__", Boolean.FALSE);
    options.setTimeOutInMilliSeconds(45000L);
    options.setAction("urn:" + operation);
    sender.setOptions(options);
    if (sessionCookie != null && !sessionCookie.isEmpty()) {
        Header header = new Header("Cookie", sessionCookie);
        ArrayList headers = new ArrayList();
        headers.add(header);
        sender.getOptions().setProperty(HTTPConstants.HTTP_HEADERS, headers);
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:27,代码来源:ParallelRequestHelper.java

示例7: testReturnContentType

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
@Test(groups = { "wso2.esb" }, description = "Test for MIMEBoundary value in Content-Type header for multipart/form-data")
public void testReturnContentType() throws Exception {

    String boundary = "boundary";
    String jsonPayload = "{\"action\":\"ping\"}";

    SimpleHttpClient httpClient = new SimpleHttpClient();

    HttpResponse response = httpClient.doPost(getApiInvocationURL("testMIMEBoundary"), null, jsonPayload, HTTPConstants.MEDIA_TYPE_APPLICATION_JSON);
    String contentTypeData = response.getEntity().getContentType().getValue();

    if (contentTypeData.contains(boundary)) {
        String[] pairs = contentTypeData.split(";");
        for (String pair : pairs) {
            if (pair.contains(boundary)) {
                String[] boundaryDetails = pair.split("=");
                Assert.assertTrue(boundaryDetails[1].contains("MIMEBoundary_"), "MIMEBoundary is not set in Content-Type header");
            }
        }
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:22,代码来源:MultipartFormdataMIMEBoundaryTestCase.java

示例8: charsetTestWithInComingContentType

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Test for charset value in the Content-Type header " +
                                           "in response once message is built in out out sequence")
public void charsetTestWithInComingContentType() throws Exception {

    Map<String, String> headers = new HashMap<>();

    headers.put("Content-Type", "text/xml;charset=UTF-8");
    headers.put("SOAPAction", "urn:getQuote");

    HttpResponse response = HttpRequestUtil.doPost(new URL(getProxyServiceURLHttp("contentTypeCharsetProxy1"))
            , messagePayload, headers);
    Assert.assertNotNull(response, "Response is null");
    Assert.assertTrue(response.getData().contains("WSO2 Company"), "Response not as expected " + response);

    String contentType = response.getHeaders().get("Content-Type");
    Assert.assertTrue(contentType.contains("text/xml"), "Content-Type mismatched " + contentType);
    Assert.assertEquals(StringUtils.countMatches(contentType, HTTPConstants.CHAR_SET_ENCODING), 1
            , "charset repeated in Content-Type header " + contentType);

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

示例9: charsetTestByChangingContentType

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Test for charset value in the Content-Type header " +
                                           "in response once message is built in out out sequence " +
                                           "with messageType")
public void charsetTestByChangingContentType() throws Exception {

    Map<String, String> headers = new HashMap<>();

    headers.put("Content-Type", "text/xml;charset=UTF-8");
    headers.put("SOAPAction", "urn:getQuote");

    HttpResponse response = HttpRequestUtil.doPost(new URL(getProxyServiceURLHttp("contentTypeCharsetProxy2"))
            , messagePayload, headers);
    Assert.assertNotNull(response, "Response is null");
    Assert.assertTrue(response.getData().contains("WSO2 Company"), "Response not as expected " + response);

    String contentType = response.getHeaders().get("Content-Type");
    //Removing since a invalid scenario after the fix for https://wso2.org/jira/browse/ESBJAVA-1994
    //Assert.assertTrue(contentType.contains("application/xml"), "Content-Type is not changed " + contentType);
    Assert.assertEquals(StringUtils.countMatches(contentType, HTTPConstants.CHAR_SET_ENCODING), 1
            , "charset repeated in Content-Type header " + contentType);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:22,代码来源:ESBJAVA4468ContentTypeCharsetInResponseTestCase.java

示例10: charsetTestByChangingContentTypeWithCharset

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Test for charset value in the Content-Type header " +
                                           "in response once message is built in out out sequence " +
                                           "with messageType with charset")
public void charsetTestByChangingContentTypeWithCharset() throws Exception {

    Map<String, String> headers = new HashMap<>();

    headers.put("Content-Type", "text/xml;charset=UTF-8");
    headers.put("SOAPAction", "urn:getQuote");

    HttpResponse response = HttpRequestUtil.doPost(new URL(getProxyServiceURLHttp("contentTypeCharsetProxy3"))
            , messagePayload, headers);
    Assert.assertNotNull(response, "Response is null");
    Assert.assertTrue(response.getData().contains("WSO2 Company"), "Response not as expected " + response);

    String contentType = response.getHeaders().get("Content-Type");
    //Removing Invalid scenario after the fix for https://wso2.org/jira/browse/ESBJAVA-1994
    //Assert.assertTrue(contentType.contains("application/xml"), "Content-Type is not changed " + contentType);
    Assert.assertEquals(StringUtils.countMatches(contentType, HTTPConstants.CHAR_SET_ENCODING), 1
            , "charset repeated in Content-Type header " + contentType);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:22,代码来源:ESBJAVA4468ContentTypeCharsetInResponseTestCase.java

示例11: outOnlyWithoutContentAwareMediatorTest

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
@Test(groups = {"wso2.esb"})
public void outOnlyWithoutContentAwareMediatorTest() throws Exception {
    WireMonitorServer wireMonitorServer = new WireMonitorServer(3828);
    Map<String, String> headers = new HashMap<>();

    wireMonitorServer.start();

    headers.put(HttpHeaders.CONTENT_TYPE, "text/xml");
    headers.put(HTTPConstants.HEADER_SOAP_ACTION, "urn:placeOrder");

    HttpResponse response = HttpRequestUtil.doPost(new URL(getProxyServiceURLHttp("ESBJAVA4469"))
            , messageBody, headers);

    Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_ACCEPTED, "Response code should be 202");
    String outGoingMessage = wireMonitorServer.getCapturedMessage();
    Assert.assertTrue(outGoingMessage.contains(">WSO2<")
            , "Outgoing message is empty or invalid content " + outGoingMessage);

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

示例12: outOnlyWithContentAwareMediatorTest

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
@Test(groups = {"wso2.esb"})
public void outOnlyWithContentAwareMediatorTest() throws Exception {
    WireMonitorServer wireMonitorServer = new WireMonitorServer(3829);
    Map<String, String> headers = new HashMap<>();

    wireMonitorServer.start();

    headers.put(HttpHeaders.CONTENT_TYPE, "text/xml");
    headers.put(HTTPConstants.HEADER_SOAP_ACTION, "urn:placeOrder");

    HttpResponse response = HttpRequestUtil.doPost(new URL(getProxyServiceURLHttp("ESBJAVA4469WithLogMediator"))
            , messageBody, headers);

    Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_ACCEPTED, "Response code should be 202");
    String outGoingMessage = wireMonitorServer.getCapturedMessage();
    Assert.assertTrue(outGoingMessage.contains(">WSO2<")
            , "Outgoing message is empty or invalid content " + outGoingMessage);

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

示例13: isHandle

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * Checks whether the authentication of the context can be handled using this authenticator.
 *
 * @param messageContext containing the request need to be authenticated.
 * @return boolean indicating whether the request can be authenticated by this Authenticator.
 */
public boolean isHandle(MessageContext messageContext) {
    HttpServletRequest httpServletRequest = getHttpRequest(messageContext);
    if (httpServletRequest != null) {
        String headerValue = httpServletRequest.getHeader(HTTPConstants.HEADER_AUTHORIZATION);
        if (headerValue != null && !headerValue.trim().isEmpty()) {
            String[] headerPart = headerValue.trim().split(OauthAuthenticatorConstants.SPLITING_CHARACTOR);
            if (OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER.equals(headerPart[0])) {
                return true;
            }
        } else if (httpServletRequest.getParameter(OauthAuthenticatorConstants.BEARER_TOKEN_IDENTIFIER) != null) {
            return true;
        }
    }
    return false;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:22,代码来源:OauthAuthenticator.java

示例14: sendGraceFullRestartRequest

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
public static void sendGraceFullRestartRequest(String backendURL, String userName,
                                               String password) throws AutomationFrameworkException {
    try {
        ServiceClient serviceClient = new ServiceClient();
        Options opts = new Options();
        opts.setManageSession(true);
        opts.setTo(new EndpointReference(backendURL + "/ServerAdmin"));
        opts.setAction("urn:restart");
        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
        auth.setUsername(userName);
        auth.setPassword(password);
        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);

        serviceClient.setOptions(opts);
        serviceClient.sendReceive(ClientConnectionUtil.createPayLoadRestartServerGracefully());

    } catch (AxisFault e) {
        log.error("Unable to restart carbon server gracefully..", e);
        throw new AutomationFrameworkException("Unable to restart carbon server gracefully..", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-platform-integration,代码行数:22,代码来源:ClientConnectionUtil.java

示例15: checkUserAuthorization

import org.apache.axis2.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * @param username
 * @param operation
 * @throws IdentityProviderException
 */
private void checkUserAuthorization(String username, String operation) throws IdentityProviderException {
    MessageContext msgContext = MessageContext.getCurrentMessageContext();
    HttpServletRequest request = (HttpServletRequest) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    HttpSession httpSession = request.getSession(false);
    if (httpSession != null) {
        String userName = (String) httpSession.getAttribute(OpenIDServerConstants.OPENID_LOGGEDIN_USER);
        if (!username.equals(userName)) {
            throw new IdentityProviderException("Unauthorised action by user " + username +
                                                " to access " + operation);
        }
        return;
    }
    throw new IdentityProviderException("Unauthorised action by user " + username +
                                        " to access " + operation);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:21,代码来源:OpenIDProviderService.java


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