1 /* 2 (C) Copyright IBM Corp. 2005, 2009 3 4 THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE 5 ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE 6 CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. 7 8 You can obtain a current copy of the Eclipse Public License from 9 http://www.opensource.org/licenses/eclipse-1.0.php 10 11 @author : Roberto Pineiro, IBM, roberto.pineiro@us.ibm.com 12 * @author : Chung-hao Tan, IBM, chungtan@us.ibm.com 13 * 14 * 15 * Change History 16 * Flag Date Prog Description 17 *------------------------------------------------------------------------------- 18 * 1535756 2006-08-07 lupusalex Make code warning free 19 * 1516242 2006-11-27 lupusalex Support of OpenPegasus local authentication 20 * 1565892 2006-11-28 lupusalex Make SBLIM client JSR48 compliant 21 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL 22 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1) 23 * 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2) 24 */ 25 26 package org.metricshub.wbem.sblim.cimclient.internal.http; 27 28 /*- 29 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ 30 * WBEM Java Client 31 * ჻჻჻჻჻჻ 32 * Copyright 2023 - 2025 MetricsHub 33 * ჻჻჻჻჻჻ 34 * Licensed under the Apache License, Version 2.0 (the "License"); 35 * you may not use this file except in compliance with the License. 36 * You may obtain a copy of the License at 37 * 38 * http://www.apache.org/licenses/LICENSE-2.0 39 * 40 * Unless required by applicable law or agreed to in writing, software 41 * distributed under the License is distributed on an "AS IS" BASIS, 42 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 43 * See the License for the specific language governing permissions and 44 * limitations under the License. 45 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ 46 */ 47 48 import java.util.ArrayList; 49 import java.util.Iterator; 50 51 /** 52 * Class AuthorizationHandler manages AdAuthorizationInfo instances 53 * 54 */ 55 public class AuthorizationHandler { 56 private ArrayList<AuthorizationInfo> iAuthList = new ArrayList<AuthorizationInfo>(); 57 58 /** 59 * Adds an AuthorizationInfo to the handler 60 * 61 * @param pAuthorizationInfo 62 * The AuthorizationInfo to add 63 */ 64 public synchronized void addAuthorizationInfo(AuthorizationInfo pAuthorizationInfo) { 65 this.iAuthList.add(pAuthorizationInfo); 66 } 67 68 /** 69 * Returns the corresponding AuthorizationInfo for a given set of parameters 70 * 71 * @param pAuthorizationModule 72 * The authorization module 73 * @param pProxy 74 * Proxy authentication ? 75 * @param pAddr 76 * Host address 77 * @param pPort 78 * Host port 79 * @param pProtocol 80 * Protocol 81 * @param pRealm 82 * Realm 83 * @param pScheme 84 * Scheme 85 * @return The AuthorizationInfo or <code>null</code> if none fits 86 */ 87 public synchronized AuthorizationInfo getAuthorizationInfo( 88 String pAuthorizationModule, 89 Boolean pProxy, 90 String pAddr, 91 int pPort, 92 String pProtocol, 93 String pRealm, 94 String pScheme 95 ) { 96 AuthorizationInfo request = AuthorizationInfo.createAuthorizationInfo( 97 pAuthorizationModule, 98 pProxy, 99 pAddr, 100 pPort, 101 pProtocol, 102 pRealm, 103 pScheme 104 ); 105 106 Iterator<AuthorizationInfo> iter = this.iAuthList.iterator(); 107 while (iter.hasNext()) { 108 AuthorizationInfo authInfo = iter.next(); 109 110 if (authInfo.match(request)) return authInfo; 111 } 112 return null; 113 } 114 115 /** 116 * Returns the AuthorizationInfo at a given index 117 * 118 * @param pIndex 119 * The index 120 * @return The AuthorizationInfo 121 */ 122 public synchronized AuthorizationInfo getAuthorizationInfo(int pIndex) { 123 return this.iAuthList.get(pIndex); 124 } 125 126 @Override 127 public String toString() { 128 return "AuthorizationHandler=[AuthInfoList=" + this.iAuthList + "]"; 129 } 130 }