[spring-extensions] branch main updated: IDP-1819 ldap auth response handlers use period.
Daniel Fisher
dfisher at vt.edu
Wed Sep 1 04:04:03 UTC 2021
This is an automated email from the git hooks/post-receive script.
dfisher pushed a commit to branch main
in repository spring-extensions.
View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=2e564498d46861a12227f92f92bce9cc621c400c
The following commit(s) were added to refs/heads/main by this push:
new 2e56449 IDP-1819 ldap auth response handlers use period.
2e56449 is described below
commit 2e564498d46861a12227f92f92bce9cc621c400c
Author: Daniel Fisher <dfisher at vt.edu>
AuthorDate: Tue Aug 31 23:46:29 2021 -0400
IDP-1819 ldap auth response handlers use period.
Add a string to period converter.
Implementation follows the same strategy as StringToDurationConverter which supports an integer format for days.
---
.../ext/spring/config/StringToPeriodConverter.java | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/main/java/net/shibboleth/ext/spring/config/StringToPeriodConverter.java b/src/main/java/net/shibboleth/ext/spring/config/StringToPeriodConverter.java
new file mode 100644
index 0000000..e7a77a6
--- /dev/null
+++ b/src/main/java/net/shibboleth/ext/spring/config/StringToPeriodConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.config;
+
+import java.time.Period;
+
+import org.springframework.core.convert.converter.Converter;
+
+/**
+ * Allows setting of Period-valued properties using lexical string form.
+ */
+public class StringToPeriodConverter implements Converter<String,Period> {
+
+ /** {@inheritDoc} */
+ public Period convert(final String source) {
+ if (source.startsWith("P") || source.startsWith("-P")) {
+ return Period.parse(source);
+ }
+
+ // Treat as days.
+ return Period.ofDays(Integer.valueOf(source));
+ }
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list