001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.auth.xacml; 019 020import java.util.Collections; 021 022import javax.inject.Inject; 023 024import org.jboss.security.xacml.sunxacml.PDP; 025import org.jboss.security.xacml.sunxacml.PDPConfig; 026import org.jboss.security.xacml.sunxacml.finder.AttributeFinder; 027import org.jboss.security.xacml.sunxacml.finder.PolicyFinder; 028import org.jboss.security.xacml.sunxacml.finder.ResourceFinder; 029import org.slf4j.Logger; 030import org.slf4j.LoggerFactory; 031import org.springframework.stereotype.Component; 032 033 034/** 035 * Factory that creates the XACML Policy Decision Point. 036 * 037 * @author Gregory Jansen 038 */ 039@Component 040public class PDPFactory { 041 042 private static final Logger LOGGER = LoggerFactory.getLogger(PDPFactory.class); 043 044 @Inject 045 private FedoraPolicyFinderModule fedoraPolicyFinderModule; 046 047 @Inject 048 private FedoraResourceFinderModule fedoraResourceFinderModule; 049 050 /** 051 * Make a PDP for the Fedora environment. 052 * 053 * @see org.springframework.beans.factory.FactoryBean#getObject() 054 * @return the PDP 055 */ 056 public PDP makePDP() { 057 final PolicyFinder policyFinder = new PolicyFinder(); 058 policyFinder.setModules(Collections.singleton(fedoraPolicyFinderModule)); 059 060 final ResourceFinder resourceFinder = new ResourceFinder(); 061 resourceFinder.setModules(Collections.singletonList(fedoraResourceFinderModule)); 062 063 final PDPConfig pdpConfig = new PDPConfig(new AttributeFinder(), policyFinder, resourceFinder); 064 final PDP pdp = new PDP(pdpConfig); 065 LOGGER.info("XACML Policy Decision Point (PDP) initialized"); 066 return pdp; 067 } 068 069}