// Path: app/models/User.java
// @Entity
// public class User extends BaseModel {
// 	
// 	@Required
// 	@MaxSize(45)
// 	@Unique
// 	@Column(length=45, nullable=false, unique=true)
// 	public String username;
// 	
// 	@Column(length=255, nullable=true)
// 	public String password;
// 	
// 	@Required
// 	@MaxSize(45)
// 	@Column(length=45, nullable=false)
// 	public String firstName;
// 	
// 	@Required
// 	@MaxSize(45)
// 	@Column(length=45, nullable=false)
// 	public String lastName;
// 
//     public boolean needsPasswordReset = false;
// 	
// 	@Column(name="last_access")
// 	public Date lastAccess;
// 
//     @Column(name="last_activity")
//     public Date lastActivity;
// 	
// 	@ManyToOne(optional=false)
// 	public UserRole role;
// 
// 	private void encryptPassword() {
// 		if (this.password!=null) {
// 			this.password = Crypto.encryptAES(this.password);
// 		}
// 	}
// 	
// 	private void decryptPassword() {
// 		if (this.password!=null) {
// 			this.password = Crypto.decryptAES(this.password);
// 		}
// 	}
// 
//     public String getFullName() {
//         String name = "";
// 
//         if (this.firstName!=null && !this.firstName.isEmpty()) {
//             name = firstName;
//         }
// 
//         if (this.lastName!=null && !this.lastName.isEmpty()) {
// 
//             if (!name.isEmpty()) {
//                 name += " ";
//             }
// 
//             name += lastName;
//         }
// 
//         return name;
//     }
// 	
// 	@Override
// 	protected void onPrePersist() {
// 		super.onPrePersist();
// 		encryptPassword();
// 	}
// 	
// 	@Override
// 	protected void onPreUpdate() {
// 		super.onPreUpdate();
// 		encryptPassword();
// 	}
// 	
// 	@Override
// 	protected void onPostLoad() {
// 		super.onPostLoad();
// 		decryptPassword();
// 	}
// }


import models.User;
import play.data.validation.Equals;
import play.data.validation.MaxSize;
import play.data.validation.MinSize;
import play.data.validation.Required;
import play.i18n.Messages;
import play.mvc.With;
/*
 *   Copyright 2016 ITM, S.A.
 *
 *   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`](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 controllers;


/**
 * Created by jandrad on 21/09/15.
 */

@With(Secure.class)
public class Profile extends AuthenticatedController {

    public static void index() {
// Path: app/models/User.java
// @Entity
// public class User extends BaseModel {
// 	
// 	@Required
// 	@MaxSize(45)
// 	@Unique
// 	@Column(length=45, nullable=false, unique=true)
// 	public String username;
// 	
// 	@Column(length=255, nullable=true)
// 	public String password;
// 	
// 	@Required
// 	@MaxSize(45)
// 	@Column(length=45, nullable=false)
// 	public String firstName;
// 	
// 	@Required
// 	@MaxSize(45)
// 	@Column(length=45, nullable=false)
// 	public String lastName;
// 
//     public boolean needsPasswordReset = false;
// 	
// 	@Column(name="last_access")
// 	public Date lastAccess;
// 
//     @Column(name="last_activity")
//     public Date lastActivity;
// 	
// 	@ManyToOne(optional=false)
// 	public UserRole role;
// 
// 	private void encryptPassword() {
// 		if (this.password!=null) {
// 			this.password = Crypto.encryptAES(this.password);
// 		}
// 	}
// 	
// 	private void decryptPassword() {
// 		if (this.password!=null) {
// 			this.password = Crypto.decryptAES(this.password);
// 		}
// 	}
// 
//     public String getFullName() {
//         String name = "";
// 
//         if (this.firstName!=null && !this.firstName.isEmpty()) {
//             name = firstName;
//         }
// 
//         if (this.lastName!=null && !this.lastName.isEmpty()) {
// 
//             if (!name.isEmpty()) {
//                 name += " ";
//             }
// 
//             name += lastName;
//         }
// 
//         return name;
//     }
// 	
// 	@Override
// 	protected void onPrePersist() {
// 		super.onPrePersist();
// 		encryptPassword();
// 	}
// 	
// 	@Override
// 	protected void onPreUpdate() {
// 		super.onPreUpdate();
// 		encryptPassword();
// 	}
// 	
// 	@Override
// 	protected void onPostLoad() {
// 		super.onPostLoad();
// 		decryptPassword();
// 	}
// }


// Path: app/controllers/Profile.java
import models.User;
import play.data.validation.Equals;
import play.data.validation.MaxSize;
import play.data.validation.MinSize;
import play.data.validation.Required;
import play.i18n.Messages;
import play.mvc.With;

/*
 *   Copyright 2016 ITM, S.A.
 *
 *   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`](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 controllers;


/**
 * Created by jandrad on 21/09/15.
 */

@With(Secure.class)
public class Profile extends AuthenticatedController {

    public static void index() {
        User user = getUser();