001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: Authorizer.java,v 1.3 2008/06/25 05:43:39 qcheng Exp $ 026 * 027 */ 028 029package com.sun.identity.log.spi; 030 031import com.sun.identity.log.LogConstants; 032import com.sun.identity.log.LogManager; 033import com.sun.identity.log.LogManagerUtil; 034 035/** 036 * This class is used to verify the authorization of the 037 * of the person who is trying to perform a log operation. 038 * @supported.all.api 039 */ 040 041public class Authorizer { 042 private static IAuthorizer authorizer; 043 private static LogManager lmanager = 044 (LogManager)LogManagerUtil.getLogManager(); 045 046 static { 047 String authzClass = lmanager.getProperty(LogConstants.AUTHZ); 048 try { 049 Class c = Class.forName(authzClass); 050 authorizer = (IAuthorizer)c.newInstance(); 051 } catch(Exception e) { 052 Debug.error("Authorizer ", e); 053 } 054 } 055 056 /** 057 * Returns true if a given log record should be published. 058 * 059 * @param logName Log name on which operation is to be performed. 060 * @param operation Log operation to be performed. 061 * @param credential Credential to be authorized. 062 * @return true if the credential is authorized. 063 */ 064 public static boolean isAuthorized( 065 String logName, 066 String operation, 067 Object credential) 068 { 069 return authorizer.isAuthorized (logName, operation, credential); 070 } 071 072 /** 073 * Returns true if given subject is authorized to change the password. 074 * 075 * @param credential Credential to be checked for authorization. 076 * @return true if given subject is authorized to change the password. 077 */ 078 public static boolean isAuthorized (Object credential) { 079 return authorizer.isAuthorized (credential); 080 } 081}
Copyright © 2010-2017, ForgeRock All Rights Reserved.