View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/security/authorization/ClassificationNodeCompare.java,v 1.1 2003/06/20 14:26:10 farrukh_najmi Exp $ 3 * 4 * ==================================================================== 5 * 6 * This code is subject to the freebxml License, Version 1.1 7 * 8 * Copyright (c) 2003 freebxml.org. All rights reserved. 9 * 10 * ==================================================================== 11 */ 12 package com.sun.ebxml.registry.security.authorization; 13 14 15 /*** 16 * Does a match on a ClassificationNode id taking into account the inheritence 17 * semantics of ClassificationNode hierarchies. 18 * 19 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> */ 20 public class ClassificationNodeCompare extends com.sun.xacml.cond.FunctionBase { 21 22 // the name of the function, which will be used publicly 23 public static final String NAME = "classification-node-compare"; 24 25 // the parameter types, in order, and whether or not they're bags 26 private static final String params [] = { com.sun.xacml.attr.StringAttribute.identifier, 27 com.sun.xacml.attr.StringAttribute.identifier }; 28 private static final boolean bagParams [] = { false, false }; 29 30 public ClassificationNodeCompare() { 31 // use the constructor that handles mixed argument types 32 super(NAME, 0, params, bagParams, com.sun.xacml.attr.BooleanAttribute.identifier, 33 false); 34 } 35 36 public com.sun.xacml.cond.EvaluationResult evaluate(java.util.List inputs, com.sun.xacml.EvaluationCtx context) { 37 // Evaluate the arguments using the helper method...this will 38 // catch any errors, and return values that can be compared 39 com.sun.xacml.attr.AttributeValue [] argValues = new com.sun.xacml.attr.AttributeValue[inputs.size()]; 40 com.sun.xacml.cond.EvaluationResult result = evalArgs(inputs, context, argValues); 41 if (result != null) 42 return result; 43 44 // cast the resolved values into specific types 45 String str1 = (argValues[0]).encode(); 46 String str2 = (argValues[1]).encode(); 47 48 boolean evalResult = false; 49 50 //First see if we have an exact match on cnode id 51 if (str1.equals(str2)) { 52 evalResult = true; 53 } 54 else { 55 // now see if the ClassificationNode identified by str1 ancestor 56 //of ClassificationNode identified by str2 57 try { 58 org.oasis.ebxml.registry.bindings.rim.RegistryObjectType cnode1 = com.sun.ebxml.registry.query.QueryManagerImpl.getInstance().getRegistryObject(str1); 59 if (!(cnode1 instanceof org.oasis.ebxml.registry.bindings.rim.ClassificationNodeType)) { 60 throw new com.sun.ebxml.registry.RegistryException("Expected ClassificationNodeType. Found " + cnode1.getClass()); 61 } 62 String path1 = ((org.oasis.ebxml.registry.bindings.rim.ClassificationNodeType)cnode1).getPath(); 63 64 org.oasis.ebxml.registry.bindings.rim.RegistryObjectType cnode2 = com.sun.ebxml.registry.query.QueryManagerImpl.getInstance().getRegistryObject(str2); 65 if (!(cnode2 instanceof org.oasis.ebxml.registry.bindings.rim.ClassificationNodeType)) { 66 throw new com.sun.ebxml.registry.RegistryException("Expected ClassificationNodeType. Found " + cnode2.getClass()); 67 } 68 String path2 = ((org.oasis.ebxml.registry.bindings.rim.ClassificationNodeType)cnode2).getPath(); 69 70 if (path2.startsWith(path1)) { 71 evalResult = true; 72 } 73 } 74 catch (com.sun.ebxml.registry.RegistryException e) { 75 e.printStackTrace(); 76 } 77 } 78 79 // boolean returns are common, so there's a getInstance() for that 80 return com.sun.xacml.cond.EvaluationResult.getInstance(evalResult); 81 } 82 } 83

This page was automatically generated by Maven