@Override public SecurityContext authenticate(String username, String password, X509Certificate[] peerCertificates) throws SecurityException { try { CallbackHandler callback = new JaasCertificateCallbackHandler(peerCertificates); LoginContext lc = new LoginContext(jaasConfiguration, callback); lc.login(); Subject subject = lc.getSubject(); String dnName = ""; for (Principal principal : subject.getPrincipals()) { if (principal instanceof UserPrincipal) { dnName = ((UserPrincipal)principal).getName(); break; } } return new JaasCertificateSecurityContext(dnName, subject, peerCertificates); } catch (Exception e) { throw new SecurityException("User name [" + username + "] or password is invalid. " + e.getMessage(), e); } } }
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); String userID = context.getUserName(); if (isUseAuthenticatePrincipal()) { SecurityContext securityContext = context.getSecurityContext(); if (securityContext != null) { Set<?> principals = securityContext.getPrincipals(); if (principals != null) { for (Object candidate : principals) { if (candidate instanceof UserPrincipal) { userID = ((UserPrincipal)candidate).getName(); break; } } } } } messageSend.setUserID(userID); super.send(producerExchange, messageSend); }
@Override public SecurityContext authenticate(String username, String password, X509Certificate[] peerCertificates) throws SecurityException { try { CallbackHandler callback = new JaasCertificateCallbackHandler(peerCertificates); LoginContext lc = new LoginContext(jaasConfiguration, callback); lc.login(); Subject subject = lc.getSubject(); String dnName = ""; for (Principal principal : subject.getPrincipals()) { if (principal instanceof UserPrincipal) { dnName = ((UserPrincipal)principal).getName(); break; } } return new JaasCertificateSecurityContext(dnName, subject, peerCertificates); } catch (Exception e) { throw new SecurityException("User name [" + username + "] or password is invalid. " + e.getMessage(), e); } } }
@Override public SecurityContext authenticate(String username, String password, X509Certificate[] peerCertificates) throws SecurityException { try { CallbackHandler callback = new JaasCertificateCallbackHandler(peerCertificates); LoginContext lc = new LoginContext(jaasConfiguration, callback); lc.login(); Subject subject = lc.getSubject(); String dnName = ""; for (Principal principal : subject.getPrincipals()) { if (principal instanceof UserPrincipal) { dnName = ((UserPrincipal)principal).getName(); break; } } return new JaasCertificateSecurityContext(dnName, subject, peerCertificates); } catch (Exception e) { throw new SecurityException("User name [" + username + "] or password is invalid. " + e.getMessage(), e); } } }
@Override public SecurityContext authenticate(String username, String password, X509Certificate[] peerCertificates) throws SecurityException { try { CallbackHandler callback = new JaasCertificateCallbackHandler(peerCertificates); LoginContext lc = new LoginContext(jaasConfiguration, callback); lc.login(); Subject subject = lc.getSubject(); String dnName = ""; for (Principal principal : subject.getPrincipals()) { if (principal instanceof UserPrincipal) { dnName = ((UserPrincipal)principal).getName(); break; } } return new JaasCertificateSecurityContext(dnName, subject, peerCertificates); } catch (Exception e) { throw new SecurityException("User name [" + username + "] or password is invalid. " + e.getMessage(), e); } } }
Principal nextPrincipal = (Principal)iter.next(); if (nextPrincipal instanceof UserPrincipal) { dnName = ((UserPrincipal)nextPrincipal).getName(); break;
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); String userID = context.getUserName(); if (isUseAuthenticatePrincipal()) { SecurityContext securityContext = context.getSecurityContext(); if (securityContext != null) { Set<?> principals = securityContext.getPrincipals(); if (principals != null) { for (Object candidate : principals) { if (candidate instanceof UserPrincipal) { userID = ((UserPrincipal)candidate).getName(); break; } } } } } messageSend.setUserID(userID); super.send(producerExchange, messageSend); }
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); String userID = context.getUserName(); if (isUseAuthenticatePrincipal()) { SecurityContext securityContext = context.getSecurityContext(); if (securityContext != null) { Set<?> principals = securityContext.getPrincipals(); if (principals != null) { for (Object candidate : principals) { if (candidate instanceof UserPrincipal) { userID = ((UserPrincipal)candidate).getName(); break; } } } } } messageSend.setUserID(userID); super.send(producerExchange, messageSend); }
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); String userID = context.getUserName(); if (isUseAuthenticatePrincipal()) { SecurityContext securityContext = context.getSecurityContext(); if (securityContext != null) { Set<?> principals = securityContext.getPrincipals(); if (principals != null) { for (Object candidate : principals) { if (candidate instanceof UserPrincipal) { userID = ((UserPrincipal)candidate).getName(); break; } } } } } messageSend.setUserID(userID); super.send(producerExchange, messageSend); }
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); String userID = context.getUserName(); if (isUseAuthenticatePrincipal()) { SecurityContext securityContext = context.getSecurityContext(); if (securityContext != null) { Set<?> principals = securityContext.getPrincipals(); if (principals != null) { for (Object candidate : principals) { if (candidate instanceof UserPrincipal) { userID = ((UserPrincipal)candidate).getName(); break; } } } } } messageSend.setUserID(userID); super.send(producerExchange, messageSend); }