/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyrighted [year] [name of copyright owner]".
*
* Copyright 2014-2015 ForgeRock AS.
*/
/**
* Contains state corresponding to a UsernameToken and will emit json which includes state necessary to act as the
* input_token_state in the RestSTSTokenTranslationInvocationState - i.e. the username and password state, and a
* AMSTSConstants.TOKEN_TYPE_KEY field corresponding to TokenType.USERNAME.name().
*/
public class UsernameTokenState {
public static class UsernameTokenStateBuilder {
private byte[] username;
private byte[] password;
private UsernameTokenStateBuilder() {}
return this;
}
return this;
}
return new UsernameTokenState(this);
}
}
}
}
}
return new UsernameTokenStateBuilder();
}
public byte[] getUsername() {
return restUsernameToken.getUsername();
}
public byte[] getPassword() {
return restUsernameToken.getPassword();
}
try {
field(AMSTSConstants.USERNAME_TOKEN_USERNAME, new String(restUsernameToken.getUsername(), AMSTSConstants.UTF_8_CHARSET_ID)),
field(AMSTSConstants.USERNAME_TOKEN_PASSWORD, new String(restUsernameToken.getPassword(), AMSTSConstants.UTF_8_CHARSET_ID))));
} catch (UnsupportedEncodingException e) {
throw new TokenMarshalException(ResourceException.BAD_REQUEST, "Unsupported charset marshalling toJson: " + e);
}
}
try {
return UsernameTokenState.builder()
.password(jsonValue.get(AMSTSConstants.USERNAME_TOKEN_PASSWORD).asString().getBytes(AMSTSConstants.UTF_8_CHARSET_ID))
.username(jsonValue.get(AMSTSConstants.USERNAME_TOKEN_USERNAME).asString().getBytes(AMSTSConstants.UTF_8_CHARSET_ID))
.build();
} catch (UnsupportedEncodingException e) {
throw new TokenMarshalException(ResourceException.BAD_REQUEST, "Unsupported charset marshalling fromJson: " + e);
}
}
try {
} catch (TokenMarshalException e) {
return "Exception caught marshalling toJson: " + e;
}
}
public int hashCode() {
}
if (other instanceof UsernameTokenState) {
}
return false;
}
}