use of com.microsoft.azure.management.graphrbac.PasswordCredential in project azure-sdk-for-java by Azure.
the class ServicePrincipalImpl method refreshCredentialsAsync.
Observable<ServicePrincipal> refreshCredentialsAsync() {
final Observable<ServicePrincipal> keyCredentials = manager.inner().servicePrincipals().listKeyCredentialsAsync(id()).map(new Func1<List<KeyCredentialInner>, Map<String, CertificateCredential>>() {
@Override
public Map<String, CertificateCredential> call(List<KeyCredentialInner> keyCredentialInners) {
if (keyCredentialInners == null || keyCredentialInners.isEmpty()) {
return null;
}
Map<String, CertificateCredential> certificateCredentialMap = new HashMap<String, CertificateCredential>();
for (KeyCredentialInner inner : keyCredentialInners) {
CertificateCredential credential = new CertificateCredentialImpl<>(inner);
certificateCredentialMap.put(credential.name(), credential);
}
return certificateCredentialMap;
}
}).map(new Func1<Map<String, CertificateCredential>, ServicePrincipal>() {
@Override
public ServicePrincipal call(Map<String, CertificateCredential> stringCertificateCredentialMap) {
ServicePrincipalImpl.this.cachedCertificateCredentials = stringCertificateCredentialMap;
return ServicePrincipalImpl.this;
}
});
final Observable<ServicePrincipal> passwordCredentials = manager.inner().servicePrincipals().listPasswordCredentialsAsync(id()).map(new Func1<List<PasswordCredentialInner>, Map<String, PasswordCredential>>() {
@Override
public Map<String, PasswordCredential> call(List<PasswordCredentialInner> passwordCredentialInners) {
if (passwordCredentialInners == null || passwordCredentialInners.isEmpty()) {
return null;
}
Map<String, PasswordCredential> passwordCredentialMap = new HashMap<String, PasswordCredential>();
for (PasswordCredentialInner inner : passwordCredentialInners) {
PasswordCredential credential = new PasswordCredentialImpl<>(inner);
passwordCredentialMap.put(credential.name(), credential);
}
return passwordCredentialMap;
}
}).map(new Func1<Map<String, PasswordCredential>, ServicePrincipal>() {
@Override
public ServicePrincipal call(Map<String, PasswordCredential> stringPasswordCredentialMap) {
ServicePrincipalImpl.this.cachedPasswordCredentials = stringPasswordCredentialMap;
return ServicePrincipalImpl.this;
}
});
return keyCredentials.mergeWith(passwordCredentials).last();
}
Aggregations