/* 
 * Copyright 2015 Ryan Gilera.
 *
 * 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 com.github.daytron.revworks.authentication;

import com.github.daytron.revworks.data.UserType;
import java.security.Principal;

/**
 *
 * @author Ryan Gilera
 */
abstract class User implements Principal {
    private final String id;
    private final String firstName;
    private final String lastName;
    private final UserType userType;
    
    /**
     * Only {@link UserAuthentication} may create new instances.
     *
     * @param name
     */
    User(String id, String firstname, String lastname, UserType userType) {
        this.id = id;
        this.firstName = firstname;
        this.lastName = lastname;
        this.userType = userType;
    }

    @Override
    public String getName() {
        return this.firstName + " " + this.lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public UserType getUserType() {
        return userType;
    }

    public String getId() {
        return id;
    }
    
    public boolean isLecturerUser() {
        return userType == UserType.LECTURER;
    }
    
    public boolean isStudentUser() {
        return userType == UserType.STUDENT;
    }
}

@@ -804,16 +804,17 @@
 cipal %7B%0A
+%0A
     priv
@@ -942,20 +942,16 @@
 erType;%0A
-    
 %0A    /**
@@ -1267,68 +1267,538 @@
     
-@Override%0A    public String getName() %7B%0A        return this.
+/**%0A     * Returns the unique identifier of a user. %7B@link Principal%7D class default%0A     * implementation of this method refers to the username of a user to%0A     * identify them uniquely but since there are two different usernames from%0A     * two different user types, it is better to treat it as User ID as they are%0A     * identified in the database.%0A     *%0A     * @return A unique ID of the user%0A     */%0A    @Override%0A    public String getName() %7B%0A        return this.id;%0A    %7D%0A%0A    public String getFullName() %7B%0A        return 
 firs
@@ -1811,21 +1811,16 @@
 + %22 %22 + 
-this.
 lastName
@@ -2034,66 +2034,8 @@
  %7D%0A%0A
-    public String getId() %7B%0A        return id;%0A    %7D%0A    %0A
     
@@ -2120,20 +2120,16 @@
 ;%0A    %7D%0A
-    
 %0A    pub

Modify getName from Principal class to return user id instead and create a separate method to return user full name