001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2010 Sun Microsystems, Inc. 015 * Portions Copyright 2012-2014 ForgeRock AS. 016 */ 017 018package org.forgerock.opendj.ldap; 019 020/** 021 * An interface for providing additional connection security to a connection. 022 */ 023public interface ConnectionSecurityLayer { 024 025 /** 026 * Disposes of any system resources or security-sensitive information that 027 * this connection security layer might be using. Invoking this method 028 * invalidates this instance. 029 */ 030 void dispose(); 031 032 /** 033 * Unwraps a byte array received from the peer. 034 * 035 * @param incoming 036 * A non-{@code null} byte array containing the encoded bytes 037 * from the peer. 038 * @param offset 039 * The starting position in {@code incoming} of the bytes to be 040 * unwrapped. 041 * @param len 042 * The number of bytes from {@code incoming} to be unwrapped. 043 * @return A non-{@code null} byte array containing the unwrapped bytes. 044 * @throws LdapException 045 * If {@code incoming} cannot be successfully unwrapped. 046 */ 047 byte[] unwrap(byte[] incoming, int offset, int len) throws LdapException; 048 049 /** 050 * Wraps a byte array to be sent to the peer. 051 * 052 * @param outgoing 053 * A non-{@code null} byte array containing the unencoded bytes 054 * to be sent to the peer. 055 * @param offset 056 * The starting position in {@code outgoing} of the bytes to be 057 * wrapped. 058 * @param len 059 * The number of bytes from {@code outgoing} to be wrapped. 060 * @return A non-{@code null} byte array containing the wrapped bytes. 061 * @throws LdapException 062 * If {@code outgoing} cannot be successfully wrapped. 063 */ 064 byte[] wrap(byte[] outgoing, int offset, int len) throws LdapException; 065}