Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-4083: Do not use priority annotations for classes without public API #4195

Merged
merged 3 commits into from Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -58,7 +58,6 @@
import org.eclipse.microprofile.metrics.annotation.Metric;

@Dependent
@Priority(Interceptor.Priority.LIBRARY_BEFORE + 1)
public class MetricProducer {

@Inject
Expand Down
Expand Up @@ -43,7 +43,6 @@

import fish.payara.security.identitystores.YubikeyIdentityStore;
import fish.payara.security.annotations.YubikeyIdentityStoreDefinition;
import fish.payara.security.identitystores.YubicoAPIImpl;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -84,8 +83,6 @@ public void register(@Observes BeforeBeanDiscovery beforeBean, BeanManager beanM
MODULE_PREFIX + TwoIdentityStoreAuthenticationMechanism.class.getName());
beforeBean.addAnnotatedType(beanManager.createAnnotatedType(TwoIdentityStoreAuthenticationMechanismState.class),
MODULE_PREFIX + TwoIdentityStoreAuthenticationMechanismState.class.getName());
beforeBean.addAnnotatedType(beanManager.createAnnotatedType(YubicoAPIImpl.class),
MODULE_PREFIX + YubicoAPIImpl.class.getName());
beforeBean.addAnnotatedType(beanManager.createAnnotatedType(YubikeyIdentityStore.class),
MODULE_PREFIX + YubikeyIdentityStore.class.getName());

Expand Down
Expand Up @@ -41,17 +41,40 @@
package fish.payara.security.identitystores;

import com.yubico.client.v2.VerificationResponse;
import com.yubico.client.v2.YubicoClient;
import com.yubico.client.v2.exceptions.YubicoValidationFailure;
import com.yubico.client.v2.exceptions.YubicoVerificationException;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author Mark Wareham
*/
public interface YubicoAPI {

public void init(int apiClientID, String apiClientKey);
public VerificationResponse verify(String otp) throws YubicoVerificationException, YubicoValidationFailure;
public Integer getClientId();
public String[] getWsapiUrls();
class YubicoAPI {
private static final Logger LOG = Logger.getLogger(YubicoAPI.class.getName());

private YubicoClient yubicoClient;

YubicoAPI(int apiClientID, String apiClientKey) {
if(apiClientID==0){
LOG.log(Level.WARNING, "A Yubico clientID has not been set");
}else{
LOG.log(Level.INFO, "Set up YubicoClient with clientID of {0}", apiClientID);
}
yubicoClient = YubicoClient.getClient(apiClientID, apiClientKey);
}

public VerificationResponse verify(String otp) throws YubicoVerificationException, YubicoValidationFailure {
return yubicoClient.verify(otp);
}

public Integer getClientId() {
return yubicoClient.getClientId();
}

public String[] getWsapiUrls() {
return yubicoClient.getWsapiUrls();
}
}

This file was deleted.

Expand Up @@ -76,21 +76,20 @@ public class YubikeyIdentityStore implements IdentityStore {

private static final Logger LOG = Logger.getLogger(YubikeyIdentityStore.class.getName());

@Inject
private YubicoAPI yubicoAPI;

private RequestTracingService requestTracing;
private int priority; //priority is handled as immediate, not deferred

public YubikeyIdentityStore init (YubikeyIdentityStoreDefinition definition){
public YubikeyIdentityStore init(YubikeyIdentityStoreDefinition definition) {
try {
this.requestTracing = Globals.get(RequestTracingService.class);
} catch (NullPointerException e) {
LOG.log(Level.INFO, "Error retrieving Request Tracing service "
+ "during initialisation of Yubikey Identity Store - NullPointerException");
}
priority = definition.priority();
yubicoAPI.init(definition.yubikeyAPIClientID(), definition.yubikeyAPIKey());
yubicoAPI = new YubicoAPI(definition.yubikeyAPIClientID(), definition.yubikeyAPIKey());
return this;
}

Expand Down