mat-ale commented on a change in pull request #178:
URL: https://github.com/apache/syncope/pull/178#discussion_r418057236



##########
File path: 
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SAML2IdPMetadataBinderImpl.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.syncope.core.provisioning.java.data;
+
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.apache.syncope.common.lib.to.SAML2IdPMetadataTO;
+import org.apache.syncope.core.persistence.api.entity.auth.SAML2IdPMetadata;
+import org.apache.syncope.core.provisioning.api.data.SAML2IdPMetadataBinder;
+
+@Component
+public class SAML2IdPMetadataBinderImpl implements SAML2IdPMetadataBinder {
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    private SAML2IdPMetadata getSAML2IdPMetadata(
+            final SAML2IdPMetadata saml2IdPMetadata,
+            final SAML2IdPMetadataTO saml2IdPMetadataTO) {
+
+        SAML2IdPMetadata result = saml2IdPMetadata;
+
+        if (result == null) {
+            result = entityFactory.newEntity(SAML2IdPMetadata.class);
+        }
+
+        SAML2IdPMetadata saml2IdPMetadataResult = 
SAML2IdPMetadata.class.cast(result);
+        SAML2IdPMetadataTO saml2IdPMetadataTOElem = 
SAML2IdPMetadataTO.class.cast(saml2IdPMetadataTO);
+
+        
saml2IdPMetadataResult.setEncryptionCertificate(saml2IdPMetadataTOElem.getEncryptionCertificate());
+        
saml2IdPMetadataResult.setEncryptionKey(saml2IdPMetadataTOElem.getEncryptionKey());
+        
saml2IdPMetadataResult.setMetadata(saml2IdPMetadataTOElem.getMetadata());
+        
saml2IdPMetadataResult.setSigningCertificate(saml2IdPMetadataTOElem.getSigningCertificate());
+        
saml2IdPMetadataResult.setSigningKey(saml2IdPMetadataTOElem.getSigningKey());
+        
saml2IdPMetadataResult.setAppliesTo(saml2IdPMetadataTOElem.getAppliesTo());
+
+        return result;
+    }
+
+    @Override
+    public SAML2IdPMetadata create(final SAML2IdPMetadataTO 
saml2IdPMetadataTO) {
+        return getSAML2IdPMetadata(null, saml2IdPMetadataTO);

Review comment:
       I would also add that the `#update` could be called instead of 
`#getSAML2IdPMetadata` there! WDYT?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to