Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing a SQL backend for the Secret service and end to end work…
…flow for scp transfers
- Loading branch information
1 parent
c4417d1
commit aff6236
Showing
19 changed files
with
450 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
.../secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.airavata.mft.secret.server; | ||
|
||
import org.apache.airavata.mft.secret.server.backend.SecretBackend; | ||
import org.apache.airavata.mft.secret.server.backend.sql.SQLSecretBackend; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class AppConfig { | ||
|
||
@Bean | ||
SecretBackend secretBackend() {return new SQLSecretBackend();} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ice/server/src/main/java/org/apache/airavata/mft/secret/server/backend/SecretBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.airavata.mft.secret.server.backend; | ||
|
||
import org.apache.airavata.mft.secret.service.*; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SecretBackend { | ||
public Optional<SCPSecret> getSCPSecret(SCPSecretGetRequest request); | ||
public SCPSecret createSCPSecret(SCPSecretCreateRequest request); | ||
public boolean updateSCPSecret(SCPSecretUpdateRequest request); | ||
public boolean deleteSCPSecret(SCPSecretDeleteRequest request); | ||
} |
59 changes: 59 additions & 0 deletions
59
...ver/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/SQLSecretBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.airavata.mft.secret.server.backend.sql; | ||
|
||
import org.apache.airavata.mft.secret.server.backend.SecretBackend; | ||
import org.apache.airavata.mft.secret.server.backend.sql.entity.SCPSecretEntity; | ||
import org.apache.airavata.mft.secret.server.backend.sql.repository.SecretRepository; | ||
import org.apache.airavata.mft.secret.service.*; | ||
import org.dozer.DozerBeanMapper; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Optional; | ||
|
||
public class SQLSecretBackend implements SecretBackend { | ||
|
||
@Autowired | ||
private SecretRepository secretRepository; | ||
|
||
private DozerBeanMapper mapper = new DozerBeanMapper(); | ||
|
||
@Override | ||
public Optional<SCPSecret> getSCPSecret(SCPSecretGetRequest request) { | ||
Optional<SCPSecretEntity> secretEty = secretRepository.findBySecretId(request.getSecretId()); | ||
return secretEty.map(scpSecretEntity -> mapper.map(scpSecretEntity, SCPSecret.newBuilder().getClass()).build()); | ||
} | ||
|
||
@Override | ||
public SCPSecret createSCPSecret(SCPSecretCreateRequest request) { | ||
SCPSecretEntity savedEntity = secretRepository.save(mapper.map(request, SCPSecretEntity.class)); | ||
return mapper.map(savedEntity, SCPSecret.newBuilder().getClass()).build(); | ||
} | ||
|
||
@Override | ||
public boolean updateSCPSecret(SCPSecretUpdateRequest request) { | ||
secretRepository.save(mapper.map(request, SCPSecretEntity.class)); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean deleteSCPSecret(SCPSecretDeleteRequest request) { | ||
secretRepository.deleteById(request.getSecretId()); | ||
return true; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...c/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/SCPSecretEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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.airavata.mft.secret.server.backend.sql.entity; | ||
|
||
import org.hibernate.annotations.GenericGenerator; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
public class SCPSecretEntity { | ||
|
||
@Id | ||
@Column(name = "SECRET_ID") | ||
@GeneratedValue(generator = "uuid") | ||
@GenericGenerator(name = "uuid", strategy = "uuid2") | ||
private String secretId; | ||
|
||
@Column(name = "PRIVATE_KEY") | ||
private String privateKey; | ||
|
||
@Column(name = "PUBLIC_KEY") | ||
private String publicKey; | ||
|
||
@Column(name = "PASSPHRASE") | ||
private String passphrase; | ||
|
||
@Column(name = "USER_NAME") | ||
private String user; | ||
|
||
public String getSecretId() { | ||
return secretId; | ||
} | ||
|
||
public void setSecretId(String secretId) { | ||
this.secretId = secretId; | ||
} | ||
|
||
public String getPrivateKey() { | ||
return privateKey; | ||
} | ||
|
||
public void setPrivateKey(String privateKey) { | ||
this.privateKey = privateKey; | ||
} | ||
|
||
public String getPublicKey() { | ||
return publicKey; | ||
} | ||
|
||
public void setPublicKey(String publicKey) { | ||
this.publicKey = publicKey; | ||
} | ||
|
||
public String getPassphrase() { | ||
return passphrase; | ||
} | ||
|
||
public void setPassphrase(String passphrase) { | ||
this.passphrase = passphrase; | ||
} | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(String user) { | ||
this.user = user; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...n/java/org/apache/airavata/mft/secret/server/backend/sql/repository/SecretRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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.airavata.mft.secret.server.backend.sql.repository; | ||
|
||
import org.apache.airavata.mft.secret.server.backend.sql.entity.SCPSecretEntity; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SecretRepository extends CrudRepository<SCPSecretEntity, String> { | ||
Optional<SCPSecretEntity> findBySecretId(String resourceId); | ||
} |
Oops, something went wrong.