001/* 002 * Copyright 2009-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2009-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2009-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.persist; 037 038 039 040import com.unboundid.util.NotMutable; 041import com.unboundid.util.NotNull; 042import com.unboundid.util.StaticUtils; 043import com.unboundid.util.ThreadSafety; 044import com.unboundid.util.ThreadSafetyLevel; 045 046 047 048/** 049 * This class provides an OID allocator implementation that will generate OIDs 050 * which are equal to the lowercase name of the associated attribute type or 051 * object class followed by "-oid". This will not result in an OID that is 052 * technically valid, but is accepted by several directory servers. 053 */ 054@NotMutable() 055@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 056public final class DefaultOIDAllocator 057 extends OIDAllocator 058{ 059 /** 060 * The singleton instance of this OID allocator. 061 */ 062 @NotNull private static final DefaultOIDAllocator INSTANCE = 063 new DefaultOIDAllocator(); 064 065 066 067 /** 068 * The serial version UID for this serializable class. 069 */ 070 private static final long serialVersionUID = 4815405566303309719L; 071 072 073 074 /** 075 * Creates a new instance of this OID allocator. 076 */ 077 private DefaultOIDAllocator() 078 { 079 // No implementation required. 080 } 081 082 083 084 /** 085 * Retrieves the singleton instance of this OID allocator. 086 * 087 * @return The singleton instance of this OID allocator. 088 */ 089 @NotNull() 090 public static DefaultOIDAllocator getInstance() 091 { 092 return INSTANCE; 093 } 094 095 096 097 /** 098 * {@inheritDoc} 099 */ 100 @Override() 101 @NotNull() 102 public String allocateAttributeTypeOID(@NotNull final String name) 103 { 104 return StaticUtils.toLowerCase(name) + "-oid"; 105 } 106 107 108 109 /** 110 * {@inheritDoc} 111 */ 112 @Override() 113 @NotNull() 114 public String allocateObjectClassOID(@NotNull final String name) 115 { 116 return StaticUtils.toLowerCase(name) + "-oid"; 117 } 118}