forked from community/device-mgt-core
Merge pull request #301 from ayyoob/transport
Added support for push notification(xmpp, mqtt)revert-70aa11f8
commit
66f4c0607d
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.context.CarbonContext;
|
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
||||||
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
|
|
||||||
|
|
||||||
public class MQTTPushNotificationStrategyUtil {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(MQTTPushNotificationStrategyUtil.class);
|
|
||||||
|
|
||||||
public static String getAuthenticatedUser() {
|
|
||||||
CarbonContext carbonContext = CarbonContext.getThreadLocalCarbonContext();
|
|
||||||
String username = carbonContext.getUsername();
|
|
||||||
String tenantDomain = carbonContext.getTenantDomain();
|
|
||||||
if (username.endsWith(tenantDomain)) {
|
|
||||||
return username.substring(0, username.lastIndexOf("@"));
|
|
||||||
}
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAuthenticatedUserTenantDomain() {
|
|
||||||
return CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This exception is thrown whether the xmpp configured with invalid configuration.
|
||||||
|
*/
|
||||||
|
public class InvalidConfigurationException extends RuntimeException {
|
||||||
|
|
||||||
|
public InvalidConfigurationException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidConfigurationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidConfigurationException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidConfigurationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidConfigurationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.internal.util;
|
||||||
|
|
||||||
|
public final class XMPPAdapterConstants {
|
||||||
|
|
||||||
|
private XMPPAdapterConstants() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String XMPP_ADAPTER_TYPE = "xmpp";
|
||||||
|
public static final String XMPP_ADAPTER_PROPERTY_PASSWORD = "password";
|
||||||
|
public static final String XMPP_ADAPTER_PROPERTY_JID = "jid";
|
||||||
|
public static final String SUBJECT_PROPERTY_KEY = "subject";
|
||||||
|
public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType";
|
||||||
|
public static final String CHAT_PROPERTY_KEY = "chat";
|
||||||
|
public static final String XMPP_ADAPTER_PROPERTY_HOST = "host";
|
||||||
|
public static final String XMPP_ADAPTER_PROPERTY_PORT = "port";
|
||||||
|
public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username";
|
||||||
|
public static final String XMPP_ADAPTER_PROPERTY_NAME = "xmpp.adapter.name";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.oauth.extensions.OAuthExtUtils;
|
||||||
|
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
|
||||||
|
import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler;
|
||||||
|
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;
|
||||||
|
|
||||||
|
public class ExtendedJWTBearerGrantHandler extends JWTBearerGrantHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
|
||||||
|
return OAuthExtUtils.setScopes(tokReqMsgCtx);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue