static ClientUserAuths getClientUserAuths(ClientProxyMembershipID proxyId) { ClientUserAuths clientUserAuths = new ClientUserAuths(proxyId.hashCode()); ClientUserAuths returnedClientUserAuths = proxyIdVsClientUserAuths.putIfAbsent(proxyId, clientUserAuths); if (returnedClientUserAuths == null) { return clientUserAuths; } return returnedClientUserAuths; }
public void cleanup(boolean fromCacheClientProxy) { for (UserAuthAttributes userAuth : this.uniqueIdVsUserAuth.values()) { // isDurable is checked for multiuser in CQ if (!fromCacheClientProxy && !userAuth.isDurable()) {// from serverConnection class cleanUserAuth(userAuth); } else if (fromCacheClientProxy && userAuth.isDurable()) {// from cacheclientProxy class cleanUserAuth(userAuth); } } // Logout the subjects for (Long subjectId : uniqueIdVsSubject.keySet()) { removeSubject(subjectId); } }
private void cleanClientAuths() { if (this.clientUserAuths != null) { this.clientUserAuths.cleanup(false); } }
public void removeUserAuth(Message message, boolean keepAlive) { try { byte[] secureBytes = message.getSecureBytes(); secureBytes = this.handshake.getEncryptor().decryptBytes(secureBytes); // need to decrypt it first then get connectionid AuthIds aIds = new AuthIds(secureBytes); long connId = aIds.getConnectionId(); if (connId != this.connectionId) { throw new AuthenticationFailedException("Authentication failed"); } try { // first try integrated security boolean removed = this.clientUserAuths.removeSubject(aIds.getUniqueId()); // if not successful, try the old way if (!removed) { this.clientUserAuths.removeUserId(aIds.getUniqueId(), keepAlive); } } catch (NullPointerException exception) { // Bug #52023. logger.debug("Exception {}", exception); } } catch (Exception exception) { throw new AuthenticationFailedException("Authentication failed", exception); } }
public void fillPreviousCQAuth(ClientUserAuths previousClientUserAuths) { for (Iterator<Map.Entry<String, UserAuthAttributes>> iter = previousClientUserAuths.cqNameVsUserAuth.entrySet().iterator(); iter.hasNext();) { Map.Entry<String, UserAuthAttributes> ent = iter.next(); String cqName = ent.getKey(); UserAuthAttributes prevUaa = ent.getValue(); UserAuthAttributes newUaa = this.cqNameVsUserAuth.putIfAbsent(cqName, prevUaa); if (newUaa != null) { previousClientUserAuths.cleanUserAuth(prevUaa); } } } }
uaa = this.clientUserAuths.getUserAuthAttributes(uniqueId); } catch (NullPointerException npe) { if (this.isTerminated()) {
public long putUserAuth(UserAuthAttributes userAuthAttr) { // TODO:hitesh should we do random here // long newId = counter.getAndIncrement(); long newId = getNextID(); uniqueIdVsUserAuth.put(newId, userAuthAttr); return newId; }
private void setAuthAttributes() throws Exception { logger.debug("setAttributes()"); Object principal = getHandshake().verifyCredentials(); long uniqueId; if (principal instanceof Subject) { uniqueId = getClientUserAuths(getProxyID()).putSubject((Subject) principal); } else { // this sets principal in map as well.... uniqueId = getUniqueId((Principal) principal); setPrincipal((Principal) principal); } setUserAuthId(uniqueId); }
private void reinitializeClientAuths() { if (this.clientUserAuths != null && AcceptorImpl.isPostAuthzCallbackPresent()) { synchronized (this.clientUserAuthsLock) { ClientUserAuths newClientAuth = ServerConnection.getClientUserAuths(this.proxyID); newClientAuth.fillPreviousCQAuth(this.clientUserAuths); this.clientUserAuths = newClientAuth; } } }
private long setUserAuthorizeAndPostAuthorizeRequest(AuthorizeRequest authzRequest, AuthorizeRequestPP postAuthzRequest) throws IOException { UserAuthAttributes userAuthAttr = new UserAuthAttributes(authzRequest, postAuthzRequest); if (this.clientUserAuths == null) { this.initializeClientUserAuths(); } try { return this.clientUserAuths.putUserAuth(userAuthAttr); } catch (NullPointerException exception) { if (this.isTerminated()) { // Bug #52023. throw new IOException("Server connection is terminated."); } throw exception; } }
long uniqueId = getUniqueId(); String messageType = MessageType.getString(this.requestMessage.getMessageType()); Subject subject = this.clientUserAuths.getSubject(uniqueId); if (subject != null) { threadState = securityService.bindSubject(subject);
public boolean removeUserId(long userId, boolean keepAlive) { UserAuthAttributes uaa = uniqueIdVsUserAuth.get(userId); if (uaa != null && !(uaa.isDurable() && keepAlive)) { uaa = uniqueIdVsUserAuth.remove(userId); logger.debug("UserAuth of {} removed."); if (uaa != null) { cleanUserAuth(uaa); return true; } } return false; }
public AuthorizeRequestPP getPostAuthzRequest() throws AuthenticationRequiredException, IOException { if (!AcceptorImpl.isAuthenticationRequired()) { return null; } if (securityService.isIntegratedSecurity()) { return null; } // look client version and return authzrequest // for backward client it will be store in member variable userAuthId // for other look "requestMessage" here and get unique-id from this to get the authzrequest long uniqueId = getUniqueId(); UserAuthAttributes uaa = null; try { uaa = this.clientUserAuths.getUserAuthAttributes(uniqueId); } catch (NullPointerException npe) { if (this.isTerminated()) { // Bug #52023. throw new IOException("Server connection is terminated."); } else { logger.debug("Unexpected exception {}", npe); } } if (uaa == null) { throw new AuthenticationRequiredException("User authorization attributes not found."); } return uaa.getPostAuthzRequest(); }
public long putSubject(Subject subject) { long newId = getNextID(); uniqueIdVsSubject.put(newId, subject); logger.debug("Subject of {} added.", newId); return newId; }
if (principal instanceof Subject) { Subject subject = (Subject) principal; uniqueId = this.clientUserAuths.putSubject(subject); } else {
public void setUserAuthAttributesForCq(String cqName, long uniqueId, boolean isDurable) { UserAuthAttributes uaa = this.uniqueIdVsUserAuth.get(uniqueId); if (uaa != null) { if (!isDurable) this.cqNameVsUserAuth.put(cqName, uaa); else { UserAuthAttributes oldUaa = this.cqNameVsUserAuth.put(cqName, uaa); if (oldUaa != null) { if (oldUaa != uaa)// clean earlier one { this.cleanUserAuth(oldUaa); // add durable(increment) uaa.setDurable(); } else { // if looks extra call from client } } else { uaa.setDurable(); } } } }
this.clientUserAuths.getUserAuthAttributes(cqNames[i]).getPostAuthzRequest(); if (logger.isDebugEnabled() && postAuthCallback == null) { logger.debug("CCP clientCq post callback is null"); this.clientUserAuths.getUserAuthAttributes(cqNames[i]);
this.postAuthzCallback = null; } else if (this.clientUserAuths != null) {// for multiple users this.clientUserAuths.cleanup(true); this.clientUserAuths = null;