@Override public void handleMessage(SoapMessage msg) throws Fault { Endpoint ep = msg.getExchange().get(Endpoint.class); sdc.set(ep.getSecurityDomainContext()); try { SecurityToken token = msg.get(SecurityToken.class); SecurityContext context = msg.get(SecurityContext.class); if (token == null || context == null || context.getUserPrincipal() == null) { super.handleMessage(msg); return; } UsernameToken ut = (UsernameToken) token; Subject subject = createSubject( ut.getName(), ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime()); SecurityContext sc = doCreateSecurityContext(context.getUserPrincipal(), subject); msg.put(SecurityContext.class, sc); } finally { if (sdc != null) { sdc.remove(); } } }