001/**
002 *
003 * Copyright 2017 Paul Schaub
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.omemo.element;
018
019import org.jivesoftware.smack.packet.ExtensionElement;
020import org.jivesoftware.smack.util.XmlStringBuilder;
021
022/**
023 * Class that represents an OMEMO Bundle element.
024 * TODO: Move functionality to here.
025 *
026 * @author Paul Schaub
027 */
028public abstract class OmemoBundleElement implements ExtensionElement {
029
030    public static final String BUNDLE = "bundle";
031    public static final String SIGNED_PRE_KEY_PUB = "signedPreKeyPublic";
032    public static final String SIGNED_PRE_KEY_ID = "signedPreKeyId";
033    public static final String SIGNED_PRE_KEY_SIG = "signedPreKeySignature";
034    public static final String IDENTITY_KEY = "identityKey";
035    public static final String PRE_KEYS = "prekeys";
036    public static final String PRE_KEY_PUB = "preKeyPublic";
037    public static final String PRE_KEY_ID = "preKeyId";
038
039    @Override
040    public abstract XmlStringBuilder toXML();
041
042    @Override
043    public boolean equals(Object other) {
044        if (!(other instanceof OmemoBundleElement)) {
045            return false;
046        }
047
048        OmemoBundleElement otherOmemoBundleElement = (OmemoBundleElement) other;
049        return toXML().equals(otherOmemoBundleElement.toXML());
050    }
051
052    @Override
053    public int hashCode() {
054        return this.toXML().hashCode();
055    }
056}