/*
 * oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2015, Gluu
 */

package org.xdi.oxauth.model.fido.u2f.protocol;

import java.io.Serializable;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.jboss.resteasy.annotations.providers.jaxb.IgnoreMediaTypes;
import org.xdi.oxauth.model.fido.u2f.exception.BadInputException;

/**
 * FIDO U2F device registration response
 *
 * @author Yuriy Movchan Date: 05/13/2015
 */
@IgnoreMediaTypes("application/*+json")
// try to ignore jettison as it's recommended here:
// http://docs.jboss.org/resteasy/docs/2.3.4.Final/userguide/html/json.html
@JsonIgnoreProperties(ignoreUnknown = true)
public class RegisterResponse implements Serializable {

	private static final long serialVersionUID = -4192863815075074953L;

	/**
	 * base64 (raw registration response message)
	 */
	@JsonProperty
	private final String registrationData;

	/**
	 * base64(UTF8(client data))
	 */
	@JsonProperty
	private final String clientData;

	/**
	 * base64(UTF8(device data))
	 */
	@JsonProperty
	private final String deviceData;

	@JsonIgnore
	private transient ClientData clientDataRef;

	public RegisterResponse(@JsonProperty("registrationData") String registrationData, @JsonProperty("clientData") String clientData) throws BadInputException {
		this(registrationData, clientData, null);
	}

	public RegisterResponse(@JsonProperty("registrationData") String registrationData, @JsonProperty("clientData") String clientData, @JsonProperty("deviceData") String deviceData) throws BadInputException {
		this.registrationData = registrationData;
		this.clientData = clientData;
		this.clientDataRef = new ClientData(clientData);
		this.deviceData = deviceData;
	}

	public String getRegistrationData() {
		return registrationData;
	}

	public ClientData getClientData() {
		return clientDataRef;
	}

	public String getDeviceData() {
		return deviceData;
	}

	@JsonIgnore
	public String getRequestId() {
		return getClientData().getChallenge();
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("RegisterResponse [registrationData=").append(registrationData).append(", clientData=").append(clientData).append(", deviceData=")
				.append(deviceData).append("]");
		return builder.toString();
	}

}

@@ -1304,214 +1304,8 @@
 f;%0A%0A
-%09public RegisterResponse(@JsonProperty(%22registrationData%22) String registrationData, @JsonProperty(%22clientData%22) String clientData) throws BadInputException %7B%0A%09%09this(registrationData, clientData, null);%0A%09%7D%0A%0A
 %09pub

Fix json constructor