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.shared.ldap.extras.extended; 021 022 023import org.apache.directory.shared.i18n.I18n; 024import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl; 025import org.apache.directory.shared.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 /** The serial version UUID */ 037 private static final long serialVersionUID = 1L; 038 039 public CertGenerationResponseImpl( int messageId, ResultCodeEnum rcode ) 040 { 041 super( messageId, EXTENSION_OID ); 042 043 switch ( rcode ) 044 { 045 case SUCCESS: 046 case OPERATIONS_ERROR: 047 case INSUFFICIENT_ACCESS_RIGHTS: 048 break; 049 050 default: 051 throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.SUCCESS, 052 ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) ); 053 } 054 055 super.getLdapResult().setMatchedDn( null ); 056 super.getLdapResult().setResultCode( rcode ); 057 } 058 059 060 public CertGenerationResponseImpl( int messageId ) 061 { 062 super( messageId, EXTENSION_OID ); 063 super.getLdapResult().setMatchedDn( null ); 064 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 065 } 066 067 068 public CertGenerationResponseImpl() 069 { 070 super( EXTENSION_OID ); 071 super.getLdapResult().setMatchedDn( null ); 072 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 073 } 074 075 076 /** 077 * Gets the OID uniquely identifying this extended response (a.k.a. its 078 * name). 079 * 080 * @return the OID of the extended response type. 081 */ 082 public String getResponseName() 083 { 084 return EXTENSION_OID; 085 } 086 087 088 /** 089 * Sets the OID uniquely identifying this extended response (a.k.a. its 090 * name). 091 * 092 * @param oid 093 * the OID of the extended response type. 094 */ 095 public void setResponseName( String oid ) 096 { 097 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) ); 098 } 099 100 101 /** 102 * {@inheritDoc} 103 */ 104 @Override 105 public int hashCode() 106 { 107 int hash = 37; 108 // Seems simple but look at the equals() method ... 109 hash = hash * 17 + getClass().getName().hashCode(); 110 111 return hash; 112 } 113 114 115 /** 116 * {@inheritDoc} 117 */ 118 @Override 119 public boolean equals( Object obj ) 120 { 121 if ( obj == this ) 122 { 123 return true; 124 } 125 126 return ( obj instanceof CertGenerationResponseImpl ); 127 } 128}