001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.shiro;
018
019import org.apache.activemq.security.SecurityContext;
020import org.apache.activemq.shiro.subject.SubjectConnectionReference;
021import org.apache.activemq.shiro.subject.SubjectSecurityContext;
022import org.apache.shiro.env.Environment;
023
024/**
025 * Default {@code SecurityContextFactory} implementation that creates
026 * {@link org.apache.activemq.shiro.subject.SubjectSecurityContext} instances, allowing the connection's {@code Subject} and the Shiro
027 * {@link Environment} to be available to downstream security broker filters.
028 *
029 * @since 5.10.0
030 */
031public class DefaultSecurityContextFactory implements SecurityContextFactory {
032
033    /**
034     * Returns a new {@link org.apache.activemq.shiro.subject.SubjectSecurityContext} instance, allowing the connection's {@code Subject} and the Shiro
035     * {@link Environment} to be available to downstream security broker filters.
036     *
037     * @param conn the subject's connection
038     * @return a new {@link org.apache.activemq.shiro.subject.SubjectSecurityContext} instance, allowing the connection's {@code Subject} and the Shiro
039     *         {@link Environment} to be available to downstream security broker filters.
040     */
041    @Override
042    public SecurityContext createSecurityContext(SubjectConnectionReference conn) {
043        return new SubjectSecurityContext(conn);
044    }
045}