All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.orientechnologies.orient.server.OClientSessions Maven / Gradle / Ivy

There is a newer version: 3.2.33
Show newest version
package com.orientechnologies.orient.server;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.orientechnologies.orient.core.metadata.security.OToken;

public class OClientSessions {

  private OToken                  token;
  private List connections = Collections.synchronizedList(new ArrayList());
  private byte[]                  binaryToken;

  public OClientSessions(byte[] binaryToken, OToken token) {
    this.binaryToken = binaryToken;
    this.token = token;
  }

  public void addConnection(OClientConnection conn) {
    this.connections.add(conn);
  }

  public void removeConnection(OClientConnection conn) {
    this.connections.remove(conn);
  }

  @Override
  public int hashCode() {
    return Arrays.hashCode(binaryToken);
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (!(obj instanceof OClientSessions))
      return false;
    return Arrays.equals(this.binaryToken, ((OClientSessions) obj).binaryToken);
  }

  public boolean isActive() {
    return !connections.isEmpty();
  }

  public List getConnections() {
    return connections;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy