Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private static Class<?> getClass(String platformString) {
return AppleInstallation.class;
case "baidu":
return BaiduInstallation.class;
case "browser":
return BrowserInstallation.class;
case "fcm":
return FcmInstallation.class;
case "mpns":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------

package com.windowsazure.messaging;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;

/**
* This class represents Browser Push PNS credentials for Azure Notification Hubs.
*/
public final class BrowserCredential extends PnsCredential {
private String subject;
private String vapidPublicKey;
private String vapidPrivateKey;

/**
* Creates a new BrowserCredential with default values.
*/
public BrowserCredential() {
}

/**
* Creates a BrowserCredential with subject, VAPID public key and private key.
* @param subject The subject in mailto: or http:// form.
* @param vapidPublicKey The VAPID public key.
* @param vapidPrivateKey The VAPID private key.
*/
public BrowserCredential(String subject, String vapidPublicKey, String vapidPrivateKey) {
this.subject = subject;
this.vapidPublicKey = vapidPublicKey;
this.vapidPrivateKey = vapidPrivateKey;
}

/**
* Gets the browser credential subject.
* @return The browser credential subject.
*/
public String getSubject() { return subject; }

/**
* Sets the browser credential subject.
* @param value The new browser credential subject to set.
*/
public void setSubject(String value) { subject = value; }

/**
* Gets the browser credential VAPID public key.
* @return The browser credential VAPID public key.
*/
public String getVapidPublicKey() { return vapidPublicKey; }

/**
* Sets the browser credential VAPID public key.
* @param value The browser credential VAPID public key to set.
*/
public void setVapidPublicKey(String value) { vapidPublicKey = value; }

/**
* Gets the browser credential VAPID private key.
* @return The browser credential VAPID private key.
*/
public String getVapidPrivateKey() { return vapidPrivateKey; }

/**
* Sets the browser credential VAPID private key.
* @param value The browser credential VAPID private key to set.
*/
public void setVapidPrivateKey(String value) { vapidPrivateKey = value; }

@Override
public List<AbstractMap.SimpleEntry<String, String>> getProperties() {
ArrayList<AbstractMap.SimpleEntry<String, String>> result = new ArrayList<>();
result.add(new AbstractMap.SimpleEntry<>("Subject", subject));
result.add(new AbstractMap.SimpleEntry<>("VapidPublicKey", vapidPublicKey));
result.add(new AbstractMap.SimpleEntry<>("VapidPrivateKey", vapidPrivateKey));
return result;
}

@Override
public String getRootTagName() {
return "BrowserCredential";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.windowsazure.messaging;

/**
* This class represents an installation for browser push.
*/
public class BrowserInstallation extends BaseInstallation {
private BrowserPushChannel pushChannel;

/**
* Creates a new instance of the BrowserInstallation class.
*
* @param installationId The ID for the installation.
*/
public BrowserInstallation(String installationId) {
this(installationId, (String[]) null);
}

/**
* Creates a new instance of the BrowserInstallation class.
*
* @param installationId The ID for the installation.
* @param tags The tags for the installation.
*/
public BrowserInstallation(String installationId, String... tags) {
this(installationId, null, tags);
}

/**
* Creates a new instance of the Installation class.
*
* @param installationId The ID for the installation.
*/
public BrowserInstallation(String installationId, BrowserPushChannel pushChannel) {
this(installationId, pushChannel, (String[]) null);
}

/**
* Creates a new instance of the Installation class.
* @param installationId The ID for the installation.
* @param pushChannel The device specific push channel for the installation.
* @param tags The tags for the installation.
*/
public BrowserInstallation(String installationId, BrowserPushChannel pushChannel, String... tags) {
super(installationId, NotificationPlatform.Browser, tags);
this.pushChannel = pushChannel;
}

/**
* Gets the PNS specific push channel for the installation.
*
* @return The PNS specific push channel for the installation.
*/
public BrowserPushChannel getPushChannel() { return pushChannel; }

/**
* Sets the PNS specific push channel for the installation.
*
* @param value The PNS specific push channel for the installation
*/
public void setPushChannel(BrowserPushChannel value) { pushChannel = value; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.windowsazure.messaging;

public class BrowserNotification extends Notification {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.windowsazure.messaging;

import java.util.Objects;

/**
* This class represents
*/
public class BrowserPushChannel {
private String endpoint;
private String p256dh;
private String auth;

/**
* Creates a new instance of the BrowserPushChannel class.
*/
public BrowserPushChannel() {

}

/**
* Creates a new instance of the BrowserPushChannel class.
* @param endpoint The browser PNS endpoint URL.
* @param p256dh The P256DH key from the browser registration.
* @param auth The auth secret from the browser registration.
*/
public BrowserPushChannel(
String endpoint,
String p256dh,
String auth
) {
this.endpoint = endpoint;
this.p256dh = p256dh;
this.auth = auth;
}

/**
* Gets the browser PNS endpoint URL.
* @return The browser PNS endpoint URL.
*/
public String getEndpoint() { return endpoint; }

/**
* Sets the browser PNS endpoint URL.
* @param value The browser PNS endpoint URL.
*/
public void setEndpoint(String value) { endpoint = value; }

/**
* Gets the browser subscription p256dh key.
* @return The browser subscription p256dh key.
*/
public String getP256dh() { return p256dh; }

/**
* Sets the browser subscription p256dh key.
* @param value The browser subscription p256dh key.
*/
public void setP256dh(String value) { p256dh = value; }

/**
* Gets the browser subscription auth secret.
* @return The browser subscription auth secret.
*/
public String getAuth() { return auth; }

/**
* Sets the browser subscription auth secret.
* @param value The browser subscription auth secret.
*/
public void setAuth(String value) { auth = value; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BrowserPushChannel that = (BrowserPushChannel) o;
return Objects.equals(getEndpoint(), that.getEndpoint()) && Objects.equals(getP256dh(), that.getP256dh()) && Objects.equals(getAuth(), that.getAuth());
}

@Override
public int hashCode() {
return Objects.hash(getEndpoint(), getP256dh(), getAuth());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------

package com.windowsazure.messaging;

import java.util.Objects;

/**
* This class represents a Browser Push device registration.
*/
public class BrowserRegistration extends Registration {
private static final String BROWSER_NATIVE_REGISTRATION1 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"><content type=\"application/xml\"><BrowserRegistrationDescription xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/netservices/2010/10/servicebus/connect\">";
private static final String BROWSER_NATIVE_REGISTRATION2 = "<Endpoint>";
private static final String BROWSER_NATIVE_REGISTRATION3 = "</Endpoint><P256DH>";
private static final String BROWSER_NATIVE_REGISTRATION4 = "</P256DH><Auth>";
private static final String BROWSER_NATIVE_REGISTRATION5 = "</Auth></BrowserRegistrationDescription></content></entry>";

protected String endpoint;
protected String p256dh;
protected String auth;

/**
* Creates a new instance of the BrowserRegistration class.
*/
public BrowserRegistration() {
super();
}

/**
* Creates a new instance of the BrowserRegistration class with endpoint, p256dh and auth secret.
* @param endpoint The browser PNS endpoint URL.
* @param p256dh The P256DH key from the browser registration.
* @param auth The auth secret from the browser registration.
*/
public BrowserRegistration(String endpoint, String p256dh, String auth) {
super();
this.endpoint = endpoint;
this.p256dh = p256dh;
this.auth = auth;
}

/**
* Creates a new instance of the BrowserRegistration class with endpoint, p256dh and auth secret.
* @param registrationId The Azure Notification Hubs registration ID.
* @param endpoint The browser PNS endpoint URL.
* @param p256dh The P256DH key from the browser registration.
* @param auth The auth secret from the browser registration.
*/
public BrowserRegistration(String registrationId, String endpoint, String p256dh, String auth) {
super(registrationId);
this.endpoint = endpoint;
this.p256dh = p256dh;
this.auth = auth;
}

/**
* Gets the browser PNS endpoint URL.
* @return The browser PNS endpoint URL.
*/
public String getEndpoint() { return endpoint; }

/**
* Sets the browser PNS endpoint URL.
* @param value The browser PNS endpoint URL.
*/
public void setEndpoint(String value) { endpoint = value; }

/**
* Gets the browser subscription p256dh key.
* @return The browser subscription p256dh key.
*/
public String getP256dh() { return p256dh; }

/**
* Sets the browser subscription p256dh key.
* @param value The browser subscription p256dh key.
*/
public void setP256dh(String value) { p256dh = value; }

/**
* Gets the browser subscription auth secret.
* @return The browser subscription auth secret.
*/
public String getAuth() { return auth; }

/**
* Sets the browser subscription auth secret.
* @param value The browser subscription auth secret.
*/
public void setAuth(String value) { auth = value; }

/**
* Gets the PNS handle for getting devices by channel.
* @return The PNS handle for getting devices by channel.
*/
@Override
public String getPnsHandle() { return endpoint; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
BrowserRegistration that = (BrowserRegistration) o;
return Objects.equals(getEndpoint(), that.getEndpoint()) && Objects.equals(getP256dh(), that.getP256dh()) && Objects.equals(getAuth(), that.getAuth());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getEndpoint(), getP256dh(), getAuth());
}

@Override
public String getXml() {
return BROWSER_NATIVE_REGISTRATION1 +
getTagsXml() +
BROWSER_NATIVE_REGISTRATION2 +
endpoint +
BROWSER_NATIVE_REGISTRATION3 +
p256dh +
BROWSER_NATIVE_REGISTRATION4 +
auth +
BROWSER_NATIVE_REGISTRATION5;
}
}
Loading