Skip to content

Commit

Permalink
feature: introduce base classes for matchTerm feature on certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo.andreussi committed Jul 10, 2024
1 parent 9980735 commit ca60dcb
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* @since 1.1.0
*/
public class CertificateInfoAttributes extends KapuaNamedEntityAttributes {

public static final String CA_ID = "caId";

public static final String FORWARDABLE = "forwardable";
Expand All @@ -34,4 +33,12 @@ public class CertificateInfoAttributes extends KapuaNamedEntityAttributes {

public static final String USAGE_NAME = USAGE + ".name";

public static final String SERIAL = "serial";

public static final String ALGORITHM = "algorithm";

public static final String SUBJECT = "subject";



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 2018, 2022 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.service.certificate.info;

import org.eclipse.kapua.model.query.predicate.MatchPredicate;

public interface CertificateInfoMatchPredicate<T> extends MatchPredicate<T> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public interface CertificateInfoQuery extends KapuaForwardableEntityQuery {
* @since 1.1.0
*/
void setIncludeInherited(Boolean includeInherited);

/**
* Instantiates a new {@link CertificateInfoMatchPredicate}.
*
* @param matchTerm The term to use to match.
* @param <T> The type of the term
* @return The newly instantiated {@link CertificateInfoMatchPredicate}.
* @since 2.1.0
*/
<T> CertificateInfoMatchPredicate<T> matchPredicate(T matchTerm);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2018, 2022 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.service.certificate.info.internal;

import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate;
import org.eclipse.kapua.service.certificate.info.CertificateInfoAttributes;
import org.eclipse.kapua.service.certificate.info.CertificateInfoMatchPredicate;

import java.util.Arrays;

public class CertificateInfoMatchPredicateImpl<T> extends AbstractMatchPredicate<T> implements CertificateInfoMatchPredicate<T> {

/**
* Constructor.
*
* @param matchTerm
* @since 2.1.0
*/
public CertificateInfoMatchPredicateImpl(T matchTerm) {
this.attributeNames = Arrays.asList(

Check warning on line 30 in service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java

View check run for this annotation

Codecov / codecov/patch

service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java#L29-L30

Added lines #L29 - L30 were not covered by tests
CertificateInfoAttributes.NAME,
CertificateInfoAttributes.SERIAL,
CertificateInfoAttributes.SIGNATURE,
CertificateInfoAttributes.ALGORITHM,
CertificateInfoAttributes.SUBJECT
);
this.matchTerm = matchTerm;
}

Check warning on line 38 in service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java

View check run for this annotation

Codecov / codecov/patch

service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java#L37-L38

Added lines #L37 - L38 were not covered by tests

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.certificate.info.CertificateInfoMatchPredicate;
import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery;

/**
Expand Down Expand Up @@ -54,4 +55,9 @@ public Boolean getIncludeInherited() {
public void setIncludeInherited(Boolean includeInherited) {
this.includeInherited = includeInherited;
}

@Override
public <T> CertificateInfoMatchPredicate<T> matchPredicate(T matchTerm) {
return new CertificateInfoMatchPredicateImpl<>(matchTerm);

Check warning on line 61 in service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java

View check run for this annotation

Codecov / codecov/patch

service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java#L61

Added line #L61 was not covered by tests
}
}

0 comments on commit ca60dcb

Please sign in to comment.