Java Code Examples for org.apache.axis.MessageContext#getCurrentContext()
The following examples show how to use
org.apache.axis.MessageContext#getCurrentContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSDKService.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
protected IEngUserProfile getUserProfile() throws Exception { logger.debug("IN"); IEngUserProfile profile = null; try { MessageContext mc = MessageContext.getCurrentContext(); profile = (IEngUserProfile) mc.getProperty(IEngUserProfile.ENG_USER_PROFILE); if (profile == null) { logger.debug("User profile not found."); String userIdentifier = (String) mc.getProperty(WSHandlerConstants.USER); logger.debug("User identifier found = [" + userIdentifier + "]."); if (userIdentifier == null) { logger.warn("User identifier not found!! cannot build user profile object"); throw new Exception("Cannot create user profile"); } else { try { profile = UserUtilities.getUserProfile(userIdentifier); logger.debug("User profile for userId [" + userIdentifier + "] created."); } catch (Exception e) { logger.error("Exception creating user profile for userId [" + userIdentifier + "]!", e); throw new Exception("Cannot create user profile"); } } mc.setProperty(IEngUserProfile.ENG_USER_PROFILE, profile); } else { logger.debug("User profile for user [" + ((UserProfile) profile).getUserId() + "] retrieved."); } UserProfile userProfile = (UserProfile) profile; logger.info("User profile retrieved: userId = [" + userProfile.getUserId() + "]; username = [" + userProfile.getUserName() + "]"); } finally { logger.debug("OUT"); } return profile; }
Example 2
Source File: addSOAPResponseHeader.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException { String ns = null; String n = null; cfData val = null; boolean mustUnderstand = false; int offset = 0; if (parameters.size() == 4) { mustUnderstand = parameters.get(0).getBoolean(); offset = 1; } val = parameters.get(0 + offset); n = parameters.get(1 + offset).getString(); ns = parameters.get(2 + offset).getString(); // Create the header SOAPHeaderElement header = addSOAPRequestHeader.createSOAPHeader(val, ns, n, mustUnderstand); // Add the header try { MessageContext mc = MessageContext.getCurrentContext(); if (mc != null && mc.getResponseMessage() != null && mc.getResponseMessage().getSOAPEnvelope() != null) { // Check to see if the same header has already been added // (same meaning, having the same namespace/name pair) if (mc.getResponseMessage().getSOAPEnvelope().getHeaderByName(header.getNamespaceURI(), header.getName()) != null) throw new cfmRunTimeException(catchDataFactory.generalException("errorCode.runtimeError", "SOAP header value: " + header.getNamespaceURI() + ":" + header.getName() + " already set.")); else mc.getResponseMessage().getSOAPEnvelope().addHeader(header); } else { throw new cfmRunTimeException(catchDataFactory.generalException("errorCode.runtimeError", "Could not set SOAP header value. MessageContext response message is not available. " + "Be sure this is being called from a CFC web service function.")); } } catch (AxisFault ex) { throw new cfmRunTimeException(catchDataFactory.javaMethodException("errorCode.javaException", ex.getClass().getName(), ex.getMessage(), ex)); } return cfBooleanData.TRUE; }
Example 3
Source File: getSOAPRequestHeader.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException { SOAPHeaderElement header = null; String ns = null; String n = null; boolean asXml = false; int offset = 0; if (parameters.size() == 3) { asXml = parameters.get(0).getBoolean(); offset = 1; } n = parameters.get(0 + offset).getString(); ns = parameters.get(1 + offset).getString(); // Get the header try { MessageContext mc = MessageContext.getCurrentContext(); if (mc != null && mc.getRequestMessage() != null && mc.getRequestMessage().getSOAPEnvelope() != null) header = mc.getRequestMessage().getSOAPEnvelope().getHeaderByName(ns, n); else throw new cfmRunTimeException(catchDataFactory.generalException("errorCode.runtimeError", "Could not get SOAP header. MessageContext request message is not available. " + "Be sure this is being called from a CFC web service function.")); } catch (AxisFault ex) { throw new cfmRunTimeException(catchDataFactory.javaMethodException("errorCode.javaException", ex.getClass().getName(), ex.getMessage(), ex)); } // Convert the header value into the desired cfData type return getSOAPHeaderValue(header, asXml); }
Example 4
Source File: ServerPWCallback.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { logger.debug("IN"); for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof WSPasswordCallback) { WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; String userId = pc.getIdentifier(); logger.debug("UserId found from request: " + userId); if (pc.getUsage() == WSPasswordCallback.DECRYPT) { logger.debug("WSPasswordCallback.DECRYPT=" + WSPasswordCallback.DECRYPT); pc.setPassword("security"); // } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) { // logger.debug("WSPasswordCallback.USERNAME_TOKEN = " + pc.getUsage() + " callback usage"); // // for passwords sent in digest mode we need to provide the password, // // because the original one can't be un-digested from the message // String password = getPassword(userId); // // this will throw an exception if the passwords don't match // pc.setPassword(password); } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) { logger.debug("WSPasswordCallback.USERNAME_TOKEN_UNKNOWN = " + pc.getUsage() + " callback usage"); // for passwords sent in clear-text mode we can compare passwords directly // Get the password that was sent String password = pc.getPassword(); // Now pass them to your authentication mechanism SpagoBIUserProfile profile = authenticate(userId, password); // throws WSSecurityException.FAILED_AUTHENTICATION on failure logger.debug("New userId is " + profile.getUniqueIdentifier()); userId = profile.getUniqueIdentifier(); } else { logger.error("WSPasswordCallback usage [" + pc.getUsage() + "] not treated."); throw new UnsupportedCallbackException(callbacks[i], "WSPasswordCallback usage [" + pc.getUsage() + "] not treated."); } // Put userId into MessageContext (for services that depend on profiling) MessageContext mc = MessageContext.getCurrentContext(); logger.debug("Setting userId to " + userId); mc.setProperty(WSHandlerConstants.USER, userId); } else { logger.error("Unrecognized Callback"); throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example 5
Source File: isSOAPRequest.java From openbd-core with GNU General Public License v3.0 | 4 votes |
public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException { return ( MessageContext.getCurrentContext() == null ? cfBooleanData.FALSE : cfBooleanData.TRUE ); }