All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.owasp.esapi.reference.IntegerAccessReferenceMap Maven / Gradle / Ivy

Go to download

The Enterprise Security API (ESAPI) project is an OWASP project to create simple strong security controls for every web platform. Security controls are not simple to build. You can read about the hundreds of pitfalls for unwary developers on the OWASP website. By providing developers with a set of strong controls, we aim to eliminate some of the complexity of creating secure web applications. This can result in significant cost savings across the SDLC.

There is a newer version: 2.5.5.0
Show newest version
/**
 * OWASP Enterprise Security API (ESAPI)
 * 
 * This file is part of the Open Web Application Security Project (OWASP)
 * Enterprise Security API (ESAPI) project. For details, please see
 * http://www.owasp.org/index.php/ESAPI.
 *
 * Copyright (c) 2007 - The OWASP Foundation
 * 
 * The ESAPI is published by OWASP under the BSD license. You should read and accept the
 * LICENSE before you use, modify, and/or redistribute this software.
 * 
 * @author Jeff Williams Aspect Security
 * @created 2007
 */
package org.owasp.esapi.reference;

import java.util.Set;

/**
 * Reference implementation of the AccessReferenceMap interface. This
 * implementation generates integers for indirect references.
 * 
 * @author Jeff Williams ([email protected])
 * @author Chris Schmidt ([email protected])
 * @since June 1, 2007
 * @see org.owasp.esapi.AccessReferenceMap
 */
public class IntegerAccessReferenceMap extends AbstractAccessReferenceMap {

	private static final long serialVersionUID = 5311769278372489771L;

	int count = 1;

	/**
	 * TODO Javadoc
	 */
	public IntegerAccessReferenceMap()
	{
	}

	/**
	 * TODO Javadoc
	 */
	public IntegerAccessReferenceMap(int initialSize)
	{
		super(initialSize);
	}

	/**
	 * TODO Javadoc
	 */
	public IntegerAccessReferenceMap(Set directReferences)
	{
		super(directReferences.size());
		update(directReferences);
	}

	/**
	 * TODO Javadoc
	 */
	public IntegerAccessReferenceMap(Set directReferences, int initialSize)
	{
		super(initialSize);
		update(directReferences);
	}

	/**
     * {@inheritDoc}
	 * Note: this is final as redefinition by subclasses
	 * can lead to use before initialization issues as
	 * {@link #IntegerAccessReferenceMap(Set)} and
	 * {@link #IntegerAccessReferenceMap(Set,int)} both call it
	 * internally.
	 */
	protected final synchronized String getUniqueReference() {
		return "" + count++;  // returns a string version of the counter
	}

}