class PrincipalAuthority implements Authority, AuthorityKeyStore {

    String getAuthorizedServiceName(List<String> authorizedServices, String authorizedServiceName) {
        
        /* if we have an authorized service name specified then it must be
         * present in the authorized services list or if it's null then the
         * list must contain a single element only */

        String serviceName = authorizedServiceName;
        if (serviceName == null) {
            if (authorizedServices.size() != 1) {
                LOG.error("getAuthorizedServiceName() failed: No authorized service name specified");
                return null;
            }
            serviceName = authorizedServices.get(0);
        } else {
            if (!authorizedServices.contains(serviceName)) {
                LOG.error("getAuthorizedServiceName() failed: Invalid authorized service name specified:"
                        + serviceName);
                return null;
            }
        }
        return serviceName;
    }

    public  PrincipalAuthority();

}