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.pwdModify; 021 022 023import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest; 024import org.apache.directory.api.util.Strings; 025 026 027/** 028 * The RFC 3062 PwdModify request : 029 * 030 * <pre> 031 * PasswdModifyRequestValue ::= SEQUENCE { 032 * userIdentity [0] OCTET STRING OPTIONAL 033 * oldPasswd [1] OCTET STRING OPTIONAL 034 * newPasswd [2] OCTET STRING OPTIONAL } 035 * </pre> 036 * 037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 038 */ 039public class PasswordModifyRequestImpl extends AbstractExtendedRequest implements PasswordModifyRequest 040{ 041 /** The user identity */ 042 private byte[] userIdentity; 043 044 /** The previous password */ 045 private byte[] oldPassword; 046 047 /** The new password */ 048 private byte[] newPassword; 049 050 051 /** 052 * Create a new instance of the PwdModifyRequest extended operation 053 */ 054 public PasswordModifyRequestImpl() 055 { 056 setRequestName( EXTENSION_OID ); 057 } 058 059 060 /** 061 * Create a new instance of the PwdModifyRequest extended operation 062 * 063 * @param messageId The message ID 064 */ 065 public PasswordModifyRequestImpl( int messageId ) 066 { 067 super( messageId ); 068 setRequestName( EXTENSION_OID ); 069 } 070 071 072 /** 073 * {@inheritDoc} 074 */ 075 public byte[] getUserIdentity() 076 { 077 return userIdentity; 078 } 079 080 081 /** 082 * @param userIdentity the userIdentity to set 083 */ 084 public void setUserIdentity( byte[] userIdentity ) 085 { 086 this.userIdentity = userIdentity; 087 } 088 089 090 /** 091 * {@inheritDoc} 092 */ 093 public byte[] getOldPassword() 094 { 095 return oldPassword; 096 } 097 098 099 /** 100 * @param oldPassword the oldPassword to set 101 */ 102 public void setOldPassword( byte[] oldPassword ) 103 { 104 this.oldPassword = oldPassword; 105 } 106 107 108 /** 109 * {@inheritDoc} 110 */ 111 public byte[] getNewPassword() 112 { 113 return newPassword; 114 } 115 116 117 /** 118 * @param newPassword the newPassword to set 119 */ 120 public void setNewPassword( byte[] newPassword ) 121 { 122 this.newPassword = newPassword; 123 } 124 125 126 /** 127 * {@inheritDoc} 128 */ 129 @Override 130 public PasswordModifyResponse getResultResponse() 131 { 132 if ( response == null ) 133 { 134 response = new PasswordModifyResponseImpl( getMessageId() ); 135 } 136 137 return ( PasswordModifyResponse ) response; 138 } 139 140 141 /** 142 * @see Object#toString() 143 */ 144 public String toString() 145 { 146 StringBuilder sb = new StringBuilder(); 147 148 sb.append( "PwdModifyRequest :" ); 149 sb.append( "\n UserIdentity : " ); 150 151 if ( userIdentity != null ) 152 { 153 sb.append( Strings.utf8ToString( userIdentity ) ); 154 } 155 else 156 { 157 sb.append( "null" ); 158 } 159 160 sb.append( "\n oldPassword : " ); 161 162 if ( oldPassword != null ) 163 { 164 sb.append( Strings.utf8ToString( oldPassword ) ); 165 } 166 else 167 { 168 sb.append( "null" ); 169 } 170 171 sb.append( "\n newPassword : " ); 172 173 if ( newPassword != null ) 174 { 175 sb.append( Strings.utf8ToString( newPassword ) ); 176 } 177 else 178 { 179 sb.append( "null" ); 180 } 181 182 return sb.toString(); 183 } 184}