<commit_before>/*
 * Copyright (C) 2005 <NAME>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the
 *
 * Free Software Foundation, Inc.
 * 59 Temple Place, Suite 330
 * Boston, MA 02111-1307
 * USA
 *
 * Or, you may view it online at
 * http://www.opensource.org/licenses/lgpl-license.php
 */

package org.jsecurity.ri.authc.module.dao;

import org.jsecurity.authc.module.AuthenticationInfo;

import java.security.Permission;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

/**
 * Simple implementation of the {@link org.jsecurity.authc.module.AuthenticationInfo} interface that
 * contains all necessary information as instance variables and exposes them
 * via getters and setters using standard JavaBean notation.
 *
 * @see org.jsecurity.authc.module.AuthenticationInfo
 *
 * @since 0.1
 * @author <NAME>
 */
public class SimpleAuthenticationInfo implements AuthenticationInfo {

    /*--------------------------------------------
    |             C O N S T A N T S             |
    ============================================*/

    /*--------------------------------------------
    |    I N S T A N C E   V A R I A B L E S    |
    ============================================*/
    private List<Principal> principals;

    private Object credentials;

    /**
     * The collection of roles that apply to this user.
     */
    private Collection<String> roles;

    /**
     * The collection of permissions that apply to this user.
     */
    private Collection<Permission> permissions;

    /**
     * True if the user's account is locked, false otherwise.
     */
    private boolean accountLocked = false;

    /**
     * True if the user's credentials are expired, false otherwise.
     */
    private boolean credentialsExpired = false;

    /**
     * True if the user is allowed to log in concurrently from two
     * separate locations, false otherwise.
     */
    private boolean concurrentLoginsAllowed = true;

    /*--------------------------------------------
    |         C O N S T R U C T O R S           |
    ============================================*/
    public SimpleAuthenticationInfo() {
        this.principals = new ArrayList<Principal>();
        this.roles = new HashSet<String>();
        this.permissions = new HashSet<Permission>();
    }


    public SimpleAuthenticationInfo(Principal principal, Object credentials, Collection<String> roles) {
        this.principals = new ArrayList<Principal>();
        this.principals.add( principal );
        this.credentials = credentials;
        this.roles = roles;
    }


    public SimpleAuthenticationInfo(Principal principal, Object credentials, Collection<String> roles, Collection<Permission> permissions) {
        this.principals = new ArrayList<Principal>();
        this.principals.add( principal );
        this.credentials = credentials;
        this.roles = roles;
        this.permissions = permissions;
    }


    public SimpleAuthenticationInfo(Principal principal, Object credentials, Collection<String> roles, boolean accountLocked, boolean credentialsExpired, boolean concurrentLoginsAllowed) {
        this.principals = new ArrayList<Principal>();
        this.principals.add( principal );
        this.credentials = credentials;
        this.roles = roles;
        this.accountLocked = accountLocked;
        this.credentialsExpired = credentialsExpired;
        this.concurrentLoginsAllowed = concurrentLoginsAllowed;
    }

<commit_msg>Added constructor.<commit_after>/*
 * Copyright (C) 2005 <NAME>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the
 *
 * Free Software Foundation, Inc.
 * 59 Temple Place, Suite 330
 * Boston, MA 02111-1307
 * USA
 *
 * Or, you may view it online at
 * http://www.opensource.org/licenses/lgpl-license.php
 */

package org.jsecurity.ri.authc.module.dao;

import org.jsecurity.authc.module.AuthenticationInfo;

import java.security.Permission;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

/**
 * Simple implementation of the {@link org.jsecurity.authc.module.AuthenticationInfo} interface that
 * contains all necessary information as instance variables and exposes them
 * via getters and setters using standard JavaBean notation.
 *
 * @see org.jsecurity.authc.module.AuthenticationInfo
 *
 * @since 0.1
 * @author <NAME>
 */
public class SimpleAuthenticationInfo implements AuthenticationInfo {

    /*--------------------------------------------
    |             C O N S T A N T S             |
    ============================================*/

    /*--------------------------------------------
    |    I N S T A N C E   V A R I A B L E S    |
    ============================================*/
    private List<Principal> principals;

    private Object credentials;

    /**
     * The collection of roles that apply to this user.
     */
    private Collection<String> roles;

    /**
     * The collection of permissions that apply to this user.
     */
    private Collection<Permission> permissions;

    /**
     * True if the user's account is locked, false otherwise.
     */
    private boolean accountLocked = false;

    /**
     * True if the user's credentials are expired, false otherwise.
     */
    private boolean credentialsExpired = false;

    /**
     * True if the user is allowed to log in concurrently from two
     * separate locations, false otherwise.
     */
    private boolean concurrentLoginsAllowed = true;

    /*--------------------------------------------
    |         C O N S T R U C T O R S           |
    ============================================*/
    public SimpleAuthenticationInfo() {
        this.principals = new ArrayList<Principal>();
        this.roles = new HashSet<String>();
        this.permissions = new HashSet<Permission>();
    }


    public SimpleAuthenticationInfo(List<Principal> principals, Object credentials) {
        this.principals = principals;
        this.credentials = credentials;
    }


    public SimpleAuthenticationInfo(Principal principal, Object credentials, Collection<String> roles) {
        this.principals = new ArrayList<Principal>();
        this.principals.add( principal );
        this.credentials = credentials;
        this.roles = roles;
    }


    public SimpleAuthenticationInfo(Principal principal, Object credentials, Collection<String> roles, Collection<Permission> permissions) {
        this.principals = new ArrayList<Principal>();
        this.principals.add( principal );
        this.credentials = credentials;
        this.roles = roles;
        this.permissions = permissions;
    }


    public SimpleAuthenticationInfo(Principal principal, Object credentials, Collection<String> roles, boolean accountLocked, boolean credentialsExpired, boolean concurrentLoginsAllowed) {
        this.principals = new ArrayList<Principal>();
        this.principals.add( principal );
        this.credentials = credentials;
        this.roles = roles;
        this.accountLocked = accountLocked;
        this.credentialsExpired = credentialsExpired;
        this.concurrentLoginsAllowed = concurrentLoginsAllowed;
    }


{'fraction_non_alphanumeric': 0.13959540991364014, 'fraction_numerical': 0.005205252573050988, 'mean_word_length': 2.724229074889868, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '380936', 'n_tokens_mistral': 2134, 'n_tokens_neox': 2029, 'n_words': 752}