synchronized (LOCK) { if (getOwnJid() == null) { throw new SmackException.NotLoggedInException();
public LoggedInOmemoManager(OmemoManager manager) throws SmackException.NotLoggedInException { if (manager == null) { throw new IllegalArgumentException("OmemoManager cannot be null."); } if (manager.getOwnJid() == null) { if (manager.getConnection().isAuthenticated()) { manager.ownJid = manager.getConnection().getUser().asBareJid(); } else { throw new SmackException.NotLoggedInException(); } } this.manager = manager; }
/** * Initializes the OmemoManager. This method must be called before the manager can be used. * * @throws CorruptedOmemoKeyException * @throws InterruptedException * @throws SmackException.NoResponseException * @throws SmackException.NotConnectedException * @throws XMPPException.XMPPErrorException * @throws SmackException.NotLoggedInException * @throws PubSubException.NotALeafNodeException */ public void initialize() throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException { synchronized (LOCK) { if (!connection().isAuthenticated()) { throw new SmackException.NotLoggedInException(); } if (getTrustCallback() == null) { throw new IllegalStateException("No TrustCallback set."); } getOmemoService().init(new LoggedInOmemoManager(this)); ServiceDiscoveryManager.getInstanceFor(connection()).addFeature(PEP_NODE_DEVICE_LIST_NOTIFY); } }
/** * Get the XMPPConnection of this Manager if it's authenticated, i.e. logged in. Otherwise throw a {@link NotLoggedInException}. * * @return the XMPPConnection of this Manager. * @throws NotLoggedInException if the connection is not authenticated. */ protected final XMPPConnection getAuthenticatedConnectionOrThrow() throws NotLoggedInException { XMPPConnection connection = connection(); if (!connection.isAuthenticated()) { throw new NotLoggedInException(); } return connection; }
/** * Rotate the signedPreKey published in our OmemoBundle and republish it. This should be done every now and * then (7-14 days). The old signedPreKey should be kept for some more time (a month or so) to enable decryption * of messages that have been sent since the key was changed. * * @throws CorruptedOmemoKeyException When the IdentityKeyPair is damaged. * @throws InterruptedException XMPP error * @throws XMPPException.XMPPErrorException XMPP error * @throws SmackException.NotConnectedException XMPP error * @throws SmackException.NoResponseException XMPP error * @throws SmackException.NotLoggedInException */ public void rotateSignedPreKey() throws CorruptedOmemoKeyException, SmackException.NotLoggedInException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { synchronized (LOCK) { if (!connection().isAuthenticated()) { throw new SmackException.NotLoggedInException(); } // generate key getOmemoService().getOmemoStoreBackend().changeSignedPreKey(getOwnDevice()); // publish OmemoBundleElement bundle = getOmemoService().getOmemoStoreBackend().packOmemoBundle(getOwnDevice()); OmemoService.publishBundle(connection(), getOwnDevice(), bundle); } }
/** * Get the fingerprint of a contacts device. * @param device contacts OmemoDevice * @return fingerprint * @throws CannotEstablishOmemoSessionException if we have no session yet, and are unable to create one. * @throws SmackException.NotLoggedInException * @throws CorruptedOmemoKeyException if the copy of the fingerprint we have is corrupted. * @throws SmackException.NotConnectedException * @throws InterruptedException * @throws SmackException.NoResponseException */ public OmemoFingerprint getFingerprint(OmemoDevice device) throws CannotEstablishOmemoSessionException, SmackException.NotLoggedInException, CorruptedOmemoKeyException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { synchronized (LOCK) { if (getOwnJid() == null) { throw new SmackException.NotLoggedInException(); } if (device.equals(getOwnDevice())) { return getOwnFingerprint(); } return getOmemoService().getOmemoStoreBackend().getFingerprintAndMaybeBuildSession(new LoggedInOmemoManager(this), device); } }
/** * Build a fresh session with a contacts device. * This might come in handy if a session is broken. * * @param contactsDevice OmemoDevice of a contact. * * @throws InterruptedException * @throws SmackException.NoResponseException * @throws CorruptedOmemoKeyException if our or their identityKey is corrupted. * @throws SmackException.NotConnectedException * @throws CannotEstablishOmemoSessionException if no new session can be established. * @throws SmackException.NotLoggedInException if the connection is not authenticated. */ public void rebuildSessionWith(OmemoDevice contactsDevice) throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException, SmackException.NotConnectedException, CannotEstablishOmemoSessionException, SmackException.NotLoggedInException { if (!connection().isAuthenticated()) { throw new SmackException.NotLoggedInException(); } getOmemoService().buildFreshSessionWithDevice(connection(), getOwnDevice(), contactsDevice); }
/** * Return the fingerprint of our identity key. * * @return fingerprint * @throws SmackException.NotLoggedInException if we don't know our bareJid yet. * @throws CorruptedOmemoKeyException if our identityKey is corrupted. */ public OmemoFingerprint getOwnFingerprint() throws SmackException.NotLoggedInException, CorruptedOmemoKeyException { synchronized (LOCK) { if (getOwnJid() == null) { throw new SmackException.NotLoggedInException(); } return getOmemoService().getOmemoStoreBackend().getFingerprint(getOwnDevice()); } }
/** * Throw a {@link org.jivesoftware.smack.SmackException.NotLoggedInException} if the {@link XMPPConnection} of this * manager is not authenticated at this point. * * @throws SmackException.NotLoggedInException if we are not authenticated */ private void throwIfNotAuthenticated() throws SmackException.NotLoggedInException { if (!connection().isAuthenticated()) { throw new SmackException.NotLoggedInException(); } } }
/** * Get the XMPPConnection of this Manager if it's authenticated, i.e. logged in. Otherwise throw a {@link NotLoggedInException}. * * @return the XMPPConnection of this Manager. * @throws NotLoggedInException if the connection is not authenticated. */ protected final XMPPConnection getAuthenticatedConnectionOrThrow() throws NotLoggedInException { XMPPConnection connection = connection(); if (!connection.isAuthenticated()) { throw new NotLoggedInException(); } return connection; }