mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
76
java/google/registry/model/smd/EncodedSignedMark.java
Normal file
76
java/google/registry/model/smd/EncodedSignedMark.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// 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 com.google.domain.registry.model.smd;
|
||||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
|
||||
import com.google.appengine.api.datastore.Text;
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* Encoded data representation of a {@link SignedMark} object.
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/draft-lozano-tmch-smd-02#section-2.4">
|
||||
* draft-lozano-tmch-smd-02 § 2.4</a>
|
||||
*/
|
||||
@Embed
|
||||
@XmlRootElement(name = "encodedSignedMark")
|
||||
public class EncodedSignedMark extends ImmutableObject implements AbstractSignedMark {
|
||||
|
||||
private static final String ENCODING_DEFAULT = "base64";
|
||||
|
||||
/** Encoding used for contained data. Default is {@value #ENCODING_DEFAULT}. */
|
||||
@XmlAttribute
|
||||
String encoding;
|
||||
|
||||
/**
|
||||
* Encoded data. This is stored in a Text field rather than a String because Objectify cannot
|
||||
* autoconvert Strings greater than 500 characters to Text within {@link Embed} collections.
|
||||
*/
|
||||
@XmlValue
|
||||
@XmlJavaTypeAdapter(RemoveWhitespaceTextAdapter.class)
|
||||
Text encodedData;
|
||||
|
||||
public String getEncoding() {
|
||||
return firstNonNull(encoding, ENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
public String getEncodedData() {
|
||||
return encodedData == null ? "" : encodedData.getValue();
|
||||
}
|
||||
|
||||
public static EncodedSignedMark create(String encoding, String encodedData) {
|
||||
EncodedSignedMark instance = new EncodedSignedMark();
|
||||
instance.encoding = encoding;
|
||||
instance.encodedData = new Text(encodedData);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
try {
|
||||
return base64().decode(getEncodedData());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalStateException(e); // Turn e into a runtime exception.
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue