[java-identity-provider] branch main updated: Add TOTPPrincipal to core for shared use.
Scott Cantor
cantor.2 at osu.edu
Thu Aug 27 18:35:20 UTC 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=d68f3b63a20230fc3c48d4f417b82f411d85a211
The following commit(s) were added to refs/heads/main by this push:
new d68f3b63a Add TOTPPrincipal to core for shared use.
d68f3b63a is described below
commit d68f3b63a20230fc3c48d4f417b82f411d85a211
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Aug 27 14:35:13 2020 -0400
Add TOTPPrincipal to core for shared use.
---
.../idp/authn/principal/TOTPPrincipal.java | 92 ++++++++++++++++++++++
.../shibboleth/idp/conf/general-authn-system.xml | 8 ++
2 files changed, 100 insertions(+)
diff --git a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/principal/TOTPPrincipal.java b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/principal/TOTPPrincipal.java
new file mode 100644
index 000000000..07d3e661f
--- /dev/null
+++ b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/principal/TOTPPrincipal.java
@@ -0,0 +1,92 @@
+/*
+ * 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.idp.authn.principal;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.utilities.java.support.annotation.ParameterName;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Principal based on a TOTP authentication.
+ *
+ * @since 4.1.0
+ */
+public class TOTPPrincipal implements CloneablePrincipal {
+
+ /** The username. */
+ @Nonnull @NotEmpty private String username;
+
+ /**
+ * Constructor.
+ *
+ * @param name the username
+ */
+ public TOTPPrincipal(@Nonnull @NotEmpty @ParameterName(name="name") final String name) {
+ username = Constraint.isNotNull(StringSupport.trimOrNull(name), "Username cannot be null or empty");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull @NotEmpty public String getName() {
+ return username;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ return username.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean equals(final Object other) {
+ if (other == null) {
+ return false;
+ }
+
+ if (this == other) {
+ return true;
+ }
+
+ if (other instanceof TOTPPrincipal) {
+ return username.equals(((TOTPPrincipal) other).getName());
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("username", username).toString();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public TOTPPrincipal clone() throws CloneNotSupportedException {
+ final TOTPPrincipal copy = (TOTPPrincipal) super.clone();
+ copy.username = username;
+ return copy;
+ }
+
+}
\ No newline at end of file
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/general-authn-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/general-authn-system.xml
index d1e8a173f..042a20d07 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/general-authn-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/general-authn-system.xml
@@ -364,6 +364,14 @@
</constructor-arg>
</bean>
+ <bean p:id="totp" class="net.shibboleth.idp.authn.principal.GenericPrincipalService"
+ c:claz="net.shibboleth.idp.authn.principal.TOTPPrincipal">
+ <constructor-arg name="serializer">
+ <bean class="net.shibboleth.idp.authn.principal.SimplePrincipalSerializer"
+ c:claz="net.shibboleth.idp.authn.principal.TOTPPrincipal" c:name="TOTP" />
+ </constructor-arg>
+ </bean>
+
<bean p:id="ldap" class="net.shibboleth.idp.authn.principal.GenericPrincipalService"
c:claz="org.ldaptive.jaas.LdapPrincipal">
<constructor-arg name="serializer">
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list