001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.extras.extended.certGeneration; 021 022 023import org.apache.directory.api.i18n.I18n; 024import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl; 025import org.apache.directory.api.ldap.model.message.ResultCodeEnum; 026 027 028/** 029 * 030 * The response sent back from the server after the CertGeneration extended operation is performed. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class CertGenerationResponseImpl extends ExtendedResponseImpl implements CertGenerationResponse 035{ 036 public CertGenerationResponseImpl( int messageId, ResultCodeEnum rcode ) 037 { 038 super( messageId, EXTENSION_OID ); 039 040 switch ( rcode ) 041 { 042 case SUCCESS: 043 case OPERATIONS_ERROR: 044 case INSUFFICIENT_ACCESS_RIGHTS: 045 break; 046 047 default: 048 throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.SUCCESS, 049 ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) ); 050 } 051 052 super.getLdapResult().setMatchedDn( null ); 053 super.getLdapResult().setResultCode( rcode ); 054 } 055 056 057 public CertGenerationResponseImpl( int messageId ) 058 { 059 super( messageId, EXTENSION_OID ); 060 super.getLdapResult().setMatchedDn( null ); 061 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 062 } 063 064 065 public CertGenerationResponseImpl() 066 { 067 super( EXTENSION_OID ); 068 super.getLdapResult().setMatchedDn( null ); 069 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 070 } 071 072 073 /** 074 * Gets the OID uniquely identifying this extended response (a.k.a. its 075 * name). 076 * 077 * @return the OID of the extended response type. 078 */ 079 public String getResponseName() 080 { 081 return EXTENSION_OID; 082 } 083 084 085 /** 086 * Sets the OID uniquely identifying this extended response (a.k.a. its 087 * name). 088 * 089 * @param oid 090 * the OID of the extended response type. 091 */ 092 public void setResponseName( String oid ) 093 { 094 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) ); 095 } 096 097 098 /** 099 * {@inheritDoc} 100 */ 101 @Override 102 public int hashCode() 103 { 104 int hash = 37; 105 // Seems simple but look at the equals() method ... 106 hash = hash * 17 + getClass().getName().hashCode(); 107 108 return hash; 109 } 110 111 112 /** 113 * {@inheritDoc} 114 */ 115 @Override 116 public boolean equals( Object obj ) 117 { 118 if ( obj == this ) 119 { 120 return true; 121 } 122 123 return ( obj instanceof CertGenerationResponseImpl ); 124 } 125}