This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
565 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2019 Nike, Inc. | ||
* | ||
* Licensed 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 com.nike.cerberus.domain; | ||
|
||
/** | ||
* Enum used to distinguish between objects, files, and other types of secrets in the database. | ||
*/ | ||
public enum Source { | ||
SECURE_DATA, | ||
SECURE_DATA_VERSION | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/nike/cerberus/jobs/DataKeyRotationJob.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,52 @@ | ||
/* | ||
* Copyright (c) 2017 Nike, Inc. | ||
* | ||
* Licensed 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 com.nike.cerberus.jobs; | ||
|
||
|
||
import com.nike.cerberus.service.SecureDataService; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
public class DataKeyRotationJob extends LockingJob { | ||
|
||
private final SecureDataService secureDataService; | ||
private final int numberOfDataKeyToRotatePerJobRun; | ||
private final int dataKeyRotationPauseTimeInMillis; | ||
private final int dataKeyRotationIntervalInDays; | ||
|
||
@Inject | ||
public DataKeyRotationJob(SecureDataService secureDataService, | ||
@Named("cms.jobs.DataKeyRotationJob.numberOfDataKeyToRotatePerJobRun") | ||
int numberOfDataKeyToRotatePerJobRun, | ||
@Named("cms.jobs.DataKeyRotationJob.dataKeyRotationPauseTimeInMillis") | ||
int dataKeyRotationPauseTimeInMillis, | ||
@Named("cms.jobs.DataKeyRotationJob.dataKeyRotationIntervalInDays") | ||
int dataKeyRotationIntervalInDays) { | ||
|
||
this.secureDataService = secureDataService; | ||
this.numberOfDataKeyToRotatePerJobRun = numberOfDataKeyToRotatePerJobRun; | ||
this.dataKeyRotationPauseTimeInMillis = dataKeyRotationPauseTimeInMillis; | ||
this.dataKeyRotationIntervalInDays = dataKeyRotationIntervalInDays; | ||
} | ||
|
||
|
||
@Override | ||
protected void executeLockableCode() { | ||
secureDataService.rotateDataKeys(numberOfDataKeyToRotatePerJobRun, dataKeyRotationPauseTimeInMillis, dataKeyRotationIntervalInDays); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2017 Nike, Inc. | ||
* | ||
* Licensed 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 com.nike.cerberus.record; | ||
|
||
import com.nike.cerberus.domain.Source; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
public class DataKeyInfo { | ||
|
||
private String id; | ||
private Source source; | ||
private OffsetDateTime lastRotatedTs; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public DataKeyInfo setId(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public Source getSource() { | ||
return source; | ||
} | ||
|
||
public DataKeyInfo setSource(Source source) { | ||
this.source = source; | ||
return this; | ||
} | ||
|
||
public OffsetDateTime getLastRotatedTs() { | ||
return lastRotatedTs; | ||
} | ||
|
||
public DataKeyInfo setLastRotatedTs(OffsetDateTime lastRotatedTs) { | ||
this.lastRotatedTs = lastRotatedTs; | ||
return this; | ||
} | ||
} |
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
Oops, something went wrong.