
org.xlcloud.openstack.model.identity.keystone.KeystoneAuthentication Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2012 AMG.lab, a Bull Group Company
*
* 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 org.xlcloud.openstack.model.identity.keystone;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;
import org.xlcloud.openstack.model.identity.Authentication;
import org.xlcloud.openstack.model.identity.Token;
@XmlRootElement(name = "auth", namespace= "")
@XmlAccessorType(XmlAccessType.NONE)
@JsonRootName("auth")
public class KeystoneAuthentication implements Serializable, Authentication {
@XmlElement(type = KeystoneToken.class)
private KeystoneToken token;
@XmlElement(namespace= "", name="passwordCredentials")
@JsonProperty
private KeystonePasswordCredentials passwordCredentials;
@XmlElement(namespace= "", name="apiAccessKeyCredentials")
@JsonProperty
private KeystoneApiAccessKeyCredentials apiAccessKeyCredentials;
@XmlAttribute
private String tenantId;
@XmlAttribute
private String tenantName;
private KeystoneAuthentication() { }
public static KeystoneAuthentication withPasswordCredentials(String username, String password) {
KeystoneAuthentication auth = new KeystoneAuthentication();
auth.passwordCredentials = new KeystonePasswordCredentials();
auth.passwordCredentials.setUsername(username);
auth.passwordCredentials.setPassword(password);
return auth;
}
public static KeystoneAuthentication withApiAccessKeyCredentials(String accessKey, String secretKey) {
KeystoneAuthentication auth = new KeystoneAuthentication();
auth.apiAccessKeyCredentials = new KeystoneApiAccessKeyCredentials();
auth.apiAccessKeyCredentials.setAccessKey(accessKey);
auth.apiAccessKeyCredentials.setSecretKey(secretKey);
return auth;
}
public static KeystoneAuthentication withTokenAndTenant(String tokenId, String tenantId) {
KeystoneAuthentication auth = new KeystoneAuthentication();
auth.token = new KeystoneToken();
auth.token.setId(tokenId);
auth.tenantId = tenantId;
return auth;
}
/* (non-Javadoc)
* @see org.openstack.model.identity.glance.Authentication#getToken()
*/
@Override
public Token getToken() {
return token;
}
public void setToken(KeystoneToken token) {
this.token = token;
}
/* (non-Javadoc)
* @see org.openstack.model.identity.glance.Authentication#getTenantId()
*/
@Override
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
/* (non-Javadoc)
* @see org.openstack.model.identity.glance.Authentication#getTenantName()
*/
@Override
public String getTenantName() {
return tenantName;
}
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
@Override
public String toString() {
return "KeyStoneAuthentication [token=" + token
+ ", passwordCredentials=" + passwordCredentials
+ ", tenantId=" + tenantId + ", tenantName=" + tenantName + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy