當前位置: 首頁>>代碼示例>>Java>>正文


Java WebServiceContext.getMessageContext方法代碼示例

本文整理匯總了Java中javax.xml.ws.WebServiceContext.getMessageContext方法的典型用法代碼示例。如果您正苦於以下問題:Java WebServiceContext.getMessageContext方法的具體用法?Java WebServiceContext.getMessageContext怎麽用?Java WebServiceContext.getMessageContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.ws.WebServiceContext的用法示例。


在下文中一共展示了WebServiceContext.getMessageContext方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performInvocation

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
@Override
protected Object performInvocation(Exchange exchange, final Object serviceObject, Method m, Object[] paramArray)
      throws Exception
{
   WebServiceContext wsCtx = new WebServiceContextImpl(null);
   return wsCtx.getMessageContext() != null ? "OK" : "FAIL";
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:8,代碼來源:JBossWSInvokerTest.java

示例2: getSOAPMessageContext

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
private static SOAPMessageContext getSOAPMessageContext(MessageContext jaxwsMessageContext) {
    org.apache.axis2.context.MessageContext msgContext =
        jaxwsMessageContext.getAxisMessageContext();
    ServiceContext serviceContext = msgContext.getServiceContext();
    SOAPMessageContext soapMessageContext = null;
    if (serviceContext != null) {
        WebServiceContext wsc =
            (WebServiceContext)serviceContext.getProperty(EndpointLifecycleManagerImpl.WEBSERVICE_MESSAGE_CONTEXT);
        if (wsc != null) {
            soapMessageContext = (SOAPMessageContext)wsc.getMessageContext();
        }
    }
    return soapMessageContext;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:15,代碼來源:ContextUtils.java

示例3: getUserFromContext

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
public User getUserFromContext(WebServiceContext webServiceContext) throws ServiceException {
	try {
		MessageContext messageContext = webServiceContext.getMessageContext();
		Map<String, Object> httpHeaders = (Map<String, Object>) messageContext.get(MessageContext.HTTP_REQUEST_HEADERS);
		List<?> userList = (List<?>) httpHeaders.get("Username");
		List<?> passList = (List<?>) httpHeaders.get("Password");

		String clientUserName = (userList != null) ? userList.get(0).toString() : "anonymous";
		String clientPassword = (passList != null) ? passList.get(0).toString() : "";
		
		return new User(clientUserName, clientPassword);
	} catch (Exception e) {
		throw new ServiceException(e);
	}
}
 
開發者ID:grycap,項目名稱:vmrc,代碼行數:16,代碼來源:SecurityService.java

示例4: LazyRequestDataExtractor

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
public LazyRequestDataExtractor(WebServiceContext webServiceContext) {
    this.webServiceContext = webServiceContext;
    try {
        //according to my measuring this call is cheap. (would be nice to look into the source,
        //maybe it's just a simple getter?
        messageContext = webServiceContext.getMessageContext();
    } catch (IllegalStateException e) {
        throw new IllegalStateException("Only the Thread accepting the request has access to this!", e);
    }
}
 
開發者ID:optimaize,項目名稱:anythingworks,代碼行數:11,代碼來源:LazyRequestDataExtractor.java

示例5: getCallerId

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
public static String getCallerId(WebServiceContext wsContext) {
	String callerId = null;
	if (wsContext == null)
		return callerId;
	MessageContext mContext = wsContext.getMessageContext();
	if (mContext == null)
		return callerId;
	HttpServletRequest servletRequest = (HttpServletRequest) mContext.get(MessageContext.SERVLET_REQUEST);
	if (servletRequest == null)
		return callerId;
	java.security.cert.X509Certificate[] certs = (java.security.cert.X509Certificate[]) servletRequest.getAttribute("javax.servlet.request.X509Certificate");
	if ((certs == null) || (certs.length == 0)) {
		return callerId;
	}
	
	//TODO: seem to need to grab last cert when a proxy cert is used.  Is there a better way to find the "right" one?
	String dn = certs[certs.length-1].getSubjectDN().getName();
	StringBuffer sb = new StringBuffer();
	int index = dn.lastIndexOf(",");
	while (index != -1) {
		String str = dn.substring(index + 1).trim() + ",";
		sb.append(str);
		dn = dn.substring(0, index);
		index = dn.lastIndexOf(",");
	}
	sb.append(dn);
	callerId = CertUtil.subjectToIdentity(sb.toString());
	return callerId;
}
 
開發者ID:NCIP,項目名稱:cagrid2,代碼行數:30,代碼來源:WebServiceCallerId.java

示例6: getIPFromContext

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
private String getIPFromContext(WebServiceContext wsc) {
	MessageContext mc = wsc.getMessageContext();
	HttpServletRequest hsr = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
	return hsr.getRemoteAddr();
}
 
開發者ID:roscisz,項目名稱:KernelHive,代碼行數:6,代碼來源:ClusterBean.java

示例7: identify

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
@Override
public UddiEntityPublisher identify(String authInfoNotused, String authorizedNameNotused, WebServiceContext ctx) throws AuthenticationException, FatalErrorException {
        int MaxBindingsPerService = -1;
        int MaxServicesPerBusiness = -1;
        int MaxTmodels = -1;
        int MaxBusinesses = -1;
        try {
                MaxBindingsPerService = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_BINDINGS_PER_SERVICE, -1);
                MaxServicesPerBusiness = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_SERVICES_PER_BUSINESS, -1);
                MaxTmodels = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_TMODELS_PER_PUBLISHER, -1);
                MaxBusinesses = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_BUSINESSES_PER_PUBLISHER, -1);
        } catch (Exception ex) {
                MaxBindingsPerService = -1;
                MaxServicesPerBusiness = -1;
                MaxTmodels = -1;
                MaxBusinesses = -1;
                log.error("config exception! ", ex);
        }
        EntityManager em = PersistenceManager.getEntityManager();
        EntityTransaction tx = em.getTransaction();
        try {
                String user = null;
                if (ctx==null)
                        throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", "no web service context!"));
                if (ctx.getUserPrincipal() != null) {
                        user = ctx.getUserPrincipal().getName();
                }
                if (user == null) {
                        MessageContext mc = ctx.getMessageContext();
                        HttpServletRequest req = null;
                        if (mc != null) {
                                req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
                        }
                        if (req != null && req.getUserPrincipal()!=null) {
                                user = req.getUserPrincipal().getName();
                        }
                }
                if (user==null || user.length()==0){
                        throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher"));
                }
                tx.begin();
                Publisher publisher = em.find(Publisher.class, user);
                if (publisher == null) {
                        log.warn("Publisher \"" + user + "\" was not found in the database, adding the publisher in on the fly.");
                        publisher = new Publisher();
                        publisher.setAuthorizedName(user);
                        publisher.setIsAdmin("false");
                        publisher.setIsEnabled("true");
                        publisher.setMaxBindingsPerService(MaxBindingsPerService);
                        publisher.setMaxBusinesses(MaxBusinesses);
                        publisher.setMaxServicesPerBusiness(MaxServicesPerBusiness);
                        publisher.setMaxTmodels(MaxTmodels);
                        publisher.setPublisherName("Unknown");
                        em.persist(publisher);
                        tx.commit();
                }
                
                return publisher;
        } finally {
                if (tx.isActive()) {
                        tx.rollback();
                }
                em.close();
        }
}
 
