diff --git a/plugins/pom.xml b/plugins/pom.xml index b3890c07c85..0b1b62d9ac6 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -72,6 +72,7 @@ user-authenticators/ldap user-authenticators/md5 user-authenticators/plain-text + user-authenticators/saml2 user-authenticators/sha256salted network-elements/dns-notifier storage/image/s3 diff --git a/plugins/user-authenticators/saml2/findbugsExcludeFilter.xml b/plugins/user-authenticators/saml2/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/user-authenticators/saml2/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/user-authenticators/saml2/pom.xml b/plugins/user-authenticators/saml2/pom.xml new file mode 100644 index 00000000000..bfe5eb7e387 --- /dev/null +++ b/plugins/user-authenticators/saml2/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + cloud-plugin-user-authenticator-saml2 + Apache CloudStack Plugin - User Authenticator SAML2 + + org.apache.cloudstack + cloudstack-plugins + 4.5.0-SNAPSHOT + ../../pom.xml + + diff --git a/plugins/user-authenticators/saml2/resources/META-INF/cloudstack/saml2/module.properties b/plugins/user-authenticators/saml2/resources/META-INF/cloudstack/saml2/module.properties new file mode 100644 index 00000000000..0da9d5b2d9c --- /dev/null +++ b/plugins/user-authenticators/saml2/resources/META-INF/cloudstack/saml2/module.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF 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. +name=saml2 +parent=api diff --git a/plugins/user-authenticators/saml2/resources/META-INF/cloudstack/saml2/spring-saml2-context.xml b/plugins/user-authenticators/saml2/resources/META-INF/cloudstack/saml2/spring-saml2-context.xml new file mode 100644 index 00000000000..f244292c3b6 --- /dev/null +++ b/plugins/user-authenticators/saml2/resources/META-INF/cloudstack/saml2/spring-saml2-context.xml @@ -0,0 +1,32 @@ + + + + + + + + diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/SAML2UserAuthenticator.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/SAML2UserAuthenticator.java new file mode 100644 index 00000000000..4e1e795b960 --- /dev/null +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/SAML2UserAuthenticator.java @@ -0,0 +1,46 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF 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 org.apache.cloudstack; + +import com.cloud.server.auth.DefaultUserAuthenticator; +import com.cloud.server.auth.UserAuthenticator; +import com.cloud.utils.Pair; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import java.util.Map; + +@Local(value = {UserAuthenticator.class}) +public class SAML2UserAuthenticator extends DefaultUserAuthenticator { + public static final Logger s_logger = Logger.getLogger(SAML2UserAuthenticator.class); + + @Override + public Pair authenticate(String username, String password, Long domainId, Map requestParameters) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Trying SAML2 auth for user: " + username); + } + + // TODO: implement core logic, HTTP GET redirections etc. + + return new Pair(true, null); + } + + @Override + public String encode(final String password) { + // TODO: Complete method + StringBuilder sb = new StringBuilder(32); + return sb.toString(); + } +} diff --git a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/SAML2UserAuthenticatorTest.java b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/SAML2UserAuthenticatorTest.java new file mode 100644 index 00000000000..8298c6c13dd --- /dev/null +++ b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/SAML2UserAuthenticatorTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 org.apache.cloudstack; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class SAML2UserAuthenticatorTest { + + @Test + public void encode() { + + } + + @Test + public void authenticate() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + + } +}