This project has retired. For details please refer to its Attic page.
UserCredentials xref
View Javadoc

1   package org.apache.archiva.redback.integration.model;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.archiva.redback.users.User;
23  import org.apache.archiva.redback.users.UserManager;
24  import org.apache.archiva.redback.users.UserManagerException;
25  import org.apache.commons.lang.StringUtils;
26  
27  
28  import java.io.Serializable;
29  
30  /**
31   * UserCredentials
32   *
33   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
34   */
35  public abstract class UserCredentials
36      implements Serializable
37  {
38      // Potentially Editable Field.
39      private String username;
40  
41      // Editable Fields.
42      private String password;
43  
44      private String confirmPassword;
45  
46      private String fullName;
47  
48      private String email;
49  
50      // Display Only Fields.
51      private String timestampAccountCreation;
52  
53      private String timestampLastLogin;
54  
55      private String timestampLastPasswordChange;
56  
57      public User createUser( UserManager um )
58          throws UserManagerException
59      {
60          User user = um.createUser( username, fullName, email );
61  
62          user.setPassword( password );
63  
64          return user;
65      }
66  
67      public String toString()
68      {
69          StringBuilder sb = new StringBuilder();
70  
71          sb.append( "UserCredentials[" );
72          sb.append( "username=" ).append( username );
73          sb.append( ",fullName=" ).append( fullName );
74          sb.append( ",email=" ).append( email );
75          sb.append( ",password=" );
76          if ( StringUtils.isNotEmpty( password ) )
77          {
78              sb.append( "<***>" );
79          }
80          else
81          {
82              sb.append( "<empty>" );
83          }
84          sb.append( ",confirmPassword=" );
85          if ( StringUtils.isNotEmpty( confirmPassword ) )
86          {
87              sb.append( "<***>" );
88          }
89          else
90          {
91              sb.append( "<empty>" );
92          }
93  
94          return sb.append( "]" ).toString();
95      }
96  
97      public String getConfirmPassword()
98      {
99          return confirmPassword;
100     }
101 
102     public void setConfirmPassword( String confirmPassword )
103     {
104         this.confirmPassword = confirmPassword;
105     }
106 
107     public String getEmail()
108     {
109         return email;
110     }
111 
112     public void setEmail( String email )
113     {
114         this.email = email;
115     }
116 
117     public String getFullName()
118     {
119         return fullName;
120     }
121 
122     public void setFullName( String fullName )
123     {
124         this.fullName = fullName;
125     }
126 
127     public String getPassword()
128     {
129         return password;
130     }
131 
132     public void setPassword( String password )
133     {
134         this.password = password;
135     }
136 
137     public String getUsername()
138     {
139         return username;
140     }
141 
142     public void setUsername( String username )
143     {
144         this.username = username;
145     }
146 
147     public abstract boolean isEdit();
148 
149     public String getTimestampAccountCreation()
150     {
151         return timestampAccountCreation;
152     }
153 
154     public String getTimestampLastLogin()
155     {
156         return timestampLastLogin;
157     }
158 
159     public String getTimestampLastPasswordChange()
160     {
161         return timestampLastPasswordChange;
162     }
163 
164     public void setTimestampAccountCreation( String timestampAccountCreation )
165     {
166         this.timestampAccountCreation = timestampAccountCreation;
167     }
168 
169     public void setTimestampLastLogin( String timestampLastLogin )
170     {
171         this.timestampLastLogin = timestampLastLogin;
172     }
173 
174     public void setTimestampLastPasswordChange( String timestampLastPasswordChange )
175     {
176         this.timestampLastPasswordChange = timestampLastPasswordChange;
177     }
178 }