<commit_before>package gov.healthit.chpl.security;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import gov.healthit.chpl.auth.authentication.Claim;
import gov.healthit.chpl.auth.authentication.UserAuthenticator;
import gov.healthit.chpl.auth.jwt.JWTAuthor;
import gov.healthit.chpl.auth.jwt.JWTCreationException;
import gov.healthit.chpl.auth.user.User;
import gov.healthit.chpl.auth.user.UserManager;



public class CHPLAuthenticator extends UserAuthenticator {

	@Autowired
	private JWTAuthor jwtAuthor;
	
	@Autowired
	private UserManager userManager;
	
	@Override
	public String getJWT(User user) throws JWTCreationException {
		
		String jwt = null;
		
		Map<String, List<String>> claims = new HashMap<String, List<String>>();
		List<String> roleStrings = new ArrayList<String>();
		
		for (Claim role : user.getClaims()){
			roleStrings.add(role.getAuthority());
		}
		claims.put("Authorities", roleStrings);
		
		
		
		jwt = jwtAuthor.createJWT(user.getSubjectName(), claims);
		return jwt;
		
	}
	
	/*
	private List<String> getPermissions(User user){
		
		//userManager
		
	}
	*/
}<commit_msg>Added CHPLAuthenticator<commit_after>package gov.healthit.chpl.security;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import gov.healthit.chpl.auth.authentication.Claim;
import gov.healthit.chpl.auth.authentication.UserAuthenticator;
import gov.healthit.chpl.auth.jwt.JWTAuthor;
import gov.healthit.chpl.auth.jwt.JWTCreationException;
import gov.healthit.chpl.auth.user.User;
import gov.healthit.chpl.auth.user.UserManager;



public class CHPLAuthenticator extends UserAuthenticator {

	@Autowired
	private JWTAuthor jwtAuthor;
	
	@Autowired
	private UserManager userManager;
	
	@Override
	public String getJWT(User user) throws JWTCreationException {
		
		String jwt = null;
		
		Map<String, List<String>> claims = new HashMap<String, List<String>>();
		List<String> roleStrings = new ArrayList<String>();
		
		for (Claim role : user.getClaims()){
			roleStrings.add(role.getAuthority());
		}
		claims.put("Authorities", roleStrings);
		
		jwt = jwtAuthor.createJWT(user.getSubjectName(), claims);
		return jwt;
		
	}
	
	/*
	private List<String> getPermissions(User user){
		
		//userManager
		
	}
	*/
}
{'fraction_non_alphanumeric': 0.11447260834014718, 'fraction_numerical': 0.0, 'mean_word_length': 4.77122641509434, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5399364', 'n_tokens_mistral': 882, 'n_tokens_neox': 816, 'n_words': 149}