List of usage examples for javax.xml.ws.handler MessageContext get
V get(Object key);
From source file:com.olp.jpa.domain.docu.ut.service.EmpWebServiceImpl.java
@Override @Transactional/*from www .j a v a 2 s.c o m*/ public Future<?> addAllAsync(List<EmpBeanPub> list, boolean ignoreError, Integer outputMode, final AsyncHandler<List<EmpBeanPub>> asyncHandler) throws ServiceException { Logger logger = Logger.getLogger(getClass().getName()); logger.log(Level.INFO, "***** Within Async addAll method *****"); final ServerAsyncResponse<List<EmpBeanPub>> r = new ServerAsyncResponse<>(); MessageContext mContext = context.getMessageContext(); Set<String> s = mContext.keySet(); Iterator<String> iter = s == null ? null : s.iterator(); while (iter != null && iter.hasNext()) { logger.log(Level.INFO, "MessageContext property - {0}", iter.next()); } WrappedMessageContext wmc = (WrappedMessageContext) mContext; Message m = wmc.getWrappedMessage(); Set<String> s2 = m.keySet(); Iterator<String> iter2 = s2 == null ? null : s2.iterator(); while (iter2 != null && iter2.hasNext()) { logger.log(Level.INFO, "Message property - {0}", iter2.next()); } AddressingProperties addressProp = (AddressingProperties) mContext .get(org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND); EndpointReferenceType eprType = addressProp.getReplyTo(); return (r); }
From source file:com.olp.jpa.domain.docu.ut.service.DeptWebServiceImpl.java
@Override @Transactional/*from w w w.j ava 2s . co m*/ public Future<?> addAllAsync(List<DeptBeanPub> list, boolean ignoreError, Integer outputMode, final AsyncHandler<List<DeptBeanPub>> asyncHandler) throws ServiceException { Logger logger = Logger.getLogger(getClass().getName()); logger.log(Level.INFO, "***** Within Async addAll method *****"); final ServerAsyncResponse<List<DeptBeanPub>> r = new ServerAsyncResponse<>(); MessageContext mContext = context.getMessageContext(); Set<String> s = mContext.keySet(); Iterator<String> iter = s == null ? null : s.iterator(); while (iter != null && iter.hasNext()) { logger.log(Level.INFO, "MessageContext property - {0}", iter.next()); } WrappedMessageContext wmc = (WrappedMessageContext) mContext; Message m = wmc.getWrappedMessage(); Set<String> s2 = m.keySet(); Iterator<String> iter2 = s2 == null ? null : s2.iterator(); while (iter2 != null && iter2.hasNext()) { logger.log(Level.INFO, "Message property - {0}", iter2.next()); } AddressingProperties addressProp = (AddressingProperties) mContext .get(org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND); EndpointReferenceType eprType = addressProp.getReplyTo(); return (r); }
From source file:net.sourceforge.subsonic.service.SonosService.java
private HttpServletRequest getRequest() { MessageContext messageContext = context == null ? null : context.getMessageContext(); // See org.apache.cxf.transport.http.AbstractHTTPDestination#HTTP_REQUEST return messageContext == null ? null : (HttpServletRequest) messageContext.get("HTTP.REQUEST"); }
From source file:org.apache.hise.engine.jaxws.HISEJaxWSService.java
@Transactional public SOAPMessage invoke(final SOAPMessage request) { try {//ww w . j av a2 s . c om // TransactionStatus tx = transactionManager.getTransaction(new DefaultTransactionDefinition()); // assert transactionManager.isValidateExistingTransaction(); MessageContext c = context.getMessageContext(); Object operationInfo = c.get("org.apache.cxf.service.model.OperationInfo"); QName operation = (QName) operationInfo.getClass().getMethod("getName").invoke(operationInfo); QName portType = (QName) c.get("javax.xml.ws.wsdl.interface"); QName operation2 = (QName) c.get("javax.xml.ws.wsdl.operation"); Element body = request.getSOAPBody(); __log.debug("invoking " + request + " operation:" + operation + " portType:" + portType + " operation2:" + operation2); Node approveResponseHeader = hiseEngine.receive(HISEJaxWSService.this, portType, operation.getLocalPart(), body, request.getSOAPHeader()); SOAPMessage m = messageFactory.createMessage(); Document doc = m.getSOAPHeader().getOwnerDocument(); if (approveResponseHeader != null) { m.getSOAPHeader().appendChild(doc.importNode(approveResponseHeader, true)); } return m; } catch (Exception e) { throw new RuntimeException("Error during receiving message ", e); } }
From source file:org.apache.juddi.api.impl.AuthenticatedService.java
public UddiEntityPublisher getEntityPublisher(EntityManager em, String authInfo) throws DispositionReportFaultMessage { if (authInfo == null || authInfo.length() == 0) throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthRequired")); org.apache.juddi.model.AuthToken modelAuthToken = em.find(org.apache.juddi.model.AuthToken.class, authInfo); if (modelAuthToken == null) throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid")); int allowedMinutesOfInactivity = 0; try {//from w w w . j av a 2 s . co m allowedMinutesOfInactivity = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_TIMEOUT, 0); } catch (ConfigurationException ce) { logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from " + "the application's configuration. No automatic timeout token invalidation will occur. " + ce.getMessage(), ce); } int maxMinutesOfAge = 0; try { maxMinutesOfAge = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_EXPIRATION, 0); } catch (ConfigurationException ce) { logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from " + "the application's configuration. No automatic timeout token invalidation will occur. " + ce.getMessage(), ce); } Date now = new Date(); // 0 or negative means token does not expire if (allowedMinutesOfInactivity > 0) { // expire tokens after # minutes of inactivity // compare the time in milli-seconds if (now.getTime() > modelAuthToken.getLastUsed().getTime() + allowedMinutesOfInactivity * 60000l) { logger.info("AUDIT: FAILTURE Token " + modelAuthToken.getAuthToken() + " expired due to inactivity " + getRequestorsIPAddress()); modelAuthToken.setTokenState(AUTHTOKEN_RETIRED); } } if (maxMinutesOfAge > 0) { // expire tokens when max age is reached // compare the time in milli-seconds if (now.getTime() > modelAuthToken.getCreated().getTime() + maxMinutesOfAge * 60000l) { logger.info("AUDIT: FAILURE - Token " + modelAuthToken.getAuthorizedName() + " expired due to old age " + getRequestorsIPAddress()); modelAuthToken.setTokenState(AUTHTOKEN_RETIRED); } } if (modelAuthToken.getTokenState() == AUTHTOKEN_RETIRED) { throw new AuthTokenExpiredException(new ErrorMessage("errors.auth.AuthTokenExpired")); } if (ctx != null) { try { boolean check = true; try { check = AppConfig.getConfiguration().getBoolean(Property.JUDDI_AUTH_TOKEN_ENFORCE_SAME_IP, true); } catch (ConfigurationException ex) { logger.warn("Error loading config property " + Property.JUDDI_AUTH_TOKEN_ENFORCE_SAME_IP + " Enforcing Same IP for Auth Tokens will be enabled by default", ex); } if (check) { MessageContext mc = ctx.getMessageContext(); HttpServletRequest req = null; if (mc != null) { req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST); } if (req != null && modelAuthToken.getIPAddress() != null && modelAuthToken.getIPAddress() != null && !modelAuthToken.getIPAddress().equalsIgnoreCase(req.getRemoteAddr())) { modelAuthToken.setTokenState(AUTHTOKEN_RETIRED); logger.error( "AUDIT FAILURE - Security Alert - Attempt to use issued auth token from a different IP address, user " + modelAuthToken.getAuthorizedName() + ", issued IP " + modelAuthToken.getIPAddress() + ", attempted use from " + req.getRemoteAddr() + ", forcing reauthentication."); throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid")); //invalidate the token, someone's intercepted it or it was reused on another ip } } } catch (Exception ex) { if (ex instanceof AuthTokenRequiredException) throw (AuthTokenRequiredException) ex; logger.error("unexpected error caught looking up requestor's ip address", ex); } } Authenticator authenticator = AuthenticatorFactory.getAuthenticator(); UddiEntityPublisher entityPublisher = authenticator.identify(authInfo, modelAuthToken.getAuthorizedName()); // Must make sure the returned publisher has all the necessary fields filled if (entityPublisher == null) { logger.warn( "AUDIT FAILURE - Auth token invalided, publisher does not exist " + getRequestorsIPAddress()); throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid")); } if (entityPublisher.getAuthorizedName() == null) { logger.warn("AUDIT FAILURE - Auth token invalided, username does exist" + getRequestorsIPAddress()); throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid")); } // Auth token is being used. Adjust appropriate values so that it's internal 'expiration clock' is reset. modelAuthToken.setLastUsed(new Date()); modelAuthToken.setNumberOfUses(modelAuthToken.getNumberOfUses() + 1); return entityPublisher; }
From source file:org.apache.juddi.api.impl.AuthenticatedService.java
/** * Attempts to get the requestor's ip address from the servlet context, defaults to null it it can't be * retrieved/* w w w. j av a 2 s . c om*/ * @return requestor's ip address or null if it's not available */ public String getRequestorsIPAddress() { try { MessageContext mc = ctx.getMessageContext(); HttpServletRequest req = null; if (mc != null) { req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST); } if (req != null) { return req.getRemoteAddr(); } } catch (Exception ex) { logger.debug("Error caught looking up the requestor's ip address", ex); } return null; }
From source file:org.apache.juddi.v3.auth.HTTPContainerAuthenticator.java
@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 {/*from w ww . j a va 2 s.co m*/ 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(); } }
From source file:org.apache.juddi.v3.auth.HTTPHeaderAuthenticator.java
@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 {/*from www.j a v a2 s . c o m*/ 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(); } }
From source file:org.apache.juddi.xlt.util.LoggingHandler.java
private int getResponseCode(MessageContext context) { Integer responseCode = (Integer) context.get(MessageContext.HTTP_RESPONSE_CODE); return responseCode.intValue(); }
From source file:org.apache.juddi.xlt.util.LoggingHandler.java
private boolean isOutboundMessage(MessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); return outboundProperty.booleanValue(); }