1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  package com.hack23.cia.web.impl.ui.common;
20  
21  import java.util.Collection;
22  
23  import org.springframework.security.core.GrantedAuthority;
24  import org.springframework.security.core.userdetails.User;
25  
26  
27  
28  
29  public final class CustomUserDetails extends User {
30  
31      @Override
32  	public int hashCode() {
33  		final int prime = 31;
34  		int result = super.hashCode();
35  		result = prime * result + ((email == null) ? 0 : email.hashCode());
36  		result = prime * result + ((name == null) ? 0 : name.hashCode());
37  		result = prime * result + (newUser ? 1231 : 1237);
38  		return result;
39  	}
40  
41  	@Override
42  	public boolean equals(Object obj) {
43  		if (this == obj)
44  			return true;
45  		if (!super.equals(obj))
46  			return false;
47  		if (getClass() != obj.getClass())
48  			return false;
49  		CustomUserDetails other = (CustomUserDetails) obj;
50  		if (email == null) {
51  			if (other.email != null)
52  				return false;
53  		} else if (!email.equals(other.email))
54  			return false;
55  		if (name == null) {
56  			if (other.name != null)
57  				return false;
58  		} else if (!name.equals(other.name))
59  			return false;
60  		if (newUser != other.newUser)
61  			return false;
62  		return true;
63  	}
64  
65  	
66  	private static final long serialVersionUID = 1L;
67  
68  	
69  	private String email;
70  
71      
72      private String name;
73  
74      
75      private boolean newUser;
76  
77      
78  
79  
80  
81  
82  
83  
84  
85      public CustomUserDetails(final String username, final Collection<GrantedAuthority> authorities) {
86          super(username, "unused", authorities);
87      }
88  
89      
90  
91  
92  
93  
94      public String getEmail() {
95          return email;
96      }
97  
98      
99  
100 
101 
102 
103 
104     public void setEmail(final String email) {
105         this.email = email;
106     }
107 
108     
109 
110 
111 
112 
113     public boolean isNewUser() {
114         return newUser;
115     }
116 
117     
118 
119 
120 
121 
122 
123     public void setNewUser(final boolean newUser) {
124         this.newUser = newUser;
125     }
126 
127     
128 
129 
130 
131 
132     public String getName() {
133         return name;
134     }
135 
136     
137 
138 
139 
140 
141 
142     public void setName(final String name) {
143         this.name = name;
144     }
145 }
146