Skip to content

Commit

Permalink
Resolving merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduDilshan committed Apr 27, 2022
2 parents 6099fb8 + 9e0bd70 commit 1b8c506
Show file tree
Hide file tree
Showing 19 changed files with 1,112 additions and 134 deletions.
4 changes: 2 additions & 2 deletions components/org.wso2.carbon.identity.api.user.fido2/pom.xml
Expand Up @@ -23,12 +23,12 @@
<parent>
<groupId>org.wso2.carbon.identity.local.auth.fido</groupId>
<artifactId>identity-application-auth-fido</artifactId>
<version>5.3.21-SNAPSHOT</version>
<version>5.3.23-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<artifactId>org.wso2.carbon.identity.api.user.fido2</artifactId>
<version>5.3.21-SNAPSHOT</version>
<version>5.3.23-SNAPSHOT</version>
<packaging>jar</packaging>

<name>WSO2 Carbon - FIDO2 Identity Rest API</name>
Expand Down
Expand Up @@ -5,7 +5,7 @@
<groupId>org.wso2.carbon.identity.local.auth.fido</groupId>
<artifactId>identity-application-auth-fido</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>5.3.21-SNAPSHOT</version>
<version>5.3.23-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) (2019-2022), WSO2 Inc. (http://www.wso2.com).
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -22,72 +22,101 @@
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator;
import org.wso2.carbon.identity.application.authenticator.fido.FIDOAuthenticator;
import org.wso2.carbon.identity.application.authenticator.fido.u2f.U2FService;
import org.wso2.carbon.identity.user.store.configuration.listener.UserStoreConfigListener;
import org.wso2.carbon.user.core.service.RealmService;

/**
* @scr.component name="identity.application.authenticator.fido.component" immediate="true"
* @scr.reference name="realm.service"
* interface="org.wso2.carbon.user.core.service.RealmService"cardinality="1..1"
* policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
* OSGI declarative service component which handles registration and unregistration of FIDOAuthenticatorComponent.
*/
@Component(
name = "identity.application.authenticator.fido.component",
immediate = true
)
public class FIDOAuthenticatorServiceComponent {

private static final Log log = LogFactory.getLog(FIDOAuthenticatorServiceComponent.class);

private static RealmService realmService;

@Activate
protected void activate(ComponentContext context) {

FIDOAuthenticatorServiceDataHolder dataHolder = FIDOAuthenticatorServiceDataHolder.getInstance();
BundleContext bundleContext = context.getBundleContext();

FIDOAuthenticator fidoAuthenticator = FIDOAuthenticator.getInstance();

try {
bundleContext.registerService(ApplicationAuthenticator.class.getName(), fidoAuthenticator, null);
if (log.isDebugEnabled()) {
log.debug("FIDOAuthenticator service is registered");
log.debug("FIDOAuthenticator service is registered.");
}
} catch (Exception e) {
log.error("Error registering FIDOAuthenticator service", e);
log.error("Error registering FIDOAuthenticator service.", e);
}

U2FService u2FService = U2FService.getInstance();
try {
bundleContext.registerService(U2FService.class, u2FService, null);
if (log.isDebugEnabled()) {
log.debug("U2FService is registered");
log.debug("U2FService is registered.");
}
} catch (Exception e) {
log.error("Error registering U2FService ", e);
log.error("Error registering U2FService.", e);
}

try {
bundleContext.registerService(UserStoreConfigListener.class.getName(), new UserStoreConfigListenerImpl(), null);
} catch (Exception e){
log.error("Error registering UserStoreConfigListener ", e);
bundleContext.registerService(
UserStoreConfigListener.class.getName(), new UserStoreConfigListenerImpl(), null);
} catch (Exception e) {
log.error("Error registering UserStoreConfigListener.", e);
}

dataHolder.setBundleContext(bundleContext);
}

@Deactivate
protected void deactivate(ComponentContext context) {

if (log.isDebugEnabled()) {
log.debug("Deactivating FIDOAuthenticator bundle...");
}

FIDOAuthenticatorServiceDataHolder.getInstance().setBundleContext(null);
}

public static RealmService getRealmService() {

return FIDOAuthenticatorServiceDataHolder.getInstance().getRealmService();
}

@Reference(
name = "realm.service",
service = RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRealmService"
)
protected void setRealmService(RealmService realmService) {

if (log.isDebugEnabled()) {
log.debug("Setting the Realm Service");
log.debug("Setting the Realm Service in FIDO authenticator bundle.");
}
FIDOAuthenticatorServiceComponent.realmService = realmService;
FIDOAuthenticatorServiceDataHolder.getInstance().setRealmService(realmService);
}

protected void unsetRealmService(RealmService realmService) {

if (log.isDebugEnabled()) {
log.debug("UnSetting the Realm Service");
log.debug("UnSetting the Realm Service in FIDO authenticator bundle.");
}
FIDOAuthenticatorServiceComponent.realmService = null;
FIDOAuthenticatorServiceDataHolder.getInstance().setRealmService(null);
}
}
}
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.com).
*
* 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.identity.application.authenticator.fido.internal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.wso2.carbon.user.core.service.RealmService;

/**
* FIDO Authenticator data holder.
*/
public class FIDOAuthenticatorServiceDataHolder {

private static final Log log = LogFactory.getLog(FIDOAuthenticatorServiceDataHolder.class);
private static final FIDOAuthenticatorServiceDataHolder instance = new FIDOAuthenticatorServiceDataHolder();
private BundleContext bundleContext = null;
private RealmService realmService = null;

private FIDOAuthenticatorServiceDataHolder() {
}

public static FIDOAuthenticatorServiceDataHolder getInstance() {

return instance;
}

public void setRealmService(RealmService realmService) {

this.realmService = realmService;
}

public RealmService getRealmService() {

return realmService;
}

public void setBundleContext(BundleContext bundleContext) {

this.bundleContext = bundleContext;
}
}
Expand Up @@ -24,7 +24,7 @@
<groupId>org.wso2.carbon.identity.local.auth.fido</groupId>
<artifactId>identity-application-auth-fido</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>5.3.21-SNAPSHOT</version>
<version>5.3.23-SNAPSHOT</version>
</parent>

<packaging>war</packaging>
Expand Down
Expand Up @@ -23,7 +23,7 @@
<groupId>org.wso2.carbon.identity.local.auth.fido</groupId>
<artifactId>identity-application-auth-fido</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>5.3.21-SNAPSHOT</version>
<version>5.3.23-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -75,6 +75,18 @@
<groupId>org.wso2.orbit.yubico.webauthn</groupId>
<artifactId>yubico-webauthn</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.webauthn4j</groupId>
<artifactId>webauthn4j</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.configuration.mgt.core</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -126,7 +138,9 @@
com.fasterxml.jackson.databind.*; version="${fasterxml.jackson.version}",
com.fasterxml.jackson.annotation.*; version="${fasterxml.jackson.version}",
com.fasterxml.jackson.datatype.jdk8.*; version="${fasterxml.jackson.version}",
com.fasterxml.jackson.dataformat.cbor.*; version="${fasterxml.jackson.version}"
com.fasterxml.jackson.dataformat.cbor.*; version="${fasterxml.jackson.version}",
com.webauthn4j.*; version="${orbit.webauthn4j.version}",
org.wso2.carbon.identity.configuration.mgt.core.*
</Import-Package>
<Export-Package>
org.wso2.carbon.identity.application.authenticator.fido2.*;
Expand Down

0 comments on commit 1b8c506

Please sign in to comment.