本文整理汇总了Java中org.apache.axis2.context.MessageContext.getCurrentMessageContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getCurrentMessageContext方法的具体用法?Java MessageContext.getCurrentMessageContext怎么用?Java MessageContext.getCurrentMessageContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getCurrentMessageContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkUserAuthorization
import org.apache.axis2.context.MessageContext; //导入方法依赖的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);
String tenantFreeUsername = MultitenantUtils.getTenantAwareUsername(username);
if (httpSession != null) {
String loggedInUsername = (String) httpSession.getAttribute(ServerConstants.USER_LOGGED_IN);
if (!tenantFreeUsername.equals(loggedInUsername)) {
throw new IdentityProviderException("Unauthorised action by user " + username
+ " to access " + operation);
}
} else {
throw new IdentityProviderException("Unauthorised action by user " + tenantFreeUsername
+ " to access " + operation);
}
}
示例2: getSessionResourcePath
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static String getSessionResourcePath() throws RegistryException {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext == null) {
String msg = "Could not get the user's Registry session. Message context not found.";
log.error(msg);
throw new RegistryException(msg);
}
HttpServletRequest request =
(HttpServletRequest) messageContext.getProperty("transport.http.servletRequest");
String resourcePath = (String) request.getSession().
getAttribute(RegistryConstants.SESSION_RESOURCE_PATH);
return resourcePath;
}
示例3: echoWithFault
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement echoWithFault(OMElement echoOMElement) throws AxisFault {
String text = echoOMElement.getText();
if (THROW_FAULT_AS_AXIS_FAULT.equalsIgnoreCase(text)) {
throw new AxisFault(new QName("http://test.org", "TestFault", "test"), "FaultReason",
new Exception("This is a test Exception"));
} else if (THROW_FAULT_WITH_MSG_CTXT.equalsIgnoreCase(text)) {
MessageContext inMessageContext = MessageContext.getCurrentMessageContext();
initFaultInformation(inMessageContext);
inMessageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
inMessageContext
.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, soapFaultReason);
inMessageContext
.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, soapFaultDetail);
throw new AxisFault("Fake exception occurred !!");
} else {
return echoOMElement;
}
}
示例4: 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;
}
示例5: 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;
}
示例6: isAuthorized
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private boolean isAuthorized(String targetUser, String permissionString) throws UserStoreException,
CarbonException {
boolean isAuthrized = false;
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(ServerConstants.USER_LOGGED_IN);
isAuthrized = isUserAuthorizedToConfigureProfile(getUserRealm(), userName, targetUser, permissionString);
}
return isAuthrized;
}
示例7: uploadFileUsingSwA
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement uploadFileUsingSwA(OMElement request) throws Exception {
String imageContentId = request.
getFirstChildWithName(new QName("http://services.samples", "request")).
getFirstChildWithName(new QName("http://services.samples", "imageId")).
getText();
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
Attachments attachment = msgCtx.getAttachmentMap();
DataHandler dataHandler = attachment.getDataHandler(imageContentId);
File tempFile = File.createTempFile("swa-", ".gif");
FileOutputStream fos = new FileOutputStream(tempFile);
dataHandler.writeTo(fos);
fos.flush();
fos.close();
System.out.println("Wrote SwA attachment to temp file : " + tempFile.getAbsolutePath());
MessageContext outMsgCtx = msgCtx.getOperationContext().
getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
outMsgCtx.setProperty(
org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
OMFactory factory = request.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
OMElement payload = factory.createOMElement("uploadFileUsingSwAResponse", ns);
OMElement response = factory.createOMElement("response", ns);
OMElement imageId = factory.createOMElement("imageId", ns);
FileDataSource fileDataSource = new FileDataSource(tempFile);
dataHandler = new DataHandler(fileDataSource);
imageContentId = outMsgCtx.addAttachment(dataHandler);
imageId.setText(imageContentId);
response.addChild(imageId);
payload.addChild(response);
return payload;
}
示例8: getStringValue
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static String getStringValue(Object obj) {
if (obj instanceof Float ||
obj instanceof Double) {
double data;
if (obj instanceof Float) {
data = ((Float)obj).doubleValue();
} else {
data = (Double)obj;
}
if (Double.isNaN(data)) {
return "NaN";
} else if (data == Double.POSITIVE_INFINITY) {
return "INF";
} else if (data == Double.NEGATIVE_INFINITY) {
return "-INF";
} else {
return obj.toString();
}
} else if (obj instanceof Calendar) {
Calendar calendar = (Calendar) obj;
return ConverterUtil.convertToString(calendar);
} else if (obj instanceof Date) {
SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd");
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext != null) {
AxisService axisServce = messageContext.getAxisService();
// if the user has given a pirticualr timezone we use it.
if (axisServce.getParameter("TimeZone") != null) {
zulu.setTimeZone(TimeZone.getTimeZone((String) axisServce.getParameter("TimeZone").getValue()));
}
}
return zulu.format(obj);
} else if (obj instanceof URI){
return obj.toString();
} else if (obj instanceof BigDecimal) {
return ((BigDecimal) obj).toPlainString();
}
return obj.toString();
}
示例9: handleRememberMe
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OpenIDRememberMeDTO handleRememberMe(String openID, String ipaddress) throws Exception {
String userName = OpenIDUtil.getUserName(openID);
String hmac = null;
OpenIDRememberMeDTO dto = new OpenIDRememberMeDTO();
dto.setAuthenticated(false);
String cookie = null;
OpenIDRememberMeDO rememberMe = new OpenIDRememberMeDO();
rememberMe.setOpenID(openID);
rememberMe.setUserName(userName);
OpenIDRememberMeTokenManager tokenManager = new OpenIDRememberMeTokenManager();
if (ipaddress != null) {
cookie = IdentityUtil.generateUUID();
hmac = IdentityUtil.getHMAC(ipaddress, cookie);
rememberMe.setToken(hmac);
tokenManager.updateToken(rememberMe);
dto.setNewCookieValue(cookie);
dto.setAuthenticated(true);
MessageContext msgContext = MessageContext.getCurrentMessageContext();
if (msgContext != null) {
HttpServletRequest request =
(HttpServletRequest) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
HttpSession httpSession = request.getSession(false);
if (httpSession != null) {
httpSession.setAttribute(OpenIDServerConstants.OPENID_LOGGEDIN_USER, userName);
}
}
}
return dto;
}
示例10: setSessionObject
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static void setSessionObject(String name, Object obj) {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext != null) {
ServiceContext serviceContext = messageContext.getServiceContext();
if (serviceContext != null) {
serviceContext.setProperty(name, obj);
}
}
}
示例11: ping
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public int ping() throws AxisFault {
MessageContext msgContext = MessageContext.getCurrentMessageContext();
//operation name to can be accessed in this manner
String operationName = (String)msgContext.getProperty(OPERATION_TO_PING);
//Implementation of this method depends on the particular service
if(operationName != null && operationName.equals("getPrice")){
//For this sample
return PING_SUCCESSFUL;
}else if(operationName != null && operationName.equals("update")){
return PING_FAILD;
}
return PING_FAILD;
}
示例12: getHttpSession
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private HttpSession getHttpSession() {
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
HttpSession httpSession = null;
if (msgCtx != null) {
HttpServletRequest request =
(HttpServletRequest) msgCtx.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
httpSession = request.getSession();
}
return httpSession;
}
示例13: uploadFile
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public String uploadFile(String name, String attchmentID) throws IOException
{
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
Attachments attachment = msgCtx.getAttachmentMap();
DataHandler dataHandler = attachment.getDataHandler(attchmentID);
File file = new File(
name);
FileOutputStream fileOutputStream = new FileOutputStream(file);
dataHandler.writeTo(fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
return "File saved succesfully.";
}
示例14: isAuthorized
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private boolean isAuthorized(String targetUser) throws UserStoreException, CarbonException {
boolean isAuthrized = false;
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(ServerConstants.USER_LOGGED_IN);
isAuthrized = UserProfileUtil.isUserAuthorizedToConfigureProfile(getUserRealm(), userName, targetUser);
}
return isAuthrized;
}
示例15: setSessionResourcePath
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static void setSessionResourcePath(String path) throws RegistryException {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext == null) {
String msg = "Could not get the user's Registry session. Message context not found.";
log.error(msg);
throw new RegistryException(msg);
}
HttpServletRequest request =
(HttpServletRequest) messageContext.getProperty("transport.http.servletRequest");
request.getSession().setAttribute(RegistryConstants.SESSION_RESOURCE_PATH, path);
}