[spring-extensions] branch master updated: IDP-1429 Move PatternFactoryBean to SpringSupport
Rod Widdowson
rdw at steadingsoftware.com
Thu Apr 11 09:56:39 EDT 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository spring-extensions.
View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=e68e1f5ceaee3a77ce745fd206b615eb78e51ef1
The following commit(s) were added to refs/heads/master by this push:
new e68e1f5 IDP-1429 Move PatternFactoryBean to SpringSupport
e68e1f5 is described below
commit e68e1f5ceaee3a77ce745fd206b615eb78e51ef1
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Apr 11 14:54:49 2019 +0100
IDP-1429 Move PatternFactoryBean to SpringSupport
https://issues.shibboleth.net/jira/browse/IDP-1429
Moved from idp-attribute-resolver-spring, this module
can now be used in other custom syntax parsing modules.
---
.../ext/spring/factory/PatternFactoryBean.java | 90 ++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/src/main/java/net/shibboleth/ext/spring/factory/PatternFactoryBean.java b/src/main/java/net/shibboleth/ext/spring/factory/PatternFactoryBean.java
new file mode 100644
index 0000000..9bbbab6
--- /dev/null
+++ b/src/main/java/net/shibboleth/ext/spring/factory/PatternFactoryBean.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.ext.spring.factory;
+
+import java.util.regex.Pattern;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+/**
+ * Factory bean for {@link Pattern}. Allows us to inject property based case sensitivity.
+ */
+public class PatternFactoryBean extends AbstractComponentAwareFactoryBean<Pattern> {
+
+ /** Whether the we are case sensitive or not. */
+ @Nullable private Boolean caseSensitive;
+
+ /** The regular expressions. */
+ @Nullable private String regexp;
+
+ /** {@inheritDoc} */
+ @Override public Class<?> getObjectType() {
+ return Pattern.class;
+ }
+
+ /**
+ * set case sensitivity.
+ *
+ * @return Returns the caseSensitive.
+ */
+ public Boolean getCaseSensitive() {
+ return caseSensitive;
+ }
+
+ /**
+ * get case sensitivity.
+ *
+ * @param what The value to set.
+ */
+ public void setCaseSensitive(@Nullable final Boolean what) {
+ caseSensitive = what;
+ }
+
+ /**
+ * Get the regular expression.
+ *
+ * @return Returns the regexp.
+ */
+ @Nullable public String getRegexp() {
+ return regexp;
+ }
+
+ /**
+ * Set the regular expression.
+ *
+ * @param what what to set.
+ */
+ public void setRegexp(@Nonnull final String what) {
+ regexp = what;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Pattern doCreateInstance() throws Exception {
+ Constraint.isNotNull(regexp, "Regular expression cannot be null");
+
+ if (null == getCaseSensitive() || getCaseSensitive()) {
+ return Pattern.compile(regexp, 0);
+ } else {
+ return Pattern.compile(regexp, Pattern.CASE_INSENSITIVE);
+ }
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list