diff --git a/libraries/bot-connector/src/test/java/com/microsoft/bot/connector/JwtTokenValidationTests.java b/libraries/bot-connector/src/test/java/com/microsoft/bot/connector/JwtTokenValidationTests.java index e0bc4221f..45db7c97a 100644 --- a/libraries/bot-connector/src/test/java/com/microsoft/bot/connector/JwtTokenValidationTests.java +++ b/libraries/bot-connector/src/test/java/com/microsoft/bot/connector/JwtTokenValidationTests.java @@ -582,27 +582,17 @@ public void GovernmentChannelValidation_WrongServiceClaimValue_Fails() { } private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(String appId, String pwd, String channelService) throws IOException, ExecutionException, InterruptedException { - ChannelProvider channel = new SimpleChannelProvider(channelService); - String header = channel.isGovernment() ? getGovHeaderToken() : getHeaderToken(); - - JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(header, appId, pwd, channel); + String header = "Bearer " + new MicrosoftAppCredentials(appId, pwd).getToken().join(); + JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(header, appId, pwd, channelService); } - private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(String header, String appId, String pwd, ChannelProvider channel) { + private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Succeeds(String header, String appId, String pwd, String channelService) { CredentialProvider credentials = new SimpleCredentialProvider(appId, pwd); + ChannelProvider channel = new SimpleChannelProvider(channelService); - try { - ClaimsIdentity identity = JwtTokenValidation.validateAuthHeader( - header, - credentials, - channel, - "", - "https://webchat.botframework.com/").join(); + ClaimsIdentity identity = JwtTokenValidation.validateAuthHeader(header, credentials, channel, null, "https://webchat.botframework.com/").join(); - Assert.assertTrue(identity.isAuthenticated()); - } catch (Exception e) { - Assert.fail("Should not have thrown " + e.getClass().getName()); - } + Assert.assertTrue(identity.isAuthenticated()); } private void JwtTokenValidation_ValidateAuthHeader_WithChannelService_Throws(String header, String appId, String pwd, String channelService) throws ExecutionException, InterruptedException { diff --git a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/Activity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/Activity.java index 6d336e698..aff2b263e 100644 --- a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/Activity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/Activity.java @@ -1820,6 +1820,28 @@ public void teamsNotifyUser() { teamsChannelData.setNotification(new NotificationInfo(true)); } + /** + * Sets the notification of a meeting in the TeamsChannelData. + * @param alertInMeeting True if this is a meeting alert. + * @param externalResourceUrl The external resource Url. + */ + public void teamsNotifyUser(boolean alertInMeeting, String externalResourceUrl) { + TeamsChannelData teamsChannelData; + + try { + teamsChannelData = getChannelData(TeamsChannelData.class); + } catch (JsonProcessingException jpe) { + teamsChannelData = null; + } + + if (teamsChannelData == null) { + teamsChannelData = new TeamsChannelData(); + setChannelData(teamsChannelData); + } + + teamsChannelData.setNotification(new NotificationInfo(true, externalResourceUrl)); + } + /** * Returns this activity as a Message Activity; or null, if this is not that type of activity. * diff --git a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/NotificationInfo.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/NotificationInfo.java index 61c6845ac..95a3db4dc 100644 --- a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/NotificationInfo.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/NotificationInfo.java @@ -15,14 +15,11 @@ public class NotificationInfo { @JsonProperty(value = "alert") private Boolean alert; - /** - * Initialize new NotificationInfo. - * - * @param withAlert initial alert value. - */ - public NotificationInfo(boolean withAlert) { - setAlert(withAlert); - } + @JsonProperty(value = "alertInMeeting") + private Boolean alertInMeeting; + + @JsonProperty(value = "externalResourceUrl") + private String externalResourceUrl; /** * Getter for alert. @@ -42,6 +39,38 @@ public void setAlert(Boolean withAlert) { alert = withAlert; } + /** + * Indicates if this is a meeting alert. + * @return True if this is a meeting alert. + */ + public Boolean getAlertInMeeting() { + return alertInMeeting; + } + + /** + * Indicates if this is a meeting alert. + * @param withAlertInMeeting True if this is a meeting alert. + */ + public void setAlertInMeeting(Boolean withAlertInMeeting) { + alertInMeeting = withAlertInMeeting; + } + + /** + * Gets the resource Url of a meeting alert. + * @return The external resource url. + */ + public String getExternalResourceUrl() { + return externalResourceUrl; + } + + /** + * The resource Url of a meeting alert. + * @param withExternalResourceUrl The external resource Url. + */ + public void setExternalResourceUrl(String withExternalResourceUrl) { + externalResourceUrl = withExternalResourceUrl; + } + /** * A new instance of NotificationInfo. * @@ -51,6 +80,17 @@ public NotificationInfo(Boolean withAlert) { alert = withAlert; } + /** + * A new instance of a meeting alert. + * @param withAlertInMeeting True if this is a meeting alert. + * @param withExternalResourceUrl The external resource Url. + */ + public NotificationInfo(boolean withAlertInMeeting, String withExternalResourceUrl) { + setAlert(true); + setAlertInMeeting(withAlertInMeeting); + setExternalResourceUrl(withExternalResourceUrl); + } + /** * A new instance of NotificationInfo. */