public SecuritySubject getCurrentSubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject(); }
public SecuritySubject getCurrentSubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject(); }
public Message invoke(Message msg) { SecuritySubject subject = msg.getWorkContext().getSubject(); Authentication old = SecurityContextHolder.getContext().getAuthentication(); try { if (subject != null) { Authentication authentication = subject.getDelegate(Authentication.class); SecurityContextHolder.getContext().setAuthentication(authentication); } return next.invoke(msg); } finally { SecurityContextHolder.getContext().setAuthentication(old); } }
public Subject getSecuritySubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject().getJaasSubject(); }
public Subject getSecuritySubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject().getJaasSubject(); }
private PropagatingRunnable createRunnable(Runnable runnable) { WorkContext context = WorkContextCache.getThreadWorkContext(); List<CallbackReference> stack = context.getCallbackReferences(); if (stack != null && !stack.isEmpty()) { // clone the callstack to avoid multiple threads seeing changes stack = new ArrayList<CallbackReference>(stack); } Map<String, Object> headers = context.getHeaders(); if (headers != null && !headers.isEmpty()) { // clone the headers to avoid multiple threads seeing changes headers = new HashMap<String, Object>(headers); } SecuritySubject subject = context.getSubject(); return new PropagatingRunnable(runnable, stack, headers, subject); }
private <T> PropagatingCallable<T> createCallable(Callable<T> callable) { WorkContext context = WorkContextCache.getThreadWorkContext(); List<CallbackReference> stack = context.getCallbackReferences(); if (stack != null && !stack.isEmpty()) { // clone the callstack to avoid multiple threads seeing changes stack = new ArrayList<CallbackReference>(stack); } Map<String, Object> headers = context.getHeaders(); if (headers != null && !headers.isEmpty()) { // clone the headers to avoid multiple threads seeing changes headers = new HashMap<String, Object>(headers); } SecuritySubject subject = context.getSubject(); return new PropagatingCallable<T>(callable, stack, headers, subject); }
public Message invoke(final Message msg) { WorkContext workContext = msg.getWorkContext(); List<CallbackReference> newStack = null; List<CallbackReference> stack = workContext.getCallbackReferences(); if (stack != null && !stack.isEmpty()) { // clone the callstack to avoid multiple threads seeing changes newStack = new ArrayList<CallbackReference>(stack); } Map<String, Object> newHeaders = null; Map<String, Object> headers = workContext.getHeaders(); if (headers != null && !headers.isEmpty()) { // clone the headers to avoid multiple threads seeing changes newHeaders = new HashMap<String, Object>(headers); } SecuritySubject subject = workContext.getSubject(); Object payload = msg.getBody(); AsyncRequest request = new AsyncRequest(next, payload, subject, newStack, newHeaders, monitor); executorService.execute(request); return RESPONSE; }
public void authenticate(HttpServletRequest request, WorkContext context) throws AuthenticationException, NoCredentialsException { if (context.getSubject() != null) { // subject was previously authenticated return; } if (authenticationService == null) { throw new AuthenticationException("Authentication service not installed"); } String header = request.getHeader("Authorization"); if ((header == null) || !header.startsWith("Basic ")) { throw new NoCredentialsException(); } String base64Token = header.substring(6); try { String decoded = new String(Base64.decode(base64Token), "UTF-8"); String username = ""; String password = ""; int delimeter = decoded.indexOf(":"); if (delimeter != -1) { username = decoded.substring(0, delimeter); password = decoded.substring(delimeter + 1); } UsernamePasswordToken token = new UsernamePasswordToken(username, password); SecuritySubject subject = authenticationService.authenticate(token); context.setSubject(subject); // authorized } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } }
options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); Subject subject = msg.getWorkContext().getSubject(); if (subject != null && !subject.getPrincipals().isEmpty()) { Principal primaryPrincipal = subject.getPrincipals().iterator().next();
public Message invoke(Message msg) { WorkContext workContext = msg.getWorkContext(); try { SecuritySubject subject = workContext.getSubject(); if (subject == null) { msg.setBodyWithFault(new ServiceRuntimeException("Subject not authenticated")); return msg; } authorizationService.checkRoles(subject, roles); return next.invoke(msg); } catch (AuthorizationException e) { msg.setBodyWithFault(new ServiceRuntimeException(e)); return msg; } }