01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: User.java,v 1.2 2002/06/08 00:49:38 mediumnet Exp $
08:
09: package org.ozoneDB.core;
10:
11: import java.io.*;
12: import org.ozoneDB.DxLib.*;
13:
14: /**
15: * This class represents an ozone user. Users can be identified by
16: * its name or ID. A user can be a member of one or more user groups.
17: *
18: *
19: * @author <a href="http://www.softwarebuero.de/">SMB</a>
20: * @version $Revision: 1.2 $Date: 2002/06/08 00:49:38 $
21: * @see Group
22: */
23: public final class User extends DxObject implements Externalizable {
24:
25: protected final static long serialVersionUID = 2;
26: protected final static byte subSerialVersionUID = 1;
27:
28: protected int id;
29:
30: protected String name;
31:
32: protected String passwd;
33:
34: public User() {
35: }
36:
37: public User(String _name, int _id) {
38: name = _name;
39: passwd = name;
40: id = _id;
41: }
42:
43: public String name() {
44: return name;
45: }
46:
47: public Integer id() {
48: return new Integer(id);
49: }
50:
51: protected int getID() {
52: return id;
53: }
54:
55: public boolean equals(Object obj) {
56: if (this == obj) {
57: return true;
58: }
59: if (obj instanceof User && obj != null) {
60: return id == ((User) obj).id;
61: }
62: return false;
63: }
64:
65: public Object clone() {
66: User user = new User();
67: user.name = name;
68: user.id = -1;
69: return user;
70: }
71:
72: public String toString() {
73: return new String("OzoneUser: " + name.toString());
74: }
75:
76: public void writeExternal(ObjectOutput out) throws IOException {
77: out.writeByte(subSerialVersionUID);
78: out.writeObject(name);
79: out.writeInt(id);
80: out.writeObject(passwd);
81: }
82:
83: public synchronized void readExternal(ObjectInput in)
84: throws IOException, ClassNotFoundException {
85: byte streamVersionUID = in.readByte();
86: name = (String) in.readObject();
87: id = in.readInt();
88: passwd = (String) in.readObject();
89: }
90: }
|