Skip to content

Consistently NonNull annotation #16587

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,10 +20,9 @@
import java.util.Arrays;
import java.util.function.Function;

import reactor.util.annotation.NonNull;

import org.springframework.context.ApplicationContext;
import org.springframework.expression.Expression;
import org.springframework.lang.NonNull;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AnnotationTemplateExpressionDefaults;
import org.springframework.security.core.annotation.SecurityAnnotationScanner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,6 @@
import java.util.Set;
import java.util.function.Consumer;

import javax.annotation.Nonnull;
import javax.xml.namespace.QName;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -67,6 +66,7 @@

import org.springframework.core.convert.converter.Converter;
import org.springframework.core.log.LogMessage;
import org.springframework.lang.NonNull;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -565,13 +565,13 @@ static class SAML20AssertionValidators {
conditions.add(new AudienceRestrictionConditionValidator());
conditions.add(new DelegationRestrictionConditionValidator());
conditions.add(new ConditionValidator() {
@Nonnull
@NonNull
@Override
public QName getServicedCondition() {
return OneTimeUse.DEFAULT_ELEMENT_NAME;
}

@Nonnull
@NonNull
@Override
public ValidationResult validate(Condition condition, Assertion assertion, ValidationContext context) {
// applications should validate their own OneTimeUse conditions
Expand All @@ -580,16 +580,16 @@ public ValidationResult validate(Condition condition, Assertion assertion, Valid
});
conditions.add(new ProxyRestrictionConditionValidator());
subjects.add(new BearerSubjectConfirmationValidator() {
@Nonnull
protected ValidationResult validateAddress(@Nonnull SubjectConfirmation confirmation,
@Nonnull Assertion assertion, @Nonnull ValidationContext context, boolean required)
@NonNull
protected ValidationResult validateAddress(@NonNull SubjectConfirmation confirmation,
@NonNull Assertion assertion, @NonNull ValidationContext context, boolean required)
throws AssertionValidationException {
return ValidationResult.VALID;
}

@Nonnull
protected ValidationResult validateAddress(@Nonnull SubjectConfirmationData confirmationData,
@Nonnull Assertion assertion, @Nonnull ValidationContext context, boolean required)
@NonNull
protected ValidationResult validateAddress(@NonNull SubjectConfirmationData confirmationData,
@NonNull Assertion assertion, @NonNull ValidationContext context, boolean required)
throws AssertionValidationException {
// applications should validate their own addresses - gh-7514
return ValidationResult.VALID;
Expand All @@ -599,7 +599,7 @@ protected ValidationResult validateAddress(@Nonnull SubjectConfirmationData conf

static final SAML20AssertionValidator attributeValidator = new SAML20AssertionValidator(conditions, subjects,
statements, null, null, null) {
@Nonnull
@NonNull
@Override
protected ValidationResult validateSignature(Assertion token, ValidationContext context) {
return ValidationResult.VALID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,8 +26,6 @@
import java.util.Iterator;
import java.util.function.Consumer;

import javax.annotation.Nonnull;

import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
Expand Down Expand Up @@ -265,7 +263,7 @@ public File getFile() throws IOException {
return this.resource.getFile();
}

@Nonnull
@NonNull
@Override
public InputStream getInputStream() throws IOException {
return this.resource.getInputStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.QName;

Expand All @@ -40,6 +39,7 @@
import org.opensaml.saml.saml2.core.AttributeValue;
import org.w3c.dom.Element;

import org.springframework.lang.NonNull;
import org.springframework.security.saml2.core.OpenSamlInitializationService;

public final class TestCustomOpenSaml4Objects {
Expand Down Expand Up @@ -103,7 +103,7 @@ public interface CustomOpenSamlObject extends ElementExtensibleXMLObject {

public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implements CustomOpenSamlObject {

@Nonnull
@NonNull
private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;

/**
Expand All @@ -113,22 +113,22 @@ public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implement
* represents
* @param namespacePrefix the prefix for the given namespace
*/
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @Nonnull String elementLocalName,
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @NonNull String elementLocalName,
@Nullable String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
super.getNamespaceManager().registerNamespaceDeclaration(new Namespace(CUSTOM_NS, TYPE_CUSTOM_PREFIX));
this.unknownXMLObjects = new IndexedXMLObjectChildrenList<>(this);
}

@Nonnull
@NonNull
@Override
public List<XMLObject> getUnknownXMLObjects() {
return this.unknownXMLObjects;
}

@Nonnull
@NonNull
@Override
public List<XMLObject> getUnknownXMLObjects(@Nonnull QName typeOrName) {
public List<XMLObject> getUnknownXMLObjects(@NonNull QName typeOrName) {
return (List<XMLObject>) this.unknownXMLObjects.subList(typeOrName);
}

Expand Down Expand Up @@ -162,9 +162,9 @@ public String getCity() {

public static class CustomSamlObjectBuilder extends AbstractXMLObjectBuilder<CustomOpenSamlObject> {

@Nonnull
@NonNull
@Override
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @Nonnull String localName,
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @NonNull String localName,
@Nullable String namespacePrefix) {
return new CustomOpenSamlObjectImpl(namespaceURI, localName, namespacePrefix);
}
Expand All @@ -178,7 +178,7 @@ public CustomSamlObjectMarshaller() {
}

@Override
protected void marshallElementContent(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) {
protected void marshallElementContent(@NonNull XMLObject xmlObject, @NonNull Element domElement) {
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) xmlObject;

for (XMLObject object : customSamlObject.getOrderedChildren()) {
Expand All @@ -195,15 +195,15 @@ public CustomSamlObjectUnmarshaller() {
}

@Override
protected void processChildElement(@Nonnull XMLObject parentXMLObject, @Nonnull XMLObject childXMLObject)
protected void processChildElement(@NonNull XMLObject parentXMLObject, @NonNull XMLObject childXMLObject)
throws UnmarshallingException {
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) parentXMLObject;
customSamlObject.getUnknownXMLObjects().add(childXMLObject);
}

@Nonnull
@NonNull
@Override
protected XMLObject buildXMLObject(@Nonnull Element domElement) {
protected XMLObject buildXMLObject(@NonNull Element domElement) {
return new CustomOpenSamlObjectImpl(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
CustomOpenSamlObject.TYPE_CUSTOM_PREFIX);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,8 +26,6 @@
import java.util.Iterator;
import java.util.function.Consumer;

import javax.annotation.Nonnull;

import net.shibboleth.shared.resolver.CriteriaSet;
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
Expand Down Expand Up @@ -266,7 +264,7 @@ public File getFile() throws IOException {
return this.resource.getFile();
}

@Nonnull
@NonNull
@Override
public InputStream getInputStream() throws IOException {
return this.resource.getInputStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.QName;

Expand All @@ -40,6 +39,7 @@
import org.opensaml.saml.saml2.core.AttributeValue;
import org.w3c.dom.Element;

import org.springframework.lang.NonNull;
import org.springframework.security.saml2.core.OpenSamlInitializationService;

public final class TestCustomOpenSaml5Objects {
Expand Down Expand Up @@ -103,7 +103,7 @@ public interface CustomOpenSamlObject extends ElementExtensibleXMLObject {

public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implements CustomOpenSamlObject {

@Nonnull
@NonNull
private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;

/**
Expand All @@ -113,22 +113,22 @@ public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implement
* represents
* @param namespacePrefix the prefix for the given namespace
*/
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @Nonnull String elementLocalName,
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @NonNull String elementLocalName,
@Nullable String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
super.getNamespaceManager().registerNamespaceDeclaration(new Namespace(CUSTOM_NS, TYPE_CUSTOM_PREFIX));
this.unknownXMLObjects = new IndexedXMLObjectChildrenList<>(this);
}

@Nonnull
@NonNull
@Override
public List<XMLObject> getUnknownXMLObjects() {
return this.unknownXMLObjects;
}

@Nonnull
@NonNull
@Override
public List<XMLObject> getUnknownXMLObjects(@Nonnull QName typeOrName) {
public List<XMLObject> getUnknownXMLObjects(@NonNull QName typeOrName) {
return (List<XMLObject>) this.unknownXMLObjects.subList(typeOrName);
}

Expand Down Expand Up @@ -162,9 +162,9 @@ public String getCity() {

public static class CustomSamlObjectBuilder extends AbstractXMLObjectBuilder<CustomOpenSamlObject> {

@Nonnull
@NonNull
@Override
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @Nonnull String localName,
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @NonNull String localName,
@Nullable String namespacePrefix) {
return new CustomOpenSamlObjectImpl(namespaceURI, localName, namespacePrefix);
}
Expand All @@ -178,7 +178,7 @@ public CustomSamlObjectMarshaller() {
}

@Override
protected void marshallElementContent(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) {
protected void marshallElementContent(@NonNull XMLObject xmlObject, @NonNull Element domElement) {
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) xmlObject;

for (XMLObject object : customSamlObject.getOrderedChildren()) {
Expand All @@ -195,15 +195,15 @@ public CustomSamlObjectUnmarshaller() {
}

@Override
protected void processChildElement(@Nonnull XMLObject parentXMLObject, @Nonnull XMLObject childXMLObject)
protected void processChildElement(@NonNull XMLObject parentXMLObject, @NonNull XMLObject childXMLObject)
throws UnmarshallingException {
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) parentXMLObject;
customSamlObject.getUnknownXMLObjects().add(childXMLObject);
}

@Nonnull
@NonNull
@Override
protected XMLObject buildXMLObject(@Nonnull Element domElement) {
protected XMLObject buildXMLObject(@NonNull Element domElement) {
return new CustomOpenSamlObjectImpl(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
CustomOpenSamlObject.TYPE_CUSTOM_PREFIX);
}
Expand Down