View Javadoc
1   /**
2    * Waffle (https://github.com/dblock/waffle)
3    *
4    * Copyright (c) 2010 - 2015 Application Security, Inc.
5    *
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of the Eclipse Public License v1.0
8    * which accompanies this distribution, and is available at
9    * http://www.eclipse.org/legal/epl-v10.html
10   *
11   * Contributors:
12   *     Application Security, Inc.
13   */
14  package waffle.windows.auth;
15  
16  import java.io.Serializable;
17  
18  /**
19   * A flattened Windows Account used in a Windows principal.
20   * 
21   * @author dblock[at]dblock[dot]org
22   */
23  public class WindowsAccount implements Serializable {
24  
25      /** The Constant serialVersionUID. */
26      private static final long serialVersionUID = 1L;
27      
28      /** The sid string. */
29      private final String            sidString;
30      
31      /** The fqn. */
32      private final String            fqn;
33      
34      /** The name. */
35      private final String            name;
36      
37      /** The domain. */
38      private final String            domain;
39  
40      /**
41       * Instantiates a new windows account.
42       *
43       * @param account
44       *            the account
45       */
46      public WindowsAccount(final IWindowsAccount account) {
47          this.sidString = account.getSidString();
48          this.fqn = account.getFqn();
49          this.name = account.getName();
50          this.domain = account.getDomain();
51      }
52  
53      /**
54       * Gets the sid string.
55       *
56       * @return the sid string
57       */
58      public String getSidString() {
59          return this.sidString;
60      }
61  
62      /**
63       * Gets the fqn.
64       *
65       * @return the fqn
66       */
67      public String getFqn() {
68          return this.fqn;
69      }
70  
71      /**
72       * Gets the name.
73       *
74       * @return the name
75       */
76      public String getName() {
77          return this.name;
78      }
79  
80      /**
81       * Gets the domain.
82       *
83       * @return the domain
84       */
85      public String getDomain() {
86          return this.domain;
87      }
88  
89      /* (non-Javadoc)
90       * @see java.lang.Object#equals(java.lang.Object)
91       */
92      @Override
93      public boolean equals(final Object o) {
94  
95          if (this == o) {
96              return true;
97          }
98  
99          if (!(o instanceof WindowsAccount)) {
100             return false;
101         }
102 
103         return ((WindowsAccount) o).getSidString().equals(this.getSidString());
104     }
105 
106     /* (non-Javadoc)
107      * @see java.lang.Object#hashCode()
108      */
109     @Override
110     public int hashCode() {
111         return this.getSidString().hashCode();
112     }
113 }