<commit_before>/*
 * Copyright (c) 2014 <NAME>' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   <NAME> 
 *      - Initial concept and initial implementation
 */
package coyote.commons.security;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;


/**
 * This class models a list of roles and their associated permissions.
 */
public class Login {

  /** This logins identifier */
  String id;

  /** The credentials used to authenticate this login */
  CredentialSet credentials;

  /** The principal (entity) of this login. */
  SecurityPrincipal principal;

  /** A map of role names this login assumes. */
  HashSet<String> roles = new HashSet<String>();


  /**
   * Constructs a Login with a security principal with the given name and a 
   * credential set with the given password.
   * 
   * @param name
   * @param password
   */
  public Login( String name, String password ) {
    principal = new GenericSecurityPrincipal(name);
    credentials = new CredentialSet(CredentialSet.PASSWORD, password);
  }




  public Login( SecurityPrincipal principal, CredentialSet creds ) {
    this.principal = principal;
    credentials = creds;
  }




  public Login( CredentialSet creds ) {
    credentials = creds;
  }
<commit_msg>Username Password constructor defaults to single round MD5 hash of credential for security.<commit_after>/*
 * Copyright (c) 2014 <NAME>' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   <NAME> 
 *      - Initial concept and initial implementation
 */
package coyote.commons.security;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;


/**
 * This class models a list of roles and their associated permissions.
 */
public class Login {

  /** This logins identifier */
  String id;

  /** The credentials used to authenticate this login */
  CredentialSet credentials;

  /** The principal (entity) of this login. */
  SecurityPrincipal principal;

  /** A map of role names this login assumes. */
  HashSet<String> roles = new HashSet<String>();




  /**
   * Constructs a Login with a security principal with the given name and a 
   * credential set with the given password.
   * 
   * <p>The password is saved as a single round MD5 hash of its UTF8 encoding. 
   * This is to help ensure that the password is not stored in an easily 
   * retrievable format. This implies that the clear text password is not used 
   * in the system for authentication and that if the password is exposed by 
   * the system, the viewer of the password value will not have the original 
   * password provided by the user.</p>  
   * 
   * @param name name of the security principal (i.e. username)
   * @param password authentication credential
   */
  public Login( String name, String password ) {
    principal = new GenericSecurityPrincipal( name );
    credentials = new CredentialSet( CredentialSet.PASSWORD, password, 1 );
  }




  public Login( SecurityPrincipal principal, CredentialSet creds ) {
    this.principal = principal;
    credentials = creds;
  }

{'fraction_non_alphanumeric': 0.08191520046149409, 'fraction_numerical': 0.003461205653302567, 'mean_word_length': 3.3188044831880448, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '407992', 'n_tokens_mistral': 957, 'n_tokens_neox': 885, 'n_words': 385}