<commit_before>package esg.security.attr.service.impl;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.springframework.core.io.ClassPathResource;

import esg.security.attr.service.api.SAMLAttributeFactory;
import esg.security.attr.service.api.SAMLAttributes;
import esg.security.common.SAMLUnknownPrincipalException;
import esg.security.utils.xml.Parser;

import esg.node.security.UserInfo;
import esg.node.security.UserInfoDAO;

/**
 * Implementation of {@link SAMLAttributeFactory} backed up by node's "esgcet" RDBMS database.
 * 
 * @author gavin.bell
 */
public class SAMLAttributeFactoryDAOImpl implements SAMLAttributeFactory {
	
	final private String issuer;

    private SAMLAttributes attributes = null;
    private UserInfoDAO userInfoDAO = null;
	
	public SAMLAttributeFactoryDAOImpl(final String issuer, Properties props) throws Exception {
		
		this.issuer = issuer;
        this.userInfoDAO = new UserInfoDAO(props);
		
	}

	@Override
	public SAMLAttributes newInstance(String identifier) throws SAMLUnknownPrincipalException {        
        UserInfo userInfo = userInfoDAO.getUserById(identifier);

        //Note: as an optimization could put an LRU cache mapping
        //identifier to resultant attributes object so don't have to
        //hit the database as much.
		if (userInfo != null) {
            attributes = new SAMLAttributesImpl(identifier, issuer);
            attributes.setFirstName(userInfo.getFirstName());
            attributes.setLastName(userInfo.getLastName());
            attributes.setOpenid(userInfo.getOpenid());
            attributes.setEmail(userInfo.getEmail());
            attributes.setAttributes(userInfo.getPermissions());
			return attributes;
		} else {
			throw new SAMLUnknownPrincipalException("Unknown identifier: "+identifier);
		}
	}
    
	@Override
	public String getIssuer() {
		return issuer;
	}
	
	/**
	 * Debug method.
	 */
	public void print() {
        System.out.println(attributes);
	}

}
<commit_msg>Temporarily changing the way to check for an unknown user.<commit_after>package esg.security.attr.service.impl;

import java.util.Properties;

import esg.node.security.UserInfo;
import esg.node.security.UserInfoDAO;
import esg.security.attr.service.api.SAMLAttributeFactory;
import esg.security.attr.service.api.SAMLAttributes;
import esg.security.common.SAMLUnknownPrincipalException;

/**
 * Implementation of {@link SAMLAttributeFactory} backed up by node's "esgcet" RDBMS database.
 * 
 * @author gavin.bell
 */
public class SAMLAttributeFactoryDAOImpl implements SAMLAttributeFactory {
	
	final private String issuer;

    private SAMLAttributes attributes = null;
    private UserInfoDAO userInfoDAO = null;
	
	public SAMLAttributeFactoryDAOImpl(final String issuer, Properties props) throws Exception {
		
		this.issuer = issuer;
        this.userInfoDAO = new UserInfoDAO(props);
        		
	}

	@Override
	public SAMLAttributes newInstance(String identifier) throws SAMLUnknownPrincipalException {        
        UserInfo userInfo = userInfoDAO.getUserById(identifier);

        //Note: as an optimization could put an LRU cache mapping
        //identifier to resultant attributes object so don't have to
        //hit the database as much.
		//if (userInfo != null) {
		if (userInfo.getid()!=-1) {
            attributes = new SAMLAttributesImpl(identifier, issuer);
            attributes.setFirstName(userInfo.getFirstName());
            attributes.setLastName(userInfo.getLastName());
            attributes.setOpenid(userInfo.getOpenid());
            attributes.setEmail(userInfo.getEmail());
            attributes.setAttributes(userInfo.getPermissions());
			return attributes;
		} else {
			throw new SAMLUnknownPrincipalException("Unknown identifier: "+identifier);
		}
	}
    
	@Override
	public String getIssuer() {
		return issuer;
	}
	
	/**
	 * Debug method.
	 */
	public void print() {
        System.out.println(attributes);
	}

}

{'fraction_non_alphanumeric': 0.09264173703256937, 'fraction_numerical': 0.00024125452352231604, 'mean_word_length': 3.7113636363636364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '378721', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1177, 'n_words': 277}