Skip to content

Commit

Permalink
Brand information (registration provider only; #46)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Apr 16, 2017
1 parent a0c9b9a commit 2d7c7a0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/main/java/org/kontalk/xmppserver/KontalkIqRegister.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Kontalk XMPP Tigase extension
* Copyright (C) 2015 Kontalk Devteam <[email protected]>
* Copyright (C) 2017 Kontalk Devteam <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -659,6 +659,16 @@ private Element prepareSMSResponseForm(String from, PhoneNumberVerificationProvi
form.addField(Field.fieldTextSingle("from", from, "Sender ID"));
form.addField(Field.fieldTextSingle("challenge", provider.getChallengeType(), "Challenge type"));

String brandImage = provider.getBrandImage();
if (brandImage != null) {
form.addField(Field.fieldTextSingle("brand-image", brandImage, "Brand logo"));

String brandLink = provider.getBrandLink();
if (brandLink != null) {
form.addField(Field.fieldTextSingle("brand-link", brandLink, "Brand link"));
}
}

query.addChild(form.getElement());
return query;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Kontalk XMPP Tigase extension
* Copyright (C) 2017 Kontalk Devteam <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.kontalk.xmppserver.registration;

import tigase.db.TigaseDBException;

import java.util.Map;

/**
* Base class for a branded SMS verification provider.
* @author Daniele Ricci
*/
public abstract class BrandedSMSVerificationProvider extends AbstractSMSVerificationProvider {

protected String brandImage;
protected String brandLink;

@Override
public void init(Map<String, Object> settings) throws TigaseDBException {
super.init(settings);
brandImage = (String) settings.get("brand-image");
brandLink = (String) settings.get("brand-link");
}

@Override
public String getBrandImage() {
return brandImage;
}

@Override
public String getBrandLink() {
return brandLink;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Kontalk XMPP Tigase extension
* Copyright (C) 2015 Kontalk Devteam <[email protected]>
* Copyright (C) 2017 Kontalk Devteam <[email protected]>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -63,6 +63,17 @@ public RegistrationRequest startVerification(String domain, String phoneNumber)
/** Returns true if this provider supports this kind if registration request. */
public boolean supportsRequest(RegistrationRequest request);

/** The challenge type implemented by this provider. */
public String getChallengeType();

/** The brand image logo for this provider, if any. */
public default String getBrandImage() {
return null;
}

/** The brand link the image logo will point to, if any. */
public default String getBrandLink() {
return null;
}

}

0 comments on commit 2d7c7a0

Please sign in to comment.