/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions copyright 2013 ForgeRock AS
*/
/**
* This class provides an implementation of a SASL mechanism that relies on some
* form of authentication that has already been done outside the LDAP layer. At
* the present time, this implementation only provides support for SSL-based
* clients that presented their own certificate to the Directory Server during
* the negotiation process. Future implementations may be updated to look in
* other places to find and evaluate this external authentication information.
*/
public class ExternalSASLMechanismHandler
implements ConfigurationChangeListener<
{
/**
* The tracer object for the debug logger.
*/
// The attribute type that should hold the certificates to use for the
// validation.
// Indicates whether to attempt to validate the certificate presented by the
// client with a certificate in the user's entry.
// The current configuration for this SASL mechanism handler.
/**
* Creates a new instance of this SASL mechanism handler. No initialization
* should be done in this method, as it should all be performed in the
* <CODE>initializeSASLMechanismHandler</CODE> method.
*/
public ExternalSASLMechanismHandler()
{
super();
}
/**
* {@inheritDoc}
*/
@Override()
public void initializeSASLMechanismHandler(
{
// See if we should attempt to validate client certificates against those in
// the corresponding user's entry.
switch (configuration.getCertificateValidationPolicy())
{
case NEVER:
break;
case IFPRESENT:
break;
case ALWAYS:
break;
}
// Get the attribute type to use for validating the certificates. If none
// is provided, then default to the userCertificate type.
if (certificateAttributeType == null)
{
true);
}
}
/**
* {@inheritDoc}
*/
@Override()
public void finalizeSASLMechanismHandler()
{
}
/**
* {@inheritDoc}
*/
@Override()
{
// Get the client connection used for the bind request, and get the
// security manager for that connection. If either are null, then fail.
if (clientConnection == null) {
return;
}
if(!(clientConnection instanceof LDAPClientConnection)) {
return;
}
return;
}
// Get the certificate mapper to use to map the certificate to a user entry.
// Use the Directory Server certificate mapper to map the client certificate
// chain to a single user DN.
try
{
}
catch (DirectoryException de)
{
if (debugEnabled())
{
}
return;
}
// If the user DN is null, then we couldn't establish a mapping and
// therefore the authentication failed.
{
return;
}
else
{
}
// Get the userCertificate attribute from the user's entry for use in the
// validation process.
switch (validationPolicy)
{
case ALWAYS:
if (certAttrList == null)
{
{
return;
}
}
else
{
try
{
AttributeValue v =
boolean found = false;
for (Attribute a : certAttrList)
{
if (a.contains(v))
{
found = true;
break;
}
}
if (! found)
{
return;
}
}
catch (Exception e)
{
if (debugEnabled())
{
}
getExceptionMessage(e));
return;
}
}
break;
case IFPRESENT:
if (certAttrList != null)
{
try
{
AttributeValue v =
boolean found = false;
for (Attribute a : certAttrList)
{
if (a.contains(v))
{
found = true;
break;
}
}
if (! found)
{
return;
}
}
catch (Exception e)
{
if (debugEnabled())
{
}
getExceptionMessage(e));
return;
}
}
}
}
/**
* {@inheritDoc}
*/
@Override()
{
// This is not a password-based mechanism.
return false;
}
/**
* {@inheritDoc}
*/
@Override()
{
// This may be considered a secure mechanism.
return true;
}
/**
* {@inheritDoc}
*/
@Override()
public boolean isConfigurationAcceptable(
{
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationChangeAcceptable(
{
return true;
}
/**
* {@inheritDoc}
*/
{
boolean adminActionRequired = false;
// See if we should attempt to validate client certificates against those in
// the corresponding user's entry.
switch (configuration.getCertificateValidationPolicy())
{
case NEVER:
break;
case IFPRESENT:
break;
case ALWAYS:
break;
}
// Get the attribute type to use for validating the certificates. If none
// is provided, then default to the userCertificate type.
if (newCertificateType == null)
{
true);
}
{
}
}
}