Apply spring-javaformat and checkstyle
This commit adds the spring-javaformat code formatter and checkstyle rules to the project to make code formatting and style more consistent with other Spring projects.
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016-2020 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* https://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.example.credhub;
|
||||
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
@@ -10,37 +26,32 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CredHubService {
|
||||
|
||||
private final CredHubOperations credHubOperations;
|
||||
|
||||
private final SimpleCredentialName credentialName;
|
||||
|
||||
public CredHubService(CredHubOperations credHubOperations) {
|
||||
this.credHubOperations = credHubOperations;
|
||||
|
||||
credentialName = new SimpleCredentialName("example", "password");
|
||||
this.credentialName = new SimpleCredentialName("example", "password");
|
||||
}
|
||||
|
||||
public String generatePassword() {
|
||||
PasswordParameters parameters = PasswordParameters.builder()
|
||||
.length(12)
|
||||
.excludeLower(false)
|
||||
.excludeUpper(false)
|
||||
.excludeNumber(false)
|
||||
.includeSpecial(true)
|
||||
.build();
|
||||
|
||||
CredentialDetails<PasswordCredential> password = credHubOperations.credentials()
|
||||
.generate(PasswordParametersRequest.builder()
|
||||
.name(credentialName)
|
||||
.parameters(parameters)
|
||||
.build());
|
||||
PasswordParameters parameters = PasswordParameters.builder().length(12).excludeLower(false).excludeUpper(false)
|
||||
.excludeNumber(false).includeSpecial(true).build();
|
||||
|
||||
CredentialDetails<PasswordCredential> password = this.credHubOperations.credentials()
|
||||
.generate(PasswordParametersRequest.builder().name(this.credentialName).parameters(parameters).build());
|
||||
|
||||
return password.getValue().getPassword();
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
CredentialDetails<PasswordCredential> password = credHubOperations.credentials()
|
||||
.getByName(credentialName, PasswordCredential.class);
|
||||
CredentialDetails<PasswordCredential> password = this.credHubOperations.credentials()
|
||||
.getByName(this.credentialName, PasswordCredential.class);
|
||||
|
||||
return password.getValue().getPassword();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,45 +1,56 @@
|
||||
/*
|
||||
* Copyright 2016-2020 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* https://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.example.credhub;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.credhub.core.ReactiveCredHubOperations;
|
||||
import org.springframework.credhub.support.SimpleCredentialName;
|
||||
import org.springframework.credhub.support.password.PasswordCredential;
|
||||
import org.springframework.credhub.support.password.PasswordParameters;
|
||||
import org.springframework.credhub.support.password.PasswordParametersRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Component
|
||||
public class ReactiveCredHubService {
|
||||
|
||||
private final ReactiveCredHubOperations credHubOperations;
|
||||
|
||||
private final SimpleCredentialName credentialName;
|
||||
|
||||
public ReactiveCredHubService(ReactiveCredHubOperations credHubOperations) {
|
||||
this.credHubOperations = credHubOperations;
|
||||
|
||||
credentialName = new SimpleCredentialName("example", "password");
|
||||
this.credentialName = new SimpleCredentialName("example", "password");
|
||||
}
|
||||
|
||||
public Mono<String> generatePassword() {
|
||||
PasswordParameters parameters = PasswordParameters.builder()
|
||||
.length(12)
|
||||
.excludeLower(false)
|
||||
.excludeUpper(false)
|
||||
.excludeNumber(false)
|
||||
.includeSpecial(true)
|
||||
.build();
|
||||
PasswordParameters parameters = PasswordParameters.builder().length(12).excludeLower(false).excludeUpper(false)
|
||||
.excludeNumber(false).includeSpecial(true).build();
|
||||
|
||||
return credHubOperations.credentials()
|
||||
.generate(PasswordParametersRequest.builder()
|
||||
.name(credentialName)
|
||||
.parameters(parameters)
|
||||
.build(),
|
||||
return this.credHubOperations.credentials()
|
||||
.generate(PasswordParametersRequest.builder().name(this.credentialName).parameters(parameters).build(),
|
||||
PasswordCredential.class)
|
||||
.map(password -> password.getValue().getPassword());
|
||||
.map((password) -> password.getValue().getPassword());
|
||||
}
|
||||
|
||||
public Mono<String> getPassword() {
|
||||
return credHubOperations.credentials()
|
||||
.getByName(credentialName, PasswordCredential.class)
|
||||
.map(password -> password.getValue().getPassword());
|
||||
return this.credHubOperations.credentials().getByName(this.credentialName, PasswordCredential.class)
|
||||
.map((password) -> password.getValue().getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user