Here are the examples of the java api org.apache.axis2.context.MessageContext taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
114 Examples
19
Source : JMSUtils.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private static boolean isHyphenDeleteMode(MessageContext msgContext) {
if (msgContext == null) {
return false;
}
String hyphenSupport = (String) msgContext.getProperty(JMSConstants.PARAM_JMS_HYPHEN_MODE);
if (hyphenSupport != null && hyphenSupport.equals(JMSConstants.HYPHEN_MODE_DELETE)) {
return true;
}
return false;
}
19
Source : JMSUtils.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private static boolean isHyphenReplaceMode(MessageContext msgContext) {
if (msgContext == null) {
return false;
}
String hyphenSupport = (String) msgContext.getProperty(JMSConstants.PARAM_JMS_HYPHEN_MODE);
if (hyphenSupport != null && hyphenSupport.equals(JMSConstants.HYPHEN_MODE_REPLACE)) {
return true;
}
return false;
}
19
Source : ODataServletRequest.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public clreplaced ODataServletRequest implements HttpServletRequest {
private MessageContext axis2MessageContext;
ODataServletRequest(MessageContext messageContext) {
this.axis2MessageContext = messageContext;
}
@Override
public String getAuthType() {
throw new UnsupportedOperationException();
}
@Override
public Cookie[] getCookies() {
throw new UnsupportedOperationException();
}
@Override
public long getDateHeader(String s) {
throw new UnsupportedOperationException();
}
@Override
public String getHeader(String s) {
Map transportHeaders = (Map) axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
return (String) transportHeaders.get(s);
}
@Override
public Enumeration getHeaders(String s) {
Map transportHeaders = (Map) axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
List headerValues = new ArrayList();
headerValues.add(transportHeaders.get(s));
return new IteratorEnumeration(headerValues.iterator());
}
@Override
public Enumeration getHeaderNames() {
Map transportHeaders = (Map) axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
return new IteratorEnumeration(transportHeaders.keySet().iterator());
}
@Override
public int getIntHeader(String s) {
throw new UnsupportedOperationException();
}
@Override
public String getMethod() {
return (String) axis2MessageContext.getProperty("HTTP_METHOD");
}
@Override
public String getPathInfo() {
throw new UnsupportedOperationException();
}
@Override
public String getPathTranslated() {
throw new UnsupportedOperationException();
}
@Override
public String getContextPath() {
return "/odata";
}
@Override
public String getQueryString() {
String queryString = null;
String url = getRequestURI();
int queryStringPosition = url.indexOf('?');
if (queryStringPosition != -1) {
queryString = url.substring(queryStringPosition + 1);
}
return queryString;
}
@Override
public String getRemoteUser() {
throw new UnsupportedOperationException();
}
@Override
public boolean isUserInRole(String s) {
throw new UnsupportedOperationException();
}
@Override
public Principal getUserPrincipal() {
throw new UnsupportedOperationException();
}
@Override
public String getRequestedSessionId() {
throw new UnsupportedOperationException();
}
@Override
public String getRequestURI() {
return axis2MessageContext.getProperty("TransportInURL").toString();
}
@Override
public StringBuffer getRequestURL() {
StringBuffer url = new StringBuffer();
url.append(axis2MessageContext.getProperty("SERVICE_PREFIX"));
String serviceURL = (String) axis2MessageContext.getProperty("TransportInURL");
int queryStringPosition = serviceURL.indexOf('?');
if (queryStringPosition != -1) {
url.append(serviceURL, 1, serviceURL.indexOf('?'));
} else {
url.append(serviceURL.substring(1));
}
return url;
}
@Override
public String getServletPath() {
return "";
}
@Override
public HttpSession getSession(boolean b) {
throw new UnsupportedOperationException();
}
@Override
public HttpSession getSession() {
throw new UnsupportedOperationException();
}
@Override
public boolean isRequestedSessionIdValid() {
throw new UnsupportedOperationException();
}
@Override
public boolean isRequestedSessionIdFromCookie() {
throw new UnsupportedOperationException();
}
@Override
public boolean isRequestedSessionIdFromURL() {
throw new UnsupportedOperationException();
}
@Override
public boolean isRequestedSessionIdFromUrl() {
throw new UnsupportedOperationException();
}
@Override
public boolean authenticate(HttpServletResponse httpServletResponse) {
throw new UnsupportedOperationException();
}
@Override
public void login(String s, String s1) {
throw new UnsupportedOperationException();
}
@Override
public void logout() {
throw new UnsupportedOperationException();
}
@Override
public Collection<Part> getParts() {
throw new UnsupportedOperationException();
}
@Override
public Part getPart(String s) {
throw new UnsupportedOperationException();
}
@Override
public Object getAttribute(String s) {
return null;
}
@Override
public Enumeration getAttributeNames() {
throw new UnsupportedOperationException();
}
@Override
public String getCharacterEncoding() {
throw new UnsupportedOperationException();
}
@Override
public void setCharacterEncoding(String s) {
throw new UnsupportedOperationException();
}
@Override
public int getContentLength() {
throw new UnsupportedOperationException();
}
@Override
public String getContentType() {
throw new UnsupportedOperationException();
}
@Override
public ServletInputStream getInputStream() throws AxisFault {
OMElement content = axis2MessageContext.getEnvelope().getBody().getFirstElement();
if (content != null) {
String contentType = (String) axis2MessageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
if (contentType.contains(ODataPreplacedThroughHandler.JSON_CONTENT_TYPE)) {
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
JsonUtil.writeAsJson(axis2MessageContext, byteOutputStream);
return new RequestServletInputStream(new ByteArrayInputStream(byteOutputStream.toByteArray()));
} else if (contentType.contains(ODataPreplacedThroughHandler.XML_CONTENT_TYPE)) {
return new RequestServletInputStream(new ByteArrayInputStream(content.toString().getBytes()));
}
}
return null;
}
private clreplaced RequestServletInputStream extends ServletInputStream {
InputStream sourceStream;
public RequestServletInputStream(InputStream sourceStream) {
this.sourceStream = sourceStream;
}
@Override
public int read() throws IOException {
return this.sourceStream.read();
}
@Override
public void close() throws IOException {
super.close();
this.sourceStream.close();
}
}
@Override
public String getParameter(String s) {
throw new UnsupportedOperationException();
}
@Override
public Enumeration getParameterNames() {
throw new UnsupportedOperationException();
}
@Override
public String[] getParameterValues(String s) {
throw new UnsupportedOperationException();
}
@Override
public Map getParameterMap() {
throw new UnsupportedOperationException();
}
@Override
public String getProtocol() {
throw new UnsupportedOperationException();
}
@Override
public String getScheme() {
throw new UnsupportedOperationException();
}
@Override
public String getServerName() {
throw new UnsupportedOperationException();
}
@Override
public int getServerPort() {
throw new UnsupportedOperationException();
}
@Override
public BufferedReader getReader() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public String getRemoteAddr() {
throw new UnsupportedOperationException();
}
@Override
public String getRemoteHost() {
throw new UnsupportedOperationException();
}
@Override
public void setAttribute(String s, Object o) {
throw new UnsupportedOperationException();
}
@Override
public void removeAttribute(String s) {
throw new UnsupportedOperationException();
}
@Override
public Locale getLocale() {
throw new UnsupportedOperationException();
}
@Override
public Enumeration getLocales() {
throw new UnsupportedOperationException();
}
@Override
public boolean isSecure() {
throw new UnsupportedOperationException();
}
@Override
public RequestDispatcher getRequestDispatcher(String s) {
throw new UnsupportedOperationException();
}
@Override
public String getRealPath(String s) {
throw new UnsupportedOperationException();
}
@Override
public int getRemotePort() {
throw new UnsupportedOperationException();
}
@Override
public String getLocalName() {
throw new UnsupportedOperationException();
}
@Override
public String getLocalAddr() {
throw new UnsupportedOperationException();
}
@Override
public int getLocalPort() {
throw new UnsupportedOperationException();
}
@Override
public ServletContext getServletContext() {
throw new UnsupportedOperationException();
}
@Override
public AsyncContext startAsync() throws IllegalStateException {
throw new UnsupportedOperationException();
}
@Override
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
throw new UnsupportedOperationException();
}
@Override
public boolean isAsyncStarted() {
throw new UnsupportedOperationException();
}
@Override
public boolean isAsyncSupported() {
throw new UnsupportedOperationException();
}
@Override
public AsyncContext getAsyncContext() {
throw new UnsupportedOperationException();
}
@Override
public DispatcherType getDispatcherType() {
throw new UnsupportedOperationException();
}
}
19
Source : AbstractAuthorizationProvider.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Default implementation to get user name from message context.
*
* @param msgContext
* @return username.
*/
public String getUsername(MessageContext msgContext) {
String userName = (String) msgContext.getProperty(DBConstants.MSG_CONTEXT_USERNAME_PROPERTY);
return userName;
}
18
Source : LoadBalanceSessionFullClient.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
protected String getSetCookieHeader(MessageContext axis2MessageContext) {
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o instanceof Map) {
Map headerMap = (Map) o;
return (String) headerMap.get(SET_COOKIE);
}
return null;
}
18
Source : LoadBalanceSessionFullClient.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
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;
}
18
Source : LoadbalanceFailoverClient.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
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;
}
18
Source : LoadbalanceFailoverClient.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
protected String getSetCookieHeader(MessageContext axis2MessageContext) {
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headerMap = (Map) o;
return (String) headerMap.get(SET_COOKIE);
}
return null;
}
18
Source : RoleRetriever.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public String getUsername(MessageContext messageContext) throws DataServiceFault {
return userName;
}
18
Source : IntegratorStatefulHandler.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public AxisService findService(MessageContext messageContext) throws AxisFault {
return this.rubsd.findService(messageContext);
}
18
Source : SMTPFaultHandler.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
return InvocationResponse.CONTINUE;
}
18
Source : AbstractAdmin.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private void checkAdminService() {
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
if (msgCtx == null) {
return;
}
AxisService axisService = msgCtx.getAxisService();
if (axisService.getParameter(Constants.ADMIN_SERVICE_PARAM_NAME) == null) {
throw new RuntimeException("AbstractAdmin can only be extended by Carbon admin services. " + getClreplaced().getName() + " is not an admin service. Service name " + axisService.getName() + ". The service should have defined the " + Constants.ADMIN_SERVICE_PARAM_NAME + " parameter");
}
}
18
Source : HttpRequestHashGenerator.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private String handleGetWithoutHeaders(MessageContext msgContext) {
if (msgContext.getTo() == null) {
return null;
}
String toAddress = msgContext.getTo().getAddress();
byte[] digest = getDigest(toAddress, MD5_DIGEST_ALGORITHM);
return digest != null ? getStringRepresentation(digest) : null;
}
18
Source : HttpRequestHashGenerator.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private String handlePostWithoutHeaders(MessageContext msgContext) {
OMNode body = msgContext.getEnvelope().getBody();
String toAddress = null;
if (msgContext.getTo() != null) {
toAddress = msgContext.getTo().getAddress();
}
if (body != null) {
byte[] digest;
if (toAddress != null) {
digest = getDigest(body, toAddress, null, MD5_DIGEST_ALGORITHM);
} else {
digest = getDigest(body, MD5_DIGEST_ALGORITHM);
}
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
18
Source : DOMHASHGenerator.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* This is the implementation of the getDigest method and will implement the DOMHASH algorithm based XML node
* identifications. This will consider only the SOAP payload and this does not consider the SOAP headers in
* generating the digets. So, in effect this will uniquely identify the SOAP messages with the same payload.
*
* @param msgContext - MessageContext on which the XML node identifier will be generated
* @return Object representing the DOMHASH value of the normalized XML node
* @throws CachingException if there is an error in generating the digest key
* <p>
* #getDigest(org.apache.axis2.context.MessageContext)
*/
public String getDigest(MessageContext msgContext) throws CachingException {
OMNode request = msgContext.getEnvelope().getBody();
if (request != null) {
byte[] digest = getDigest(request, MD5_DIGEST_ALGORITHM);
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
18
Source : POXSecurityHandler.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* 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;
}
}
18
Source : POXSecurityHandler.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public void flowComplete(MessageContext msgContext) {
// Do Nothing
}
18
Source : PublisherUtil.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public static int getTenantId(MessageContext msgContext) {
return Constants.SUPER_TENANT_ID;
}
18
Source : CallQuery.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* This method returns the system variable's value given the property name.
*/
private Object evaluateGetProperty(String propName) throws DataServiceFault {
/* so far we only evaluate the "USERNAME" value */
if ("USERNAME".equals(propName)) {
MessageContext context = MessageContext.getCurrentMessageContext();
if (context != null) {
// todo change this to use role retriever
return this.getDataService().getAuthorizationProvider().getUsername(context);
}
} else if ("TENANT_ID".equals(propName)) {
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
return String.valueOf(Constants.SUPER_TENANT_ID);
} else if ("USER_ROLES".equals(propName)) {
MessageContext context = MessageContext.getCurrentMessageContext();
if (context != null) {
return this.getDataService().getAuthorizationProvider().getUserRoles(context);
}
} else if ("NULL".equals(propName)) {
/* represent the special null value (not empty string) */
return null;
}
return null;
}
18
Source : UserStoreAuthorizationProvider.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public String[] getUserRoles(MessageContext msgContext) throws DataServiceFault {
return DBUtils.getUserRoles(getUsername(msgContext));
}
18
Source : JWTAuthorizationProvider.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public String[] getUserRoles(MessageContext msgContext) throws DataServiceFault {
// need to retrieve from msgcontext
return DBUtils.getUserRoles(getUsername(msgContext));
}
18
Source : HL7MessageFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* {@inheritdoc }*
*/
public byte[] getBytes(MessageContext messageContext, OMOutputFormat omOutputFormat) throws AxisFault {
return new byte[0];
}
18
Source : HL7MessageFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* {@inheritdoc }*
*/
public String formatSOAPAction(MessageContext messageContext, OMOutputFormat omOutputFormat, String soapAction) {
return soapAction;
}
18
Source : HL7MessageFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private boolean isGenerateMessageAck(MessageContext msgCtx) {
Object param = msgCtx.getProperty(HL7Constants.HL7_GENERATE_ACK);
if (param != null) {
return Boolean.parseBoolean(param.toString());
} else {
return false;
}
}
18
Source : HL7MessageFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* {@inheritdoc }*
*/
public String getContentType(MessageContext msgCtx, OMOutputFormat omOutputFormat, String s) {
String contentType = (String) msgCtx.getProperty(Constants.Configuration.CONTENT_TYPE);
if (contentType == null) {
contentType = HL7Constants.HL7_CONTENT_TYPE;
}
String encoding = omOutputFormat.getCharSetEncoding();
if (encoding != null) {
contentType += "; charset=" + encoding;
}
return contentType;
}
18
Source : HL7ProcessingContext.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Handle the AUTOACK, NACK messages,which are to be sent back to the client
*
* @param ctx
* @param hl7Msg
* @return
* @throws HL7Exception
* @throws AxisFault
*/
public Message handleHL7Result(MessageContext ctx, Message hl7Msg) throws HL7Exception, AxisFault {
String resultMode = (String) ctx.getProperty(HL7Constants.HL7_RESULT_MODE);
String applicationAck = (String) ctx.getProperty(HL7Constants.HL7_APPLICATION_ACK);
if (resultMode != null) {
return handleAutoAckNack(resultMode, ctx, hl7Msg);
} else if (this.isAutoAck()) {
return this.createAck(hl7Msg);
}
/*
* no one ACKed or NACKed, want to create a application ACK message so we
* will return the result from the downstream application.
*/
return handleApplicationACK(applicationAck, hl7Msg);
}
18
Source : HL7ProcessingContext.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public void initMessageContext(Message message, MessageContext msgCtx) {
msgCtx.setProperty(HL7Constants.HL7_MESSAGE_OBJECT, message);
msgCtx.setProperty(HL7Constants.HL7_Preplaced_THROUGH_INVALID_MESSAGES, isPreplacedThroughInvalidMessages());
msgCtx.setProperty(HL7Constants.HL7_BUILD_RAW_MESSAGE, isBuildRawMessages());
publishMessage(message, msgCtx);
try {
msgCtx.setProperty(HL7Constants.HL7_RAW_MESSAGE_PROPERTY_NAME, message.encode());
} catch (HL7Exception e) {
log.error("Error while encoding for RAW HL7 message in EDI format");
}
}
17
Source : LoadBalanceSessionFullClient.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
protected void setSessionID(MessageContext axis2MessageContext, String value) {
if (value == null) {
return;
}
Map map = (Map) axis2MessageContext.getProperty(HTTPConstants.HTTP_HEADERS);
if (map == null) {
map = new HashMap();
axis2MessageContext.setProperty(HTTPConstants.HTTP_HEADERS, map);
}
map.put(COOKIE, value);
}
17
Source : RoleRetriever.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public String[] getUserRoles(MessageContext messageContext) throws DataServiceFault {
log.info("External role retriever invoked returning roles");
String[] roleArray = { "admin", "sampleRole1", "sampleRole2", userRole };
return roleArray;
}
17
Source : JsonStreamBuilder.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public OMElement processDoreplacedent(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault {
try {
if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
return (OMElement) axis2GsonBuilderProcessDoreplacedentMethod.invoke(axis2GsonBuilder, inputStream, s, messageContext);
} else {
return (OMElement) synapseBuilderProcessDoreplacedentMethod.invoke(synapseBuilder, inputStream, s, messageContext);
}
} catch (InvocationTargetException | IllegalAccessException e) {
logger.error("Error occurred while processing doreplacedent for application/json", e);
throw new AxisFault(e.getMessage());
}
}
17
Source : IntegratorStatefulHandler.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public AxisOperation findOperation(AxisService axisService, MessageContext messageContext) throws AxisFault {
return null;
}
17
Source : SMTPFaultHandler.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public void flowComplete(MessageContext msgContext) {
String protocol = msgContext.getIncomingTransportName();
if (protocol == null) {
return;
}
if (protocol.equalsIgnoreCase(Constants.TRANSPORT_MAIL) && msgContext.isServerSide()) {
// This will allow the faults to go out.
msgContext.setServerSide(false);
}
}
17
Source : REQUESTHASHGenerator.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* This is the implementation of the getDigest method and will implement the Extended DOMHASH algorithm based HTTP
* request identifications. This will consider To address of the request, HTTP headers and XML Payload in generating
* the digets. So, in effect this will uniquely identify the HTTP request with the same To address, Headers and
* Payload.
*
* @param msgContext - MessageContext on which the XML node identifier will be generated
* @return Object representing the DOMHASH value of the normalized XML node
* @throws CachingException if there is an error in generating the digest key
* @see org.wso2.caching.digest.DigestGenerator #getDigest(org.apache.axis2.context.MessageContext)
*/
public String getDigest(MessageContext msgContext) throws CachingException {
OMNode body = msgContext.getEnvelope().getBody();
String toAddress = null;
if (msgContext.getTo() != null) {
toAddress = msgContext.getTo().getAddress();
}
Map<String, String> headers = (Map) msgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
if (body != null) {
byte[] digest = null;
if (toAddress != null) {
digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
} else {
digest = getDigest(body, MD5_DIGEST_ALGORITHM);
}
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
17
Source : HttpRequestHashGenerator.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private String handlePostWithHeaders(MessageContext msgContext, Map transportHeaders) {
OMNode body = msgContext.getEnvelope().getBody();
String toAddress = null;
if (msgContext.getTo() != null) {
toAddress = msgContext.getTo().getAddress();
}
if (body != null) {
byte[] digest;
if (toAddress != null) {
digest = getDigest(body, toAddress, transportHeaders, MD5_DIGEST_ALGORITHM);
} else {
digest = getDigest(body, MD5_DIGEST_ALGORITHM);
}
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
17
Source : HttpRequestHashGenerator.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private String handleGetWithHeaders(MessageContext msgContext, Map transportHeaders) {
if (msgContext.getTo() == null) {
return null;
}
String toAddress = msgContext.getTo().getAddress();
byte[] digest = getDigest(toAddress, transportHeaders, MD5_DIGEST_ALGORITHM);
return digest != null ? getStringRepresentation(digest) : null;
}
17
Source : InboundHttpServerWorker.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Creates synapse message context from axis2 context
*
* @param inboundSourceRequest Source Request of inbound
* @param axis2Context Axis2 message context of message
* @return Synapse Message Context instance
* @throws AxisFault
*/
private org.apache.synapse.MessageContext createSynapseMessageContext(SourceRequest inboundSourceRequest, MessageContext axis2Context) throws AxisFault {
return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2Context);
}
17
Source : InboundHttpServerWorker.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Set Inbound Related Properties for Axis2 Message Context
*
* @param axis2Context Axis2 Message Context of incoming request
*/
private void setInboundProperties(MessageContext axis2Context) {
axis2Context.setProperty(SynapseConstants.IS_INBOUND, true);
}
17
Source : ODataServletResponse.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public clreplaced ODataServletResponse implements HttpServletResponse {
private MessageContext axis2MessageContext;
private final ByteArrayOutputStream content = new ByteArrayOutputStream(1024);
private final ServletOutputStream outputStream = new ResponseServletOutputStream(this.content);
private long contentLength = 0;
private String contentType;
private String characterEncoding = StandardCharsets.UTF_8.name();
private int bufferSize = 4096;
private int statusCode;
private boolean committed;
ODataServletResponse(MessageContext messageContext) {
this.axis2MessageContext = messageContext;
}
@Override
public void addCookie(Cookie cookie) {
throw new UnsupportedOperationException();
}
@Override
public boolean containsHeader(String s) {
throw new UnsupportedOperationException();
}
@Override
public String encodeURL(String s) {
throw new UnsupportedOperationException();
}
@Override
public String encodeRedirectURL(String s) {
throw new UnsupportedOperationException();
}
@Override
public String encodeUrl(String s) {
throw new UnsupportedOperationException();
}
@Override
public String encodeRedirectUrl(String s) {
throw new UnsupportedOperationException();
}
@Override
public void sendError(int i, String s) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void sendError(int i) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void sendRedirect(String s) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void setDateHeader(String s, long l) {
throw new UnsupportedOperationException();
}
@Override
public void addDateHeader(String s, long l) {
throw new UnsupportedOperationException();
}
@Override
public void setHeader(String headerName, String headerValue) {
Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
Map headers = (Map) o;
if (headers != null) {
headers.put(headerName, headerValue);
}
}
@Override
public void addHeader(String headerName, String headerValue) {
Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
Map headers = (Map) o;
if (headers != null) {
headers.put(headerName, headerValue);
}
if (HTTP.CONTENT_TYPE.equals(headerName)) {
contentType = headerValue;
}
if (HTTP.CONTENT_LEN.equals(headerName)) {
contentLength = Long.parseLong(headerValue);
}
}
@Override
public void setIntHeader(String s, int i) {
throw new UnsupportedOperationException();
}
@Override
public void addIntHeader(String s, int i) {
throw new UnsupportedOperationException();
}
@Override
public void setStatus(int i) {
axis2MessageContext.setProperty(PreplacedThroughConstants.HTTP_SC, i);
statusCode = i;
}
@Override
public void setStatus(int i, String s) {
throw new UnsupportedOperationException();
}
@Override
public int getStatus() {
return statusCode;
}
@Override
public String getHeader(String s) {
throw new UnsupportedOperationException();
}
@Override
public Collection<String> getHeaders(String s) {
throw new UnsupportedOperationException();
}
@Override
public Collection<String> getHeaderNames() {
throw new UnsupportedOperationException();
}
@Override
public String getCharacterEncoding() {
return characterEncoding;
}
@Override
public String getContentType() {
return contentType;
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
return this.outputStream;
}
private void setCommittedIfBufferSizeExceeded() {
int bufSize = getBufferSize();
if (bufSize > 0 && this.content.size() > bufSize) {
setCommitted(true);
}
}
public void setCommitted(boolean committed) {
this.committed = committed;
}
private clreplaced ResponseServletOutputStream extends ServletOutputStream {
private final OutputStream targetStream;
ResponseServletOutputStream(OutputStream out) {
targetStream = out;
}
@Override
public void write(int b) throws IOException {
targetStream.write(b);
super.flush();
targetStream.flush();
setCommittedIfBufferSizeExceeded();
}
@Override
public void flush() throws IOException {
super.flush();
setCommitted(true);
}
@Override
public void close() throws IOException {
super.close();
this.targetStream.close();
}
}
@Override
public PrintWriter getWriter() {
throw new UnsupportedOperationException();
}
@Override
public void setCharacterEncoding(String s) {
this.characterEncoding = characterEncoding;
}
@Override
public void setContentLength(int i) {
contentLength = i;
}
public int getContentLength() {
return (int) this.contentLength;
}
public String getContentreplacedtring() throws UnsupportedEncodingException {
return (this.characterEncoding != null ? this.content.toString(this.characterEncoding) : this.content.toString());
}
@Override
public void setContentType(String s) {
contentType = s;
}
@Override
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
}
@Override
public int getBufferSize() {
return this.bufferSize;
}
@Override
public void flushBuffer() {
setCommitted(true);
}
@Override
public void resetBuffer() {
this.content.reset();
}
@Override
public boolean isCommitted() {
return this.committed;
}
@Override
public void reset() {
resetBuffer();
this.characterEncoding = null;
this.contentLength = 0;
this.contentType = null;
}
@Override
public void setLocale(Locale locale) {
throw new UnsupportedOperationException();
}
@Override
public Locale getLocale() {
throw new UnsupportedOperationException();
}
}
17
Source : DataServiceRequest.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Set the current session user's name, user roles etc..
* @param dataService data service
* @param dsRequest Current data service request
* @param msgContext Incoming message's message context
* @throws DataServiceFault
*/
private static void populateUserInfo(DataService dataService, DataServiceRequest dsRequest, MessageContext msgContext) throws DataServiceFault {
/* set request username */
String username = dataService.getAuthorizationProvider().getUsername(msgContext);
dsRequest.setUser(username);
/* if only there's a user .. */
if (username != null) {
/* set user roles */
try {
dsRequest.setUserRoles(dataService.getAuthorizationProvider().getUserRoles(msgContext));
} catch (Exception e) {
throw new DataServiceFault(e, "Error setting user roles");
}
}
}
17
Source : JWTAuthorizationProvider.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* This method gets the JWT token from the transport header, and extracts the user name from the JWT and
* sets it to the message context.
* Example Usage - is to enable user name token security in DSS and use the JWT token sent from APIM to
* get the roles of the user in order to utilize the content filtering feature of DSS.
* @param msgContext
*/
private String extractUsernameFromJWT(MessageContext msgContext) throws UnsupportedEncodingException, AxisFault {
if (endUserClaim == null || endUserClaim.isEmpty()) {
endUserClaim = ENDUSER_CLAIM;
}
HttpServletRequest obj = (HttpServletRequest) msgContext.getProperty(HTTP_SERVLET_REQUEST);
if (obj != null) {
// Get the JWT token from the header.
String jwt = obj.getHeader(JWT_TOKEN_HEADER_NAME);
if (jwt != null && validateSignature(jwt)) {
String jwtToken = null;
// Decode the JWT token.
jwtToken = new String(org.apache.axiom.om.util.Base64.decode(jwt), UTF_8_ENCODING);
if (jwtToken != null) {
// Extract the end user claim.
String[] tempStr4 = jwtToken.split(endUserClaim + CLAIM_VALUE_SEPARATOR);
String[] decoded = tempStr4[1].split(ESCAPED_DOUBLE_QUOTATION);
System.out.println("tempStr4= " + tempStr4.toString());
System.out.println("decoded=" + decoded.toString());
// Set username to message context.
return decoded[0];
}
}
}
return null;
}
17
Source : JWTAuthorizationProvider.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public String getUsername(MessageContext msgContext) throws DataServiceFault {
try {
return extractUsernameFromJWT(msgContext);
} catch (UnsupportedEncodingException e) {
log.debug("Error in retrieving user name from message context - " + e.getMessage(), e);
throw new DataServiceFault(e, "Error in retrieving user name from message context - " + e.getMessage());
} catch (AxisFault axisFault) {
log.debug("Error in retrieving user name from message context - " + axisFault.getMessage(), axisFault);
throw new DataServiceFault(axisFault, "Error in retrieving user name from message context - " + axisFault.getMessage());
}
}
17
Source : HL7TransportSender.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Get the response from the messagecontext
*
* @param ctx
* @return
* @throws HL7Exception
*/
private Message xmlPayloadToHL7Message(MessageContext ctx) throws HL7Exception {
OMElement hl7MsgEl = (OMElement) ctx.getEnvelope().getBody().getChildrenWithName(new QName(HL7Constants.HL7_NAMESPACE, HL7Constants.HL7_MESSAGE_ELEMENT_NAME)).next();
String hl7XMLPayload = hl7MsgEl.getFirstElement().toString();
return this.xmlparser.parse(hl7XMLPayload);
}
17
Source : HL7TransportSender.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
@Override
public void sendMessage(MessageContext messageContext, String targetEPR, OutTransportInfo outTransportInfo) throws AxisFault {
if (targetEPR != null) {
// Forward the message to the given EPR
sendUsingEPR(messageContext, targetEPR);
} else {
// Send the application ack message back to the client
sendApplicationACKResponse(messageContext, outTransportInfo);
}
}
17
Source : HL7ProcessingContext.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* Get the hl7message from the messagecontext
*
* @param ctx
* @return
* @throws HL7Exception
*/
private Message xmlPayloadToHL7Message(MessageContext ctx) throws HL7Exception {
OMElement hl7MsgEl = (OMElement) ctx.getEnvelope().getBody().getChildrenWithName(new QName(HL7Constants.HL7_NAMESPACE, HL7Constants.HL7_MESSAGE_ELEMENT_NAME)).next();
String hl7XMLPayload = hl7MsgEl.getFirstElement().toString();
Message msg = null;
try {
msg = this.xmlparser.parse(hl7XMLPayload);
return msg;
} catch (EncodingNotSupportedException e) {
log.error("Encoding error in the message", e);
throw new HL7Exception("Encoding error in the message: " + e.getMessage(), e);
} catch (DataTypeException e) {
// Make this as warning.Since some remote systems require enriched messages that violate some HL7
// rules it would be nice to be able to still send the message.
log.warn("Rule validation fails." + e);
if (!(this.isValidateMessage())) {
this.xmlparser.setValidationContext(new NoValidation());
msg = this.xmlparser.parse(hl7XMLPayload);
return msg;
}
} catch (HL7Exception e) {
log.error("Error in the Message :", e);
throw new HL7Exception("Encoding error in the message: " + e.getMessage(), e);
}
return msg;
}
17
Source : HL7ProcessingContext.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public void offerApplicationResponses(Message message, MessageContext messageContext) throws HL7Exception, AxisFault {
String resultMode = (String) messageContext.getProperty(HL7Constants.HL7_RESULT_MODE);
if (resultMode != null) {
handleAutoAckNack(resultMode, messageContext, message);
} else {
applicationResponses.offer(message);
}
}
17
Source : 103333429.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* This is the implementation of the getDigest method and will implement the Extended DOMHASH
* algorithm based HTTP request identifications. This will consider To address of the request,
* HTTP headers and XML Payload in generating the digets. So, in effect
* this will uniquely identify the HTTP request with the same To address, Headers and Payload.
*
* @param msgContext - MessageContext on which the XML node identifier will be generated
* @return Object representing the DOMHASH value of the normalized XML node
* @throws CachingException if there is an error in generating the digest key
*
* @see org.wso2.caching.digest.DigestGenerator
* #getDigest(org.apache.axis2.context.MessageContext)
*/
public String getDigest(MessageContext msgContext) throws CachingException {
OMNode body = msgContext.getEnvelope().getBody();
String toAddress = null;
if (msgContext.getTo() != null) {
toAddress = msgContext.getTo().getAddress();
}
Map<String, String> headers = (Map) msgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
if (body != null) {
byte[] digest = null;
if (toAddress != null) {
digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
} else {
digest = getDigest(body, MD5_DIGEST_ALGORITHM);
}
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
16
Source : ParallelRequestHelper.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
/**
* helper method to send begin boxcar request and return the session
*
* @return cookie
* @throws org.apache.axis2.AxisFault
*/
public String beginBoxcarReturningSession() throws AxisFault {
sender.sendReceive(payload);
MessageContext msgCtx = sender.getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
CommonsTransportHeaders commonsTransportHeaders = (CommonsTransportHeaders) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
String cookie = (String) commonsTransportHeaders.get("Set-Cookie");
return cookie;
}
16
Source : JsonStreamFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public String getContentType(MessageContext messageContext, OMOutputFormat omOutputFormat, String s) {
try {
if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
return (String) axis2GsonFormatterGetContentTypeMethod.invoke(axis2GsonFormatter, messageContext, omOutputFormat, s);
} else {
return (String) synapseFormatterGetContentTypeMethod.invoke(synapseFormatter, messageContext, omOutputFormat, s);
}
} catch (InvocationTargetException | IllegalAccessException | AxisFault e) {
logger.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
16
Source : JsonStreamFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public byte[] getBytes(MessageContext messageContext, OMOutputFormat omOutputFormat) throws AxisFault {
try {
if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
return (byte[]) axis2GsonFormatterGetBytesMethod.invoke(axis2GsonFormatter, messageContext, omOutputFormat);
} else {
return (byte[]) synapseFormatterGetBytesMethod.invoke(synapseFormatter, messageContext, omOutputFormat);
}
} catch (InvocationTargetException | IllegalAccessException e) {
logger.error("Error occurred while generating bytes for application/json", e);
throw new AxisFault(e.getMessage());
}
}
16
Source : JsonStreamFormatter.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
public String formatSOAPAction(MessageContext messageContext, OMOutputFormat omOutputFormat, String s) {
try {
if (MicroIntegratorBaseUtils.isDataService(messageContext)) {
return (String) axis2GsonFormatterFormatSOAPActionMethod.invoke(axis2GsonFormatter, messageContext, omOutputFormat, s);
} else {
return (String) synapseFormatterFormatSOAPActionMethod.invoke(synapseFormatter, messageContext, omOutputFormat, s);
}
} catch (InvocationTargetException | IllegalAccessException | AxisFault e) {
logger.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
See More Examples