/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gravitee.repository.management.model;

import java.util.Date;
import java.util.Objects;
import java.util.Set;

/**
 * @author David BRASSELY (brasseld at gmail.com)
 */
public class User {

	/**
	 * The user name
	 */
	private String username;

	/**
	 * The user password
	 */
	private String password;

	/**
	 * The user email
	 */
	private String email;

	/**
	 * The user first name
	 */
	private String firstname;

	/**
	 * The user last name
	 */
	private String lastname;

	/**
	 * The user roles
	 */
	private Set<String> roles;

	/**
	 * The user creation date
	 */
	private Date createdAt;

	/**
	 * The user last updated date
	 */
	private Date updatedAt;

	/**
	 * The user picture
	 */
	private String picture;

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<String> getRoles() {
		return roles;
	}

	public void setRoles(Set<String> roles) {
		this.roles = roles;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public Date getUpdatedAt() {
		return updatedAt;
	}

	public void setUpdatedAt(Date updatedAt) {
		this.updatedAt = updatedAt;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		User user = (User) o;
		return Objects.equals(username, user.username);
	}

	@Override
	public int hashCode() {
		return Objects.hash(username);
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder("User{");
		sb.append("firstname='").append(firstname).append('\'');
		sb.append(", lastname='").append(lastname).append('\'');
		sb.append(", mail='").append(email).append('\'');
		sb.append(", username='").append(username).append('\'');
		sb.append('}');
		return sb.toString();
	}

}

@@ -876,24 +876,213 @@
  username;%0A%0A
+%09/**%0A%09 * The source when user is coming from an external system (LDAP, ...)%0A%09 */%0A%09private String source;%0A%0A%09/**%0A%09 * The user reference in the external source%0A%09 */%0A%09private String sourceId;%0A%0A
 %09/**%0A%09 * The
@@ -1483,32 +1483,109 @@
 ate updatedAt;%0A%0A
+%09/**%0A%09 * The user last connection date%0A%09 */%0A%09private Date lastConnectionAt;%0A%0A
 %09/**%0A%09 * The use
@@ -2769,24 +2769,446 @@
 icture;%0A%09%7D%0A%0A
+%09public String getSource() %7B%0A%09%09return source;%0A%09%7D%0A%0A%09public void setSource(String source) %7B%0A%09%09this.source = source;%0A%09%7D%0A%0A%09public String getSourceId() %7B%0A%09%09return sourceId;%0A%09%7D%0A%0A%09public void setSourceId(String sourceId) %7B%0A%09%09this.sourceId = sourceId;%0A%09%7D%0A%0A%09public Date getLastConnectionAt() %7B%0A%09%09return lastConnectionAt;%0A%09%7D%0A%0A%09public void setLastConnectionAt(Date lastConnectionAt) %7B%0A%09%09this.lastConnectionAt = lastConnectionAt;%0A%09%7D%0A%0A
 %09@Override%0A%09
@@ -3590,16 +3590,200 @@
 append(%22
+username='%22).append(firstname).append('%5C'');%0A%09%09sb.append(%22, source='%22).append(source).append('%5C'');%0A%09%09sb.append(%22, external_reference='%22).append(sourceId).append('%5C'');%0A%09%09sb.append(%22, 
 firstnam
@@ -3935,67 +3935,8 @@
 ');%0A
-%09%09sb.append(%22, username='%22).append(username).append('%5C'');%0A
 %09%09sb

Improve permission management (#19)