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 @Override 076 public byte[] getUserIdentity() 077 { 078 return userIdentity; 079 } 080 081 082 /** 083 * @param userIdentity the userIdentity to set 084 */ 085 @Override 086 public void setUserIdentity( byte[] userIdentity ) 087 { 088 this.userIdentity = userIdentity; 089 } 090 091 092 /** 093 * {@inheritDoc} 094 */ 095 @Override 096 public byte[] getOldPassword() 097 { 098 return oldPassword; 099 } 100 101 102 /** 103 * @param oldPassword the oldPassword to set 104 */ 105 @Override 106 public void setOldPassword( byte[] oldPassword ) 107 { 108 this.oldPassword = oldPassword; 109 } 110 111 112 /** 113 * {@inheritDoc} 114 */ 115 @Override 116 public byte[] getNewPassword() 117 { 118 return newPassword; 119 } 120 121 122 /** 123 * @param newPassword the newPassword to set 124 */ 125 @Override 126 public void setNewPassword( byte[] newPassword ) 127 { 128 this.newPassword = newPassword; 129 } 130 131 132 /** 133 * {@inheritDoc} 134 */ 135 @Override 136 public PasswordModifyResponse getResultResponse() 137 { 138 if ( getResponse() == null ) 139 { 140 setResponse( new PasswordModifyResponseImpl( getMessageId() ) ); 141 } 142 143 return ( PasswordModifyResponse ) getResponse(); 144 } 145 146 147 /** 148 * @see Object#toString() 149 */ 150 @Override 151 public String toString() 152 { 153 StringBuilder sb = new StringBuilder(); 154 155 sb.append( "PwdModifyRequest :" ); 156 sb.append( "\n UserIdentity : " ); 157 158 if ( userIdentity != null ) 159 { 160 sb.append( Strings.utf8ToString( userIdentity ) ); 161 } 162 else 163 { 164 sb.append( "null" ); 165 } 166 167 sb.append( "\n oldPassword : " ); 168 169 if ( oldPassword != null ) 170 { 171 sb.append( Strings.utf8ToString( oldPassword ) ); 172 } 173 else 174 { 175 sb.append( "null" ); 176 } 177 178 sb.append( "\n newPassword : " ); 179 180 if ( newPassword != null ) 181 { 182 sb.append( Strings.utf8ToString( newPassword ) ); 183 } 184 else 185 { 186 sb.append( "null" ); 187 } 188 189 return sb.toString(); 190 } 191}