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.net.URI; 021import java.util.Collections; 022import java.util.Set; 023 024import org.jboss.security.xacml.sunxacml.EvaluationCtx; 025import org.jboss.security.xacml.sunxacml.attr.AttributeDesignator; 026import org.jboss.security.xacml.sunxacml.cond.EvaluationResult; 027import org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule; 028import org.springframework.stereotype.Component; 029import org.w3c.dom.Node; 030 031 032/** 033 * Finds resource attributes via a configured set of SPARQL queries. 034 * @author Gregory Jansen 035 */ 036@Component 037public class SparqlResourceAttributeFinderModule extends AttributeFinderModule { 038 039 /** 040 * Supported designator types. 041 */ 042 private static final Set<Integer> DESIGNATOR_TYPES = Collections 043 .unmodifiableSet(Collections 044 .singleton(AttributeDesignator.RESOURCE_TARGET)); 045 046 /* 047 * (non-Javadoc) 048 * @see org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule# 049 * isDesignatorSupported() 050 */ 051 @Override 052 public final boolean isDesignatorSupported() { 053 return true; 054 } 055 056 /* 057 * (non-Javadoc) 058 * @see org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule# 059 * isSelectorSupported() 060 */ 061 @Override 062 public final boolean isSelectorSupported() { 063 return true; 064 } 065 066 /* 067 * Supports resource designator types. 068 * @see org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule# 069 * getSupportedDesignatorTypes() 070 */ 071 @Override 072 public final Set<Integer> getSupportedDesignatorTypes() { 073 return SparqlResourceAttributeFinderModule.DESIGNATOR_TYPES; 074 } 075 076 /* 077 * The list of attribute IDs which are mapped to SPARQL queries. 078 * @see org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule# 079 * getSupportedIds() 080 */ 081 @Override 082 public final Set<URI> getSupportedIds() { 083 // TODO Auto-generated method stub 084 return super.getSupportedIds(); 085 } 086 087 /* 088 * (non-Javadoc) 089 * @see 090 * org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule#findAttribute 091 * (java.net.URI, java.net.URI, java.net.URI, java.net.URI, 092 * org.jboss.security.xacml.sunxacml.EvaluationCtx, int) 093 */ 094 @Override 095 public final EvaluationResult findAttribute(final URI attributeType, 096 final URI attributeId, final URI issuer, final URI subjectCategory, 097 final EvaluationCtx context, final int designatorType) { 098 // TODO Auto-generated method stub 099 return super.findAttribute(attributeType, attributeId, issuer, 100 subjectCategory, context, designatorType); 101 } 102 103 /* 104 * (non-Javadoc) 105 * @see 106 * org.jboss.security.xacml.sunxacml.finder.AttributeFinderModule#findAttribute 107 * (java.lang.String, org.w3c.dom.Node, java.net.URI, 108 * org.jboss.security.xacml.sunxacml.EvaluationCtx, java.lang.String) 109 */ 110 @Override 111 public final EvaluationResult findAttribute(final String contextPath, 112 final Node namespaceNode, final URI attributeType, 113 final EvaluationCtx context, final String xpathVersion) { 114 // TODO Auto-generated method stub 115 return super.findAttribute(contextPath, namespaceNode, attributeType, 116 context, xpathVersion); 117 } 118 119}