/**
 * Licensed to Apereo under one or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information regarding copyright ownership. Apereo
 * licenses this file to you 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 the
 * following location:
 *
 * <p>http://www.apache.org/licenses/LICENSE-2.0
 *
 * <p>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 org.apereo.portal.security;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import javax.annotation.PostConstruct;

import org.apereo.portal.properties.PropertiesManager;
import org.apereo.portal.security.provider.PersonImpl;
import org.apereo.portal.security.provider.RestrictedPerson;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Creates a person.
 *
 * <p>Can create representations of a <i>system</i> user and a <i>guest</i> user.
 *
 * <p><i>system</i> users have an ID of 0
 *
 * <p><i>guest</i> users have both of the following characteristics<br>
 *
 * <ol>
 *   <li>User is not successfully authenticated with the portal.
 *   <li>User name matches the value of the property <code>
 *       org.apereo.portal.security.PersonFactory.guest_user_name</code> in <code>portal.properties
 *       </code>.
 * </ol>
 */
@Component
public class PersonFactory {

    @Value("${org.apereo.portal.security.PersonFactory.guest_user_names:guest}")
    private String guestUsernamesProperty;

    private static List<String> guestUsernames = null;

    @PostConstruct
    public void init() {
        guestUsernames = Collections.unmodifiableList(Arrays.asList(guestUsernamesProperty.split(",")));
    }

    /**
     * Collection of guest user names specified in portal.properties as <code>
     * org.apereo.portal.security.PersonFactory.guest_user_names</code>. The value of this property
     * is a comma-delimited list.
     *
     * @since 5.0
     */
    public static List<String> getGuestUsernames() {
        if (guestUsernames == null) {
            throw new IllegalStateException("The guestUsernames collection has not been initialized");
        }
        return guestUsernames;
    }

    /**
     * Creates an empty <code>IPerson</code> implementation.
     *
     * @return an empty <code>IPerson</code> implementation
     */
    public static IPerson createPerson() {
        return new PersonImpl();
    }

    /**
     * Creates a <i>system</i> user.
     *
     * @return a <i>system</i> user
     */
    public static IPerson createSystemPerson() {
        IPerson person = createPerson();
        person.setAttribute(IPerson.USERNAME, "SYSTEM_USER");
        person.setID(0);
        return person;
    }

    /**
     * Creates a <i>restricted</i> user.
     *
     * @return <i>restricted</i> user
     */
    public static RestrictedPerson createRestrictedPerson() {
        IPerson person = createPerson();
        return new RestrictedPerson(person);
    }
}

@@ -898,17 +898,16 @@
 l.List;%0A
-%0A
 import j
@@ -940,64 +940,8 @@
 uct;
-%0A%0Aimport org.apereo.portal.properties.PropertiesManager;
 %0Aimp
@@ -1949,16 +1949,32 @@
 rnames =
+%0A               
  Collect
@@ -2442,16 +2442,37 @@
 ception(
+%0A                    
 %22The gue

Allow the CI to finish