Password.java
/*
* Copyright 2019-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bremersee.dccon.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.validation.annotation.Validated;
/**
* Request body to change a password. Administrators can just set the new password. Normal users
* must also set the previous password.
*
* @author Christian Bremer
*/
@Schema(description = "Request body to change a password. Administrators can just set the new "
+ "password. Normal users must also set the previous password.")
@Validated
@JsonIgnoreProperties(ignoreUnknown = true)
@EqualsAndHashCode
@ToString(exclude = {"value", "previousValue"})
@NoArgsConstructor
public class Password implements Serializable {
private static final long serialVersionUID = 2L;
@JsonProperty(value = "value", required = true)
private String value;
@JsonProperty(value = "previousValue")
private String previousValue;
/**
* Instantiates a new password request body.
*
* @param value the new password
*/
public Password(String value) {
this.value = value;
}
/**
* Instantiates a new password request body.
*
* @param value the new password
* @param previousValue the previous password
*/
@SuppressWarnings("unused")
@Builder(toBuilder = true)
public Password(String value, String previousValue) {
this.value = value;
this.previousValue = previousValue;
}
/**
* The new password.
*
* @return the new password
*/
@Schema(required = true, description = "The new password.")
@NotNull
public String getValue() {
return value;
}
/**
* Sets new password.
*
* @param value the new password
*/
public void setValue(String value) {
this.value = value;
}
/**
* Gets previous password.
*
* @return the previous password
*/
@Schema(required = true, description = "The previous password.")
public String getPreviousValue() {
return previousValue;
}
/**
* Sets previous password.
*
* @param previousValue the previous password
*/
public void setPreviousValue(String previousValue) {
this.previousValue = previousValue;
}
}