public DefaultMuleSession(MuleSession session) { this.id = session.getId(); this.securityContext = session.getSecurityContext(); this.valid = session.isValid(); this.properties = Collections.synchronizedMap(new CaseInsensitiveHashMap()); for (String key : session.getPropertyNamesAsSet()) { this.properties.put(key, createTypedValue(session, key)); } }
@Override public void clearSessionVariables() { session.clearProperties(); }
/** * WARNING: Only use this constructor if the instance of MuleSession has a flowConstruct set. This * constructor is only here for backwards compatibility. */ @Deprecated public DefaultMuleEvent(MuleMessage message, URI messageSourceURI, MessageExchangePattern exchangePattern, MuleSession session, int timeout, Credentials credentials, OutputStream outputStream) { this(message, messageSourceURI, exchangePattern, session.getFlowConstruct(), session, timeout, credentials, outputStream); }
private TypedValue createTypedValue(MuleSession session, String key) { return new TypedValue(session.getProperty(key), session.getPropertyDataType(key)); }
private void addAndOverrideSessionProperties(MuleSession session, MuleEvent event) { for (String name : event.getSession().getPropertyNamesAsSet()) { session.setProperty(name, event.getSession().getProperty(name)); } }
event.getSession().setSecurityContext(context); throw new UnauthorisedException(event, event.getSession().getSecurityContext(), this);
event.getSession().setSecurityContext(context);
throws SecurityException, SecurityProviderNotFoundException if (event.getSession().getSecurityContext() == null) throw new UnauthorisedException(event, event.getSession().getSecurityContext(), event.getEndpoint(), this); Authentication auth = event.getSession().getSecurityContext().getAuthentication(); if (isAuthenticate())
public void storeSessionInfoToMessage(MuleSession session, MuleMessage message) throws MuleException { StringBuilder buf = new StringBuilder(); buf.append(getSessionIDKey()).append("=").append(session.getId()); for (String key : session.getPropertyNamesAsSet()) { buf.append(";"); String propertyValue = session.getProperty(key).toString(); buf.append(key).append("=").append(propertyValue); if (logger.isDebugEnabled()) { logger.debug(String.format("Adding property to session header: %s=%s", key, session.getProperty(key))); } } String sessionString = buf.toString(); if (logger.isDebugEnabled()) { logger.debug("Adding session header to message: " + sessionString); } sessionString = (String) encoder.transform(sessionString); message.setOutboundProperty(MuleProperties.MULE_SESSION_PROPERTY, sessionString); }
@Override public <T> T getSessionVariable(String key) { return session.<T> getProperty(key); }
if (userHeader == null) throw new CredentialsNotSetException(event, event.getSession().getSecurityContext(), this); event.getSession().setSecurityContext(context);
event.getSession().setSecurityContext(context);
throws SecurityException, SecurityProviderNotFoundException SecurityContext securityContext = event.getSession().getSecurityContext(); if (securityContext == null)
protected MuleSession getMergedSession(MuleEvent[] events) { MuleSession session = new DefaultMuleSession(events[0].getSession()); for (int i = 1; i < events.length; i++) { for (String name : events[i].getSession().getPropertyNamesAsSet()) { session.setProperty(name, events[i].getSession().getProperty(name)); } } return session; }
event.getSession().setSecurityContext(context); throw new UnauthorisedException(event, event.getSession().getSecurityContext(), this);
RequestContext.getEvent().getSession().setSecurityContext(secContext);
@Override protected void authenticateOutbound(MuleEvent event) throws SecurityException, SecurityProviderNotFoundException, CryptoFailureException { SecurityContext securityContext = event.getSession().getSecurityContext(); if (securityContext == null) { if (isAuthenticate()) { throw new UnauthorisedException(event, securityContext, this); } else { return; } } Authentication auth = securityContext.getAuthentication(); if (isAuthenticate()) { auth = getSecurityManager().authenticate(auth); if (logger.isDebugEnabled()) { logger.debug("Authentication success: " + auth.toString()); } } String token = auth.getCredentials().toString(); String header = new String(strategy.encrypt(token.getBytes(), null)); getCredentialsAccessor().setCredentials(event, header); }
/** * WARNING: Only use this constructor if the instance of MuleSession has a flowConstruct set. This * constructor is only here for backwards compatibility. */ @Deprecated public DefaultMuleEvent(MuleMessage message, URI messageSourceURI, String messageSourceName, MessageExchangePattern exchangePattern, MuleSession session, int timeout, Credentials credentials, OutputStream outputStream, String encoding, boolean transacted, boolean synchronous, Object replyToDestination, ReplyToHandler replyToHandler) { this(message, messageSourceURI, messageSourceName, exchangePattern, session.getFlowConstruct(), session, timeout, credentials, outputStream, encoding, transacted, synchronous, replyToDestination, replyToHandler); }
resultSession.setSecurityContext(null); connector.getSessionHandler().storeSessionInfoToMessage(resultSession, resultEvent.getMessage());
if (session.getSecurityContext() != null && session.getSecurityContext().getAuthentication() != null) session.getSecurityContext().getAuthentication().setEvent(event);