| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | | ie.getMessage(), ie.getMessageID()); |
| | | logError(ie.getMessageObject()); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public boolean isConfigurationAddAcceptable( |
| | | CertificateMapperCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | if (configuration.isEnabled()) |
| | | { |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | unacceptableReasons.add(ie.getMessage()); |
| | | unacceptableReasons.add(ie.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | CertificateMapperCfg configuration) |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<Message> messages = new ArrayList<Message>(); |
| | | |
| | | configuration.addChangeListener(this); |
| | | |
| | |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | |
| | | messages.add(ie.getMessage()); |
| | | messages.add(ie.getMessageObject()); |
| | | } |
| | | |
| | | if (resultCode == ResultCode.SUCCESS) |
| | |
| | | */ |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | CertificateMapperCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | // FIXME -- We should try to perform some check to determine whether the |
| | | // certificate mapper is in use. |
| | |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | CertificateMapperCfg configuration) |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<Message> messages = new ArrayList<Message>(); |
| | | |
| | | DirectoryServer.deregisterCertificateMapper(configuration.dn()); |
| | | |
| | |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | CertificateMapperCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | if (configuration.isEnabled()) |
| | | { |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | unacceptableReasons.add(ie.getMessage()); |
| | | unacceptableReasons.add(ie.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | ArrayList<Message> messages = new ArrayList<Message>(); |
| | | |
| | | |
| | | // Get the existing mapper if it's already enabled. |
| | |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | |
| | | messages.add(ie.getMessage()); |
| | | messages.add(ie.getMessageObject()); |
| | | } |
| | | |
| | | if (resultCode == ResultCode.SUCCESS) |
| | |
| | | CertificateMapperCfg.class, |
| | | List.class); |
| | | |
| | | List<String> unacceptableReasons = new ArrayList<String>(); |
| | | List<Message> unacceptableReasons = new ArrayList<Message>(); |
| | | Boolean acceptable = (Boolean) method.invoke(mapper, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | if (! unacceptableReasons.isEmpty()) |
| | | { |
| | | Iterator<String> iterator = unacceptableReasons.iterator(); |
| | | Iterator<Message> iterator = unacceptableReasons.iterator(); |
| | | buffer.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | int msgID = MSGID_CONFIG_CERTMAPPER_CONFIG_NOT_ACCEPTABLE; |
| | | String message = getMessage(msgID, String.valueOf(configuration.dn()), |
| | | buffer.toString()); |
| | | throw new InitializationException(msgID, message); |
| | | Message message = ERR_CONFIG_CERTMAPPER_CONFIG_NOT_ACCEPTABLE.get( |
| | | String.valueOf(configuration.dn()), buffer.toString()); |
| | | throw new InitializationException(message); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CONFIG_CERTMAPPER_INITIALIZATION_FAILED; |
| | | String message = getMessage(msgID, className, |
| | | String.valueOf(configuration.dn()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | Message message = ERR_CONFIG_CERTMAPPER_INITIALIZATION_FAILED. |
| | | get(className, String.valueOf(configuration.dn()), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | } |
| | | } |