Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 55362 invoked from network); 1 Nov 2004 05:21:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Nov 2004 05:21:13 -0000 Received: (qmail 84555 invoked by uid 500); 1 Nov 2004 05:21:13 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 84507 invoked by uid 500); 1 Nov 2004 05:21:12 -0000 Mailing-List: contact directory-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: directory-dev@incubator.apache.org Delivered-To: mailing list directory-cvs@incubator.apache.org Received: (qmail 84492 invoked by uid 99); 1 Nov 2004 05:21:12 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 31 Oct 2004 21:21:12 -0800 Received: (qmail 55342 invoked by uid 65534); 1 Nov 2004 05:21:11 -0000 Date: 1 Nov 2004 05:21:11 -0000 Message-ID: <20041101052111.55340.qmail@minotaur.apache.org> From: erodriguez@apache.org To: directory-cvs@incubator.apache.org Subject: svn commit: rev 56209 - incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: erodriguez Date: Sun Oct 31 21:21:10 2004 New Revision: 56209 Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/KdcConfiguration.java Log: Implementation of properties-based KDC configuration. Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/KdcConfiguration.java ============================================================================== --- (empty file) +++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/KdcConfiguration.java Sun Oct 31 21:21:10 2004 @@ -0,0 +1,179 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.kerberos.kdc; + +import org.apache.kerberos.crypto.encryption.*; + +import java.io.*; +import java.util.*; + +import javax.security.auth.kerberos.*; + +public class KdcConfiguration { + + private static final int DEFAULT_PORT = 88; + private static final int BUFFER_SIZE = 1024; + private static final int MINUTE = 1000 * 60; + + private Properties _properties = new Properties(); + private EncryptionType[] _encryptionTypes; + + public KdcConfiguration() { + try { + _properties.load(new FileInputStream("kerberos.properties")); + } catch (IOException e) { + e.printStackTrace(); + } + + prepareEncryptionTypes(); + } + + public String getPrimaryRealm() { + String key = "kdc.primary.realm"; + return (String)_properties.get(key); + } + + public KerberosPrincipal getKdcPrincipal() { + String key = "kdc.principal"; + return new KerberosPrincipal((String)_properties.get(key)); + } + + public String getKerberosKeysLocation() { + String key = "kdc.keys.location"; + return (String)_properties.get(key); + } + + public EncryptionType[] getEncryptionTypes() { + return _encryptionTypes; + } + + public Hashtable getProperties() { + // Request that the krb5key value be returned as binary + _properties.put("java.naming.ldap.attributes.binary", "krb5Key"); + + return _properties; + } + + public long getClockSkew() { + String key = "kdc.allowable.clockskew"; + if (_properties.containsKey(key)) { + return MINUTE * Long.parseLong((String)_properties.get(key)); + } + return MINUTE * 5; + } + + public long getMaximumTicketLifetime() { + String key = "tgs.maximum.ticket.lifetime"; + if (_properties.containsKey(key)) { + return MINUTE * Long.parseLong((String)_properties.get(key)); + } + return MINUTE * 1440; + } + + public long getMaximumRenewableLifetime() { + String key = "tgs.maximum.renewable.lifetime"; + if (_properties.containsKey(key)) { + return MINUTE * Long.parseLong((String)_properties.get(key)); + } + return MINUTE * 10080; + } + + public int getDefaultPort() { + String key = "kdc.default.port"; + if (_properties.containsKey(key)) { + return Integer.parseInt((String)_properties.get(key)); + } + return DEFAULT_PORT; + } + + public int getBufferSize() { + String key = "kdc.buffer.size"; + if (_properties.containsKey(key)) { + return Integer.parseInt((String)_properties.get(key)); + } + return BUFFER_SIZE; + } + + public boolean isPaEncTimestampRequired() { + String key = "kdc.pa.enc.timestamp.required"; + if (_properties.containsKey(key)) { + return "true".equalsIgnoreCase((String)_properties.get(key)); + } + return true; + } + + public boolean isEmptyAddressesAllowed() { + String key = "tgs.empty.addresses.allowed"; + if (_properties.containsKey(key)) { + return "true".equalsIgnoreCase((String)_properties.get(key)); + } + return true; + } + + public boolean isForwardableAllowed() { + String key = "tgs.forwardable.allowed"; + if (_properties.containsKey(key)) { + return "true".equalsIgnoreCase((String)_properties.get(key)); + } + return true; + } + + public boolean isProxiableAllowed() { + String key = "tgs.proxiable.allowed"; + if (_properties.containsKey(key)) { + return "true".equalsIgnoreCase((String)_properties.get(key)); + } + return true; + } + + public boolean isPostdateAllowed() { + String key = "tgs.postdate.allowed"; + if (_properties.containsKey(key)) { + return "true".equalsIgnoreCase((String)_properties.get(key)); + } + return true; + } + + public boolean isRenewableAllowed() { + String key = "tgs.renewable.allowed"; + if (_properties.containsKey(key)) { + return "true".equalsIgnoreCase((String)_properties.get(key)); + } + return true; + } + + private void prepareEncryptionTypes() { + String key = "kdc.encryption.types"; + String[] encryptionTypes = ((String)_properties.get(key)).split("\\s"); + + List encTypes = new ArrayList(); + + for (int i = 0;i < encryptionTypes.length; i++) { + String enc = encryptionTypes[i]; + Iterator it = EncryptionType.VALUES.iterator(); + while (it.hasNext()) { + EncryptionType type = (EncryptionType)it.next(); + if (type.toString().equalsIgnoreCase(enc)) { + encTypes.add(type); + } + } + } + + _encryptionTypes = (EncryptionType[])encTypes.toArray(new EncryptionType[encTypes.size()]); + } +} +