forked from community/device-mgt-core
Merge branch 'master' of https://gitlab.com/entgra/carbon-device-mgt
Conflicts: components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.javarevert-70ac1926
commit
5d6c614a7a
@ -0,0 +1 @@
|
||||
registry=http://nexus.entgra.io/repository/npm-group/
|
@ -0,0 +1,33 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.exceptions;
|
||||
|
||||
/**
|
||||
* Exception thrown due to Database Connection issues.
|
||||
*/
|
||||
public class DBConnectionException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -6779125067467878014L;
|
||||
|
||||
public DBConnectionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DBConnectionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.common.exceptions;
|
||||
|
||||
public class OTPManagementException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 397485329551276175L;
|
||||
|
||||
public OTPManagementException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
}
|
||||
|
||||
public OTPManagementException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public OTPManagementException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public OTPManagementException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public OTPManagementException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (pvt) Ltd. 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.common.exceptions;
|
||||
|
||||
public class UnAuthorizedException extends DeviceManagementException {
|
||||
private static final long serialVersionUID = 2304023531260840549L;
|
||||
|
||||
public UnAuthorizedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UnAuthorizedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public UnAuthorizedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public UnAuthorizedException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
}
|
||||
|
||||
public UnAuthorizedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.general;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class OneTimeTokenDetails extends TenantDetail {
|
||||
|
||||
String password;
|
||||
String token;
|
||||
long createdDate;
|
||||
long updatedDate;
|
||||
boolean isExpired;
|
||||
String metaInfo;
|
||||
Map<String, String> replaceValue;
|
||||
String emailType;
|
||||
|
||||
public long getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
|
||||
public void setCreatedDate(long createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
public long getUpdatedDate() {
|
||||
return updatedDate;
|
||||
}
|
||||
|
||||
public void setUpdatedDate(long updatedDate) {
|
||||
this.updatedDate = updatedDate;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return isExpired;
|
||||
}
|
||||
|
||||
public void setExpired(boolean expired) {
|
||||
isExpired = expired;
|
||||
}
|
||||
|
||||
public String getMetaInfo() {
|
||||
return metaInfo;
|
||||
}
|
||||
|
||||
public void setMetaInfo(String metaInfo) {
|
||||
this.metaInfo = metaInfo;
|
||||
}
|
||||
|
||||
public Map<String, String> getReplaceValue() {
|
||||
return replaceValue;
|
||||
}
|
||||
|
||||
public void setReplaceValue(Map<String, String> replaceValue) {
|
||||
this.replaceValue = replaceValue;
|
||||
}
|
||||
|
||||
public String getEmailType() {
|
||||
return emailType;
|
||||
}
|
||||
|
||||
public void setEmailType(String emailType) {
|
||||
this.emailType = emailType;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.invitation.mgt;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(
|
||||
value = "DeviceEnrollmentInvitation",
|
||||
description = "Holds data to send device enrollment invitation to list of existing users.")
|
||||
public class DeviceEnrollmentInvitation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6933837278652532052L;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "usernames",
|
||||
value = "List of usernames of users.",
|
||||
required = true)
|
||||
private List<String> usernames;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "deviceEnrollmentTypes",
|
||||
value = "List of enrollment types against device types.")
|
||||
private List<DeviceEnrollmentType> deviceEnrollmentTypes;
|
||||
|
||||
public List<String> getUsernames() {
|
||||
return usernames;
|
||||
}
|
||||
|
||||
public void setUsernames(List<String> usernames) {
|
||||
this.usernames = usernames;
|
||||
}
|
||||
|
||||
public List<DeviceEnrollmentType> getDeviceEnrollmentTypes() {
|
||||
return deviceEnrollmentTypes;
|
||||
}
|
||||
|
||||
public void setDeviceEnrollmentTypes(
|
||||
List<DeviceEnrollmentType> deviceEnrollmentTypes) {
|
||||
this.deviceEnrollmentTypes = deviceEnrollmentTypes;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package org.wso2.carbon.device.mgt.common.invitation.mgt;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import java.util.List;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "DeviceEnrollmentInvitationDetails", propOrder = {
|
||||
"enrollmentDetails"
|
||||
})
|
||||
public class DeviceEnrollmentInvitationDetails {
|
||||
|
||||
@XmlElement(name = "EnrollmentDetails")
|
||||
private List<EnrollmentDetails> enrollmentDetails;
|
||||
|
||||
public List<EnrollmentDetails> getEnrollmentDetails() {
|
||||
return enrollmentDetails;
|
||||
}
|
||||
|
||||
public void setEnrollmentDetails(List<EnrollmentDetails> enrollmentDetails) {
|
||||
this.enrollmentDetails = enrollmentDetails;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.invitation.mgt;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(
|
||||
value = "DeviceEnrollmentType",
|
||||
description = "Holds data of enrollment types against device types.")
|
||||
public class DeviceEnrollmentType implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6563596191450032613L;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "deviceType",
|
||||
value = "Device type (i.e: android, ios, windows)",
|
||||
required = true)
|
||||
private String deviceType;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "enrollmentType",
|
||||
value = "Enrollment type (i.e: BYOD, COPE, COSU)",
|
||||
required = true)
|
||||
private List<String> enrollmentType;
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(String deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public List<String> getEnrollmentType() {
|
||||
return enrollmentType;
|
||||
}
|
||||
|
||||
public void setEnrollmentType(List<String> enrollmentType) {
|
||||
this.enrollmentType = enrollmentType;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.wso2.carbon.device.mgt.common.invitation.mgt;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "EnrollmentDetails", propOrder = {
|
||||
"enrollmentType",
|
||||
"enrollmentSteps"
|
||||
})
|
||||
public class EnrollmentDetails {
|
||||
|
||||
@XmlElement(name = "EnrollmentType")
|
||||
private String enrollmentType;
|
||||
|
||||
@XmlElement(name = "EnrollmentSteps")
|
||||
private String enrollmentSteps;
|
||||
|
||||
public String getEnrollmentType() {
|
||||
return enrollmentType;
|
||||
}
|
||||
|
||||
public void setEnrollmentType(String enrollmentType) {
|
||||
this.enrollmentType = enrollmentType;
|
||||
}
|
||||
|
||||
public String getEnrollmentSteps() {
|
||||
return enrollmentSteps;
|
||||
}
|
||||
|
||||
public void setEnrollmentSteps(String enrollmentSteps) {
|
||||
this.enrollmentSteps = enrollmentSteps;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.otp.mgt;
|
||||
|
||||
public enum OTPEmailTypes {
|
||||
USER_VERIFY, DEVICE_ENROLLMENT
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.otp.mgt.dto;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class OneTimePinDTO {
|
||||
|
||||
int id;
|
||||
String otpToken;
|
||||
int tenantId;
|
||||
String username;
|
||||
String email;
|
||||
String emailType;
|
||||
String metaInfo;
|
||||
Timestamp createdAt;
|
||||
int expiryTime;
|
||||
boolean isExpired;
|
||||
|
||||
public int getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(int tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOtpToken() {
|
||||
return otpToken;
|
||||
}
|
||||
|
||||
public void setOtpToken(String otpToken) {
|
||||
this.otpToken = otpToken;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmailType() {
|
||||
return emailType;
|
||||
}
|
||||
|
||||
public void setEmailType(String emailType) {
|
||||
this.emailType = emailType;
|
||||
}
|
||||
|
||||
public String getMetaInfo() { return metaInfo; }
|
||||
|
||||
public void setMetaInfo(String metaInfo) {
|
||||
this.metaInfo = metaInfo;
|
||||
}
|
||||
|
||||
public Timestamp getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Timestamp createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public int getExpiryTime() {
|
||||
return expiryTime;
|
||||
}
|
||||
|
||||
public void setExpiryTime(int expiryTime) {
|
||||
this.expiryTime = expiryTime;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return isExpired;
|
||||
}
|
||||
|
||||
public void setExpired(boolean expired) {
|
||||
isExpired = expired;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.otp.mgt.wrapper;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OTPWrapper {
|
||||
|
||||
private String email;
|
||||
private String emailType;
|
||||
private String username;
|
||||
private List<Metadata> properties;
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmailType() {
|
||||
return emailType;
|
||||
}
|
||||
|
||||
public void setEmailType(String emailType) {
|
||||
this.emailType = emailType;
|
||||
}
|
||||
|
||||
public String getUsername() { return username; }
|
||||
|
||||
public void setUsername(String username) { this.username = username; }
|
||||
|
||||
public List<Metadata> getProperties() { return properties; }
|
||||
|
||||
public void setProperties(List<Metadata> properties) { this.properties = properties; }
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.roles.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "DefaultRoles")
|
||||
public class DefaultRoles {
|
||||
|
||||
private boolean enabled;
|
||||
private List<Role> roles;
|
||||
|
||||
@XmlElement(name = "Enabled", required = true)
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "Roles", required = true)
|
||||
@XmlElement(name = "Role", required = true)
|
||||
public List<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.roles.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "Role")
|
||||
public class Role {
|
||||
|
||||
private String name;
|
||||
private List<String> permissions;
|
||||
|
||||
@XmlElement(name = "Name", required = true)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "Permissions", required = true)
|
||||
@XmlElement(name = "Permission", required = true)
|
||||
public List<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.common.spi;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation;
|
||||
import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO;
|
||||
import org.wso2.carbon.device.mgt.common.otp.mgt.wrapper.OTPWrapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OTPManagementService {
|
||||
|
||||
/**
|
||||
* Create OTP token and store tenant details in the DB
|
||||
* @param otpWrapper OTP Mail Wrapper object which contains tenant details of registering user
|
||||
* @throws OTPManagementException if error occurs while creating OTP token and storing tenant details.
|
||||
* @throws BadRequestException if found and incompatible payload to create OTP token.
|
||||
*/
|
||||
void sendUserVerifyingMail(OTPWrapper otpWrapper) throws OTPManagementException, DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Check the validity of the OTP
|
||||
* @param oneTimeToken OTP
|
||||
* @return The OTP data
|
||||
* @throws OTPManagementException if error occurred whle verifying validity of the OPT
|
||||
* @throws BadRequestException if found an null value for OTP
|
||||
*/
|
||||
OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException;
|
||||
|
||||
/**
|
||||
* Invalidate the OTP and send welcome mail
|
||||
* @param oneTimeToken OTP
|
||||
* @param email email address
|
||||
* @param properties email properties to add to email body
|
||||
* @throws OTPManagementException if error occurred while invalidate the OTP or send welcome email
|
||||
*/
|
||||
void completeSelfRegistration(String oneTimeToken, String email, Map<String, String> properties)
|
||||
throws OTPManagementException;
|
||||
|
||||
/**
|
||||
* Create OTP token and send device enrollment invitation
|
||||
* @param deviceEnrollmentInvitation object which contains device enrollment invitation related details
|
||||
* @throws OTPManagementException if error occurred while creating OTP token &/ sending mail
|
||||
*/
|
||||
void sendDeviceEnrollmentInvitationMail(DeviceEnrollmentInvitation deviceEnrollmentInvitation)
|
||||
throws OTPManagementException;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (pvt) Ltd. 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.core.otp.mgt.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DBConnectionException;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.util.ConnectionManagerUtil;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* This class deals with getting the DB connection.
|
||||
*/
|
||||
public abstract class AbstractDAOImpl {
|
||||
|
||||
protected Connection getDBConnection() throws DBConnectionException {
|
||||
return ConnectionManagerUtil.getDBConnection();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.core.otp.mgt.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.exception.OTPManagementDAOException;
|
||||
|
||||
public interface OTPManagementDAO {
|
||||
|
||||
/**
|
||||
* Save OTP token data and tenant details of registering user
|
||||
* @param oneTimePinDTO OTPMailDTO
|
||||
* @return Primary key of the newly adding data raw
|
||||
* @throws OTPManagementDAOException if error occurred whule storing data
|
||||
*/
|
||||
int addOTPData(OneTimePinDTO oneTimePinDTO) throws OTPManagementDAOException;
|
||||
|
||||
/**
|
||||
* Get OTP data for requesting One Time Token
|
||||
* @param oneTimeToken One Time Token
|
||||
* @return {@link OneTimePinDTO}
|
||||
* @throws OTPManagementDAOException if error ocured while getting OTP data for requesting one time token
|
||||
*/
|
||||
OneTimePinDTO getOTPDataByToken (String oneTimeToken) throws OTPManagementDAOException;
|
||||
|
||||
/**
|
||||
* Expire the OTP
|
||||
* @param oneTimeToken OTP
|
||||
* @throws OTPManagementDAOException if error occurred while updating the OTP validity.
|
||||
*/
|
||||
boolean expireOneTimeToken(String oneTimeToken) throws OTPManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update OTP with renewed OTP
|
||||
* @param id ID
|
||||
* @param oneTimeToken One Time Token
|
||||
* @throws OTPManagementDAOException if error occured while updating OTP
|
||||
*/
|
||||
void renewOneTimeToken(int id, String oneTimeToken) throws OTPManagementDAOException;
|
||||
|
||||
/**
|
||||
* To veify whether email and email type exists or not
|
||||
* @param email email
|
||||
* @param emailType email type
|
||||
* @return true if email and email type exists otherwise returns false
|
||||
* @throws OTPManagementDAOException if error occurred while verify existance of the email and email type
|
||||
*/
|
||||
boolean isEmailExist (String email, String emailType) throws OTPManagementDAOException;
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (pvt) Ltd. 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.core.otp.mgt.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.UnsupportedDatabaseEngineException;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.dao.impl.GenericOTPManagementDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.dao.impl.OracleOTPManagementDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.dao.impl.PostgreSQLOTPManagementDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.dao.impl.SQLServerOTPManagementDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.util.ConnectionManagerUtil;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* This class intends to act as the primary entity that hides all DAO instantiation related complexities and logic so
|
||||
* that the business objection handling layer doesn't need to be aware of the same providing seamless plug-ability of
|
||||
* different data sources, connection acquisition mechanisms as well as different forms of DAO implementations to the
|
||||
* high-level implementations that require Application management related metadata persistence.
|
||||
*/
|
||||
public class OTPManagementDAOFactory {
|
||||
|
||||
private static String databaseEngine;
|
||||
private static final Log log = LogFactory.getLog(OTPManagementDAOFactory.class);
|
||||
|
||||
public static void init(String datasourceName) {
|
||||
ConnectionManagerUtil.resolveDataSource(datasourceName);
|
||||
databaseEngine = ConnectionManagerUtil.getDatabaseType();
|
||||
}
|
||||
|
||||
public static void init(DataSource dtSource) {
|
||||
try (Connection connection = dtSource.getConnection()) {
|
||||
databaseEngine = connection.getMetaData().getDatabaseProductName();
|
||||
} catch (SQLException e) {
|
||||
log.error("Error occurred while retrieving config.datasource connection", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static OTPManagementDAO getOTPManagementDAO() {
|
||||
if (databaseEngine != null) {
|
||||
switch (databaseEngine) {
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2:
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL:
|
||||
return new GenericOTPManagementDAOImpl();
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL:
|
||||
return new PostgreSQLOTPManagementDAOImpl();
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL:
|
||||
return new SQLServerOTPManagementDAOImpl();
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE:
|
||||
return new OracleOTPManagementDAOImpl();
|
||||
default:
|
||||
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Database engine has not initialized properly.");
|
||||
}
|
||||
}
|
@ -0,0 +1,243 @@
|
||||
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. 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.core.otp.mgt.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DBConnectionException;
|
||||
import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.dao.AbstractDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.dao.OTPManagementDAO;
|
||||
import org.wso2.carbon.device.mgt.core.otp.mgt.exception.OTPManagementDAOException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPManagementDAO {
|
||||
|
||||
private static final Log log = LogFactory.getLog(GenericOTPManagementDAOImpl.class);
|
||||
|
||||
@Override
|
||||
public int addOTPData(OneTimePinDTO oneTimePinDTO) throws OTPManagementDAOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Request received in DAO Layer to create an OTP data entry");
|
||||
log.debug("OTP Details : ");
|
||||
log.debug("OTP key : " + oneTimePinDTO.getOtpToken() + " Email : " + oneTimePinDTO.getEmail());
|
||||
}
|
||||
|
||||
String sql = "INSERT INTO DM_OTP_DATA "
|
||||
+ "(OTP_TOKEN, "
|
||||
+ "EMAIL, "
|
||||
+ "EMAIL_TYPE, "
|
||||
+ "META_INFO, "
|
||||
+ "CREATED_AT,"
|
||||
+ "TENANT_ID,"
|
||||
+ "USERNAME) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
|
||||
stmt.setString(1, oneTimePinDTO.getOtpToken());
|
||||
stmt.setString(2, oneTimePinDTO.getEmail());
|
||||
stmt.setString(3, oneTimePinDTO.getEmailType());
|
||||
stmt.setString(4, oneTimePinDTO.getMetaInfo());
|
||||
stmt.setTimestamp(5, timestamp);
|
||||
stmt.setInt(6, oneTimePinDTO.getTenantId());
|
||||
stmt.setString(7, oneTimePinDTO.getUsername());
|
||||
stmt.executeUpdate();
|
||||
try (ResultSet rs = stmt.getGeneratedKeys()) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} catch (DBConnectionException e) {
|
||||
String msg = "Error occurred while obtaining the DB connection to create an opt entry for email "
|
||||
+ oneTimePinDTO.getEmail();
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while executing SQL to create an otp entry for email " + oneTimePinDTO.getEmail();
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OneTimePinDTO getOTPDataByToken (String oneTimeToken) throws OTPManagementDAOException {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Request received in DAO Layer to get an OTP data entry for OTP");
|
||||
log.debug("OTP Details : OTP key : " + oneTimeToken );
|
||||
}
|
||||
|
||||
String sql = "SELECT "
|
||||
+ "ID, "
|
||||
+ "OTP_TOKEN, "
|
||||
+ "EMAIL, "
|
||||
+ "EMAIL_TYPE, "
|
||||
+ "META_INFO, "
|
||||
+ "CREATED_AT, "
|
||||
+ "EXPIRY_TIME, "
|
||||
+ "IS_EXPIRED, "
|
||||
+ "TENANT_ID, "
|
||||
+ "USERNAME FROM DM_OTP_DATA "
|
||||
+ "WHERE OTP_TOKEN = ?";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
stmt.setString(1, oneTimeToken);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
OneTimePinDTO oneTimePinDTO = new OneTimePinDTO();
|
||||
oneTimePinDTO.setId(rs.getInt("ID"));
|
||||
oneTimePinDTO.setOtpToken(rs.getString("OTP_TOKEN"));
|
||||
oneTimePinDTO.setEmail(rs.getString("EMAIL"));
|
||||
oneTimePinDTO.setEmailType(rs.getString("EMAIL_TYPE"));
|
||||
oneTimePinDTO.setMetaInfo(rs.getString("META_INFO"));
|
||||
oneTimePinDTO.setCreatedAt(rs.getTimestamp("CREATED_AT"));
|
||||
oneTimePinDTO.setExpiryTime(rs.getInt("EXPIRY_TIME"));
|
||||
oneTimePinDTO.setExpired(rs.getBoolean("IS_EXPIRED"));
|
||||
oneTimePinDTO.setTenantId(rs.getInt("TENANT_ID"));
|
||||
oneTimePinDTO.setUsername(rs.getString("USERNAME"));
|
||||
return oneTimePinDTO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (DBConnectionException e) {
|
||||
String msg = "Error occurred while obtaining the DB connection to get OPT data for given OTP. OTP: "
|
||||
+ oneTimeToken;
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while executing SQL to get OTP data for OTP. One time token: " + oneTimeToken;
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean expireOneTimeToken(String oneTimeToken) throws OTPManagementDAOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Request received in DAO Layer to update an OTP data entry for OTP");
|
||||
log.debug("OTP Details : OTP key : " + oneTimeToken );
|
||||
}
|
||||
|
||||
String sql = "UPDATE DM_OTP_DATA "
|
||||
+ "SET "
|
||||
+ "IS_EXPIRED = ? "
|
||||
+ "WHERE OTP_TOKEN = ?";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
stmt.setBoolean(1, true);
|
||||
stmt.setString(2, oneTimeToken);
|
||||
return stmt.executeUpdate() == 1;
|
||||
}
|
||||
} catch (DBConnectionException e) {
|
||||
String msg = "Error occurred while obtaining the DB connection to update the OTP token validity.";
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred when obtaining database connection for updating the OTP token validity.";
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renewOneTimeToken(int id, String oneTimeToken) throws OTPManagementDAOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Request received in DAO Layer to update an OTP data entry for OTP");
|
||||
log.debug("OTP Details : OTP key : " + oneTimeToken );
|
||||
}
|
||||
|
||||
String sql = "UPDATE DM_OTP_DATA "
|
||||
+ "SET "
|
||||
+ "OTP_TOKEN = ?, "
|
||||
+ "CREATED_AT = ? "
|
||||
+ "WHERE ID = ?";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
stmt.setString(1, oneTimeToken);
|
||||
stmt.setTimestamp(2, timestamp);
|
||||
stmt.setInt(3, id);
|
||||
stmt.executeUpdate();
|
||||
}
|
||||
} catch (DBConnectionException e) {
|
||||
String msg = "Error occurred while obtaining the DB connection to update the OTP token.";
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred when executing sql query to update the OTP token.";
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmailExist (String email, String emailType) throws OTPManagementDAOException {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Request received in DAO Layer to verify whether email was registed with emai type in OTP");
|
||||
log.debug("OTP Details : email : " + email + " email type: " + emailType );
|
||||
}
|
||||
|
||||
String sql = "SELECT "
|
||||
+ "ID "
|
||||
+ "FROM DM_OTP_DATA "
|
||||
+ "WHERE EMAIL = ? AND "
|
||||
+ "EMAIL_TYPE = ?";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
stmt.setString(1, email);
|
||||
stmt.setString(2, emailType);
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
return rs.next();
|
||||
}
|
||||
}
|
||||
} catch (DBConnectionException e) {
|
||||
String msg = "Error occurred while obtaining the DB connection to verify email and email type exist in OTP."
|
||||
+ " Email: " + email + "Email Type: " + emailType;
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while executing SQL to verify email and email type exist in OTP. Email: "
|
||||
+ email + "Email Type: " + emailType;
|
||||
log.error(msg, e);
|
||||
throw new OTPManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue