-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add authentication DAO layer for user def auth mgt.
- Loading branch information
1 parent
56b7c3b
commit 5ef08cc
Showing
7 changed files
with
783 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...n/src/main/java/org/wso2/carbon/identity/application/common/cache/AuthenticatorCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. 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.identity.application.common.cache; | ||
|
||
import org.wso2.carbon.identity.core.cache.BaseCache; | ||
import org.wso2.carbon.utils.CarbonUtils; | ||
|
||
/** | ||
* Cache for the user defined local application authenticator configurations. | ||
*/ | ||
public class AuthenticatorCache extends BaseCache<AuthenticatorCacheKey, AuthenticatorCacheEntry> { | ||
|
||
private static final String CACHE_NAME = "AuthenticatorCache"; | ||
private static final AuthenticatorCache INSTANCE = new AuthenticatorCache(); | ||
|
||
private AuthenticatorCache() { | ||
|
||
super(CACHE_NAME); | ||
} | ||
|
||
/** | ||
* Get Authenticator cache by the name instance. | ||
* | ||
* @return Authenticator cache by name instance. | ||
*/ | ||
public static AuthenticatorCache getInstance() { | ||
|
||
CarbonUtils.checkSecurity(); | ||
return INSTANCE; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
.../main/java/org/wso2/carbon/identity/application/common/cache/AuthenticatorCacheEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. 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.identity.application.common.cache; | ||
|
||
import org.wso2.carbon.identity.application.common.model.UserDefinedLocalAuthenticatorConfig; | ||
import org.wso2.carbon.identity.core.cache.CacheEntry; | ||
|
||
/** | ||
* Cache Entry for the user defined local application authenticator configurations. | ||
*/ | ||
public class AuthenticatorCacheEntry extends CacheEntry { | ||
|
||
private UserDefinedLocalAuthenticatorConfig authenticatorConfig; | ||
|
||
public AuthenticatorCacheEntry(UserDefinedLocalAuthenticatorConfig authenticatorConfig) { | ||
|
||
this.authenticatorConfig = authenticatorConfig; | ||
} | ||
|
||
public UserDefinedLocalAuthenticatorConfig getAuthenticatorConfig() { | ||
|
||
return authenticatorConfig; | ||
} | ||
|
||
public void setAuthenticatorConfig(UserDefinedLocalAuthenticatorConfig authenticatorConfig) { | ||
|
||
this.authenticatorConfig = authenticatorConfig; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...rc/main/java/org/wso2/carbon/identity/application/common/cache/AuthenticatorCacheKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. 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.identity.application.common.cache; | ||
|
||
import org.wso2.carbon.identity.core.cache.CacheKey; | ||
|
||
/** | ||
* Cache key for the user defined local application authenticator configurations. | ||
*/ | ||
public class AuthenticatorCacheKey extends CacheKey { | ||
|
||
private final String authenticatorName; | ||
|
||
public AuthenticatorCacheKey(String authenticatorName) { | ||
|
||
this.authenticatorName = authenticatorName; | ||
} | ||
|
||
public String getAuthenticatorName() { | ||
|
||
return authenticatorName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
|
||
if (!(o instanceof AuthenticatorCacheKey)) { | ||
return false; | ||
} | ||
return authenticatorName.equals(((AuthenticatorCacheKey) o).getAuthenticatorName()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
|
||
return authenticatorName.hashCode(); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...main/java/org/wso2/carbon/identity/application/common/dao/AuthenticatorManagementDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. 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.identity.application.common.dao; | ||
|
||
import org.wso2.carbon.identity.application.common.exception.AuthenticatorMgtException; | ||
import org.wso2.carbon.identity.application.common.model.UserDefinedLocalAuthenticatorConfig; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This interface performs CRUD operations for the user defined local application authenticator configurations. | ||
*/ | ||
public interface AuthenticatorManagementDAO { | ||
|
||
/** | ||
* Create a new user defined local application authenticator configuration. | ||
* | ||
* @param authenticatorConfig Local application authenticator configuration. | ||
* @param tenantId Tenant Id. | ||
* | ||
* @return Created UserDefinedLocalAuthenticatorConfig. | ||
* @throws AuthenticatorMgtException If an error occurs while adding the authenticator configuration. | ||
*/ | ||
UserDefinedLocalAuthenticatorConfig addUserDefinedLocalAuthenticator( | ||
UserDefinedLocalAuthenticatorConfig authenticatorConfig, int tenantId) throws AuthenticatorMgtException; | ||
|
||
/** | ||
* Update a user defined local application authenticator configuration. | ||
* | ||
* @param existingAuthenticatorConfig Existing Local application authenticator configuration. | ||
* @param updatedAuthenticatorConfig New local application authenticator configuration. | ||
* @param tenantId Tenant Id. | ||
* | ||
* @return Updated UserDefinedLocalAuthenticatorConfig. | ||
* @throws AuthenticatorMgtException If an error occurs while updating the authenticator configuration. | ||
*/ | ||
UserDefinedLocalAuthenticatorConfig updateUserDefinedLocalAuthenticator( | ||
UserDefinedLocalAuthenticatorConfig existingAuthenticatorConfig, | ||
UserDefinedLocalAuthenticatorConfig updatedAuthenticatorConfig, int tenantId) | ||
throws AuthenticatorMgtException; | ||
|
||
/** | ||
* Retrieve a Local user defined Application Authenticator configuration by name. | ||
* | ||
* @param authenticatorConfigName Name of the local application authenticator configuration. | ||
* @param tenantId Tenant Id. | ||
* | ||
* @return Retrieved UserDefinedLocalAuthenticatorConfig | ||
* @throws AuthenticatorMgtException If an error occurs while retrieving the authenticator configuration. | ||
*/ | ||
UserDefinedLocalAuthenticatorConfig getUserDefinedLocalAuthenticator( | ||
String authenticatorConfigName, int tenantId) throws AuthenticatorMgtException; | ||
|
||
/** | ||
* Retrieve all user defined local application authenticator configurations. | ||
* | ||
* @param tenantId Tenant Id. | ||
* | ||
* @return Retrieved UserDefinedLocalAuthenticatorConfig | ||
* @throws AuthenticatorMgtException If an error occurs while retrieving the authenticator configurations. | ||
*/ | ||
List<UserDefinedLocalAuthenticatorConfig> getAllUserDefinedLocalAuthenticator(int tenantId) | ||
throws AuthenticatorMgtException; | ||
|
||
/** | ||
* Create a new user defined local application authenticator configuration. | ||
* | ||
* @param authenticatorConfigName Name of the local application authenticator configuration. | ||
* @param tenantId Tenant Id. | ||
* | ||
* @throws AuthenticatorMgtException If an error occurs while deleting the authenticator configuration. | ||
*/ | ||
void deleteUserDefinedLocalAuthenticator(String authenticatorConfigName, UserDefinedLocalAuthenticatorConfig | ||
authenticatorConfig, int tenantId) throws AuthenticatorMgtException; | ||
} |
Oops, something went wrong.