<commit_before>/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2013, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This 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 software 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 software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.jboss.as.ejb3.security.service;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;

import org.jboss.as.ejb3.security.EJBMethodSecurityAttribute;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;

/**
 * A {@link Service} which can be used by other components like WS to get the security metadata associated with methods on a EJB view.
 *
 * @author: <NAME>
 * @see https://issues.jboss.org/browse/WFLY-308 for more details.
 */
public class EJBViewMethodSecurityAttributesService implements Service<EJBViewMethodSecurityAttributesService> {

    private static final ServiceName BASE_SERVICE_NAME = ServiceName.JBOSS.append("ejb").append("view-method-security-attributes");

    private final String viewClassName;
    private final Map<Method, EJBMethodSecurityAttribute> methodSecurityAttributes;

    public EJBViewMethodSecurityAttributesService(final String viewClassName, final Map<Method, EJBMethodSecurityAttribute> securityAttributes) {
        this.viewClassName = viewClassName;
        this.methodSecurityAttributes = Collections.unmodifiableMap(new HashMap<>(securityAttributes));
    }

    @Override
    public void start(StartContext startContext) throws StartException {
    }

    @Override
    public void stop(StopContext stopContext) {
    }

    @Override
    public EJBViewMethodSecurityAttributesService getValue() throws IllegalStateException, IllegalArgumentException {
        return this;
    }

    /**
     * Returns the {@link EJBMethodSecurityAttribute} associated with the passed view method. This method returns null if no security attribute is applicable for the passed method
     *
     * @param viewMethod
     * @return
     */
    public EJBMethodSecurityAttribute getSecurityAttributes(final Method viewMethod) {
        return methodSecurityAttributes.get(viewMethod);
    }

    /**
     * Returns a {@link ServiceName} for the {@link EJBViewMethodSecurityAttributesService}
     *
     * @param appName       The application name to which the bean belongs. Can be null if the bean is <b>not</b> deployed in a .ear
     * @param moduleName    The module name to which the bean belongs
     * @param beanName      The bean name
     * @param viewClassName The fully qualified class name of the EJB view
     * @return
     */
    public static ServiceName getServiceName(final String appName, final String moduleName, final String beanName, final String viewClassName) {
        if (appName != null) {
            BASE_SERVICE_NAME.append(appName);
        }
        return BASE_SERVICE_NAME.append(moduleName).append(beanName).append(viewClassName);
    }

    public static class Builder {
        private final String viewClassName;
        private final Map<Method, EJBMethodSecurityAttribute> methodSecurityAttributes = new IdentityHashMap<>();

        public Builder(final String viewClassName) {
            this.viewClassName = viewClassName;
        }

        public void addMethodSecurityMetadata(final Method viewMethod, final EJBMethodSecurityAttribute securityAttribute) {
            methodSecurityAttributes.put(viewMethod, securityAttribute);
        }

        public EJBViewMethodSecurityAttributesService build() {
            return new EJBViewMethodSecurityAttributesService(viewClassName, methodSecurityAttributes);
        }
    }
}<commit_msg>WFLY-308 Fix the service name for the EJB security metadata service<commit_after>/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2013, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This 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 software 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 software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.jboss.as.ejb3.security.service;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;

import org.jboss.as.ejb3.security.EJBMethodSecurityAttribute;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;

/**
 * A {@link Service} which can be used by other components like WS to get the security metadata associated with methods on a EJB view.
 *
 * @author: <NAME>
 * @see https://issues.jboss.org/browse/WFLY-308 for more details.
 */
public class EJBViewMethodSecurityAttributesService implements Service<EJBViewMethodSecurityAttributesService> {

    private static final ServiceName BASE_SERVICE_NAME = ServiceName.JBOSS.append("ejb").append("view-method-security-attributes");

    private final String viewClassName;
    private final Map<Method, EJBMethodSecurityAttribute> methodSecurityAttributes;

    public EJBViewMethodSecurityAttributesService(final String viewClassName, final Map<Method, EJBMethodSecurityAttribute> securityAttributes) {
        this.viewClassName = viewClassName;
        this.methodSecurityAttributes = Collections.unmodifiableMap(new HashMap<>(securityAttributes));
    }

    @Override
    public void start(StartContext startContext) throws StartException {
    }

    @Override
    public void stop(StopContext stopContext) {
    }

    @Override
    public EJBViewMethodSecurityAttributesService getValue() throws IllegalStateException, IllegalArgumentException {
        return this;
    }

    /**
     * Returns the {@link EJBMethodSecurityAttribute} associated with the passed view method. This method returns null if no security attribute is applicable for the passed method
     *
     * @param viewMethod
     * @return
     */
    public EJBMethodSecurityAttribute getSecurityAttributes(final Method viewMethod) {
        return methodSecurityAttributes.get(viewMethod);
    }

    /**
     * Returns a {@link ServiceName} for the {@link EJBViewMethodSecurityAttributesService}
     *
     * @param appName       The application name to which the bean belongs. Can be null if the bean is <b>not</b> deployed in a .ear
     * @param moduleName    The module name to which the bean belongs
     * @param beanName      The bean name
     * @param viewClassName The fully qualified class name of the EJB view
     * @return
     */
    public static ServiceName getServiceName(final String appName, final String moduleName, final String beanName, final String viewClassName) {
        final ServiceName serviceName;
        if (appName != null) {
            serviceName = BASE_SERVICE_NAME.append(appName);
        } else {
            serviceName = BASE_SERVICE_NAME;
        }
        return serviceName.append(moduleName).append(beanName).append(viewClassName);
    }

    public static class Builder {
        private final String viewClassName;
        private final Map<Method, EJBMethodSecurityAttribute> methodSecurityAttributes = new IdentityHashMap<>();

        public Builder(final String viewClassName) {
            this.viewClassName = viewClassName;
        }

        public void addMethodSecurityMetadata(final Method viewMethod, final EJBMethodSecurityAttribute securityAttribute) {
            methodSecurityAttributes.put(viewMethod, securityAttribute);
        }

        public EJBViewMethodSecurityAttributesService build() {
            return new EJBViewMethodSecurityAttributesService(viewClassName, methodSecurityAttributes);
        }
    }
}
{'fraction_non_alphanumeric': 0.06990105330354293, 'fraction_numerical': 0.005000531971486328, 'mean_word_length': 3.7885888945491595, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4446747', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2317, 'n_words': 847}