開發者ID:apache,項目名稱:juddi,代碼行數:66,代碼來源:HTTPContainerAuthenticator.java

示例8: identify

import javax.xml.ws.WebServiceContext; //導入方法依賴的package包/類
@Override
public UddiEntityPublisher identify(String notusedauthtoken, String notusedusername, WebServiceContext ctx) throws AuthenticationException, FatalErrorException {
        int MaxBindingsPerService = -1;
        int MaxServicesPerBusiness = -1;
        int MaxTmodels = -1;
        int MaxBusinesses = -1;
        String http_header_name = null;
        try {
                http_header_name = AppConfig.getConfiguration().getString(Property.JUDDI_AUTHENTICATOR_HTTP_HEADER_NAME);
                MaxBindingsPerService = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_BINDINGS_PER_SERVICE, -1);
                MaxServicesPerBusiness = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_SERVICES_PER_BUSINESS, -1);
                MaxTmodels = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_TMODELS_PER_PUBLISHER, -1);
                MaxBusinesses = AppConfig.getConfiguration().getInt(Property.JUDDI_MAX_BUSINESSES_PER_PUBLISHER, -1);
        } catch (Exception ex) {
                MaxBindingsPerService = -1;
                MaxServicesPerBusiness = -1;
                MaxTmodels = -1;
                MaxBusinesses = -1;
                log.error("config exception! ", ex);
        }
        if (http_header_name == null) {
                throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", "misconfiguration!"));
        }
        EntityManager em = PersistenceManager.getEntityManager();
        EntityTransaction tx = em.getTransaction();
        try {
                String user = null;

                MessageContext mc = ctx.getMessageContext();
                HttpServletRequest req = null;
                if (mc != null) {
                        req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
                        user = req.getHeader(http_header_name);
                }
                
                if (user == null || user.length() == 0) {
                        throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher"));
                }
                tx.begin();
                Publisher publisher = em.find(Publisher.class, user);
                if (publisher == null) {
                        log.warn("Publisher \"" + user + "\" was not found in the database, adding the publisher in on the fly.");
                        publisher = new Publisher();
                        publisher.setAuthorizedName(user);
                        publisher.setIsAdmin("false");
                        publisher.setIsEnabled("true");
                        publisher.setMaxBindingsPerService(MaxBindingsPerService);
                        publisher.setMaxBusinesses(MaxBusinesses);
                        publisher.setMaxServicesPerBusiness(MaxServicesPerBusiness);
                        publisher.setMaxTmodels(MaxTmodels);
                        publisher.setPublisherName("Unknown");
                        em.persist(publisher);
                        tx.commit();
                }

                return publisher;
        } finally {
                if (tx.isActive()) {
                        tx.rollback();
                }
                em.close();
        }
}
 
開發者ID:apache,項目名稱:juddi,代碼行數:64,代碼來源:HTTPHeaderAuthenticator.java


注:本文中的javax.xml.ws.WebServiceContext.getMessageContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。