From 50c3ab940b9c9fdf5e864d969cea25f509af14b8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 4 Oct 2018 15:47:17 +0300 Subject: RFC6415: Web Host Metadata (WIP) --- .../src/main/java/com/cliqset/xrd/XRD.java | 166 +++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 juick-server/src/main/java/com/cliqset/xrd/XRD.java (limited to 'juick-server/src/main/java/com/cliqset/xrd/XRD.java') diff --git a/juick-server/src/main/java/com/cliqset/xrd/XRD.java b/juick-server/src/main/java/com/cliqset/xrd/XRD.java new file mode 100644 index 00000000..393e977b --- /dev/null +++ b/juick-server/src/main/java/com/cliqset/xrd/XRD.java @@ -0,0 +1,166 @@ +/* + Copyright 2010 Cliqset Inc. + + 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.cliqset.xrd; + +import javax.xml.namespace.QName; +import javax.xml.bind.annotation.*; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; + +import org.w3c.dom.Element; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name="XRD", namespace=XRDConstants.XRD_NAMESPACE) +@XmlAccessorType(XmlAccessType.FIELD) +public class XRD { + + @XmlAttribute(name="id", namespace=XRDConstants.XML_NAMESPACE) + private String id; + + @XmlAnyAttribute + private Map unknownAttributes; + + @XmlElement(name="Expires", namespace=XRDConstants.XRD_NAMESPACE) + private Expires expires; + + @XmlElement(name="Subject", namespace=XRDConstants.XRD_NAMESPACE) + private Subject subject; + + @XmlElement(name="Alias", namespace=XRDConstants.XRD_NAMESPACE) + private List aliases; + + @XmlElement(name="Property", namespace=XRDConstants.XRD_NAMESPACE) + private List properties; + + @XmlElement(name="Link", namespace=XRDConstants.XRD_NAMESPACE) + private List links; + + @XmlElement(name="Signature", namespace=XRDConstants.XML_SIG_NAMESPACE) + private List signatures; + + @XmlAnyElement + private List unknownElements; + + public void setExpires(Expires expires) { + this.expires = expires; + } + + public Expires getExpires() { + return expires; + } + + public void setSubject(Subject subject) { + this.subject = subject; + } + + public Subject getSubject() { + return subject; + } + + public void setAliases(List aliases) { + this.aliases = aliases; + } + + public List getAliases() { + return aliases; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public List getProperties() { + return properties; + } + + public void setLinks(List links) { + this.links = links; + } + + public List getLinks() { + return links; + } + + public void setSignatures(List signatures) { + this.signatures = signatures; + } + + public List getSignatures() { + return signatures; + } + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setUnknownAttributes(Map unknownAttributes) { + this.unknownAttributes = unknownAttributes; + } + + public Map getUnknownAttributes() { + return unknownAttributes; + } + + public void setUnknownElements(List unknownElements) { + this.unknownElements = unknownElements; + } + + public List getUnknownElements() { + return unknownElements; + } + + public boolean hasId() { + return null != this.id; + } + + public boolean hasExpires() { + return null != this.expires; + } + + public boolean hasSubject() { + return null != this.subject; + } + + public boolean hasAliases() { + return null != this.aliases; + } + + public boolean hasProperties() { + return null != this.properties; + } + + public boolean hasLinks() { + return null != this.links; + } + + public static XRD fromStream(InputStream stream) throws XRDException { + JAXBContext context; + try { + context = JAXBContext.newInstance(XRD.class); + return (XRD)context.createUnmarshaller().unmarshal(stream); + } catch (JAXBException e) { + throw new XRDException("Unable to deserialize stream into XRD", e); + } + } +} -- cgit v1.2.3