本文整理汇总了Java中gov.nih.nci.cagrid.opensaml.SAMLAssertion类的典型用法代码示例。如果您正苦于以下问题:Java SAMLAssertion类的具体用法?Java SAMLAssertion怎么用?Java SAMLAssertion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SAMLAssertion类属于gov.nih.nci.cagrid.opensaml包,在下文中一共展示了SAMLAssertion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public static GlobusCredential login(String dorianURL, SAMLAssertion saml) throws MalformedURIException, RemoteException {
// Create a IFS Client for authorization
IFSUserClient ifsClient = new IFSUserClient(dorianURL);
// Create a lifetime for the proxy, 12 hours in this case
ProxyLifetime lifetime = new ProxyLifetime();
lifetime.setHours(12);
lifetime.setMinutes(0);
lifetime.setSeconds(0);
// specify delegation, use 0 for now. 0 indicates that the credential cannot be delegated
int delegation = 0;
delegation = Integer.valueOf(1);
// obtain your proxy and save it for use in invoking grid services
GlobusCredential cred = ifsClient.createProxy(saml, lifetime, delegation);
return cred;
}
示例2: check
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public void check(SAMLAssertion saml, Exception e) throws Exception {
if (e == null) {
throw new Exception(
"No error was received when one was expected!!!");
}
if ((!error.equals(e.getClass()))) {
throw new Exception(
"Did not receive the expected error type in authenticating.\nThe error expected was:\n"
+ error.getName()
+ "\nThe error received was:\n"
+ e.getClass().getName());
} else if ((this.errorMessage != null)
&& (Utils.getExceptionMessage(e).indexOf(this.errorMessage) == -1)) {
throw new Exception(
"Did not receive the expected error message in authenticating.\nThe error expected was:\n"
+ this.errorMessage
+ "\nThe error received was:\n"
+ Utils.getExceptionMessage(e));
}
}
示例3: runStep
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public void runStep() throws Throwable {
BasicAuthentication ba = new BasicAuthentication();
ba.setUserId(user.getUserId());
ba.setPassword(user.getPassword());
LocalUserClient client = new LocalUserClient(serviceURL);
client.changePassword(ba, newPassword);
ba.setPassword(newPassword);
SAMLAssertion saml = client.authenticate(ba);
CertificateLifetime lifetime = new CertificateLifetime();
lifetime.setHours(12);
GridUserClient client2 = new GridUserClient(this.serviceURL);
GlobusCredential gridCredential = client2
.requestUserCertificate(saml, lifetime);
assertNotNull(gridCredential);
gridCredential.verify();
}
示例4: authenticate
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public SAMLAssertion authenticate(String authenticationServiceURL,
Credential credential) throws AuthenticationErrorException,
AuthenticationConfigurationException {
try {
AuthenticationClient authenticationClient = new AuthenticationClient(
authenticationServiceURL);
SAMLAssertion samlAssertion = authenticationClient
.authenticate(credential);
log.debug("authentication successful url"
+ authenticationServiceURL);
return samlAssertion;
} catch (Exception e) {
handleException(e);
}
return null;
}
示例5: getAttribute
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
private String getAttribute(SAMLAssertion saml, String namespace, String name) throws InvalidAssertionFault {
Iterator itr = saml.getStatements();
while (itr.hasNext()) {
Object o = itr.next();
if (o instanceof SAMLAttributeStatement) {
SAMLAttributeStatement att = (SAMLAttributeStatement) o;
Iterator attItr = att.getAttributes();
while (attItr.hasNext()) {
SAMLAttribute a = (SAMLAttribute) attItr.next();
if ((a.getNamespace().equals(namespace)) && (a.getName().equals(name))) {
Iterator vals = a.getValues();
while (vals.hasNext()) {
String val = Utils.clean((String) vals.next());
if (val != null) {
return val;
}
}
}
}
}
}
InvalidAssertionFault fault = new InvalidAssertionFault();
fault.setFaultString("The assertion does not contain the required attribute, " + namespace + ":" + name);
throw fault;
}
示例6: getAttribute
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public static String getAttribute(SAMLAssertion saml, String namespace, String name) {
Iterator itr = saml.getStatements();
while (itr.hasNext()) {
Object o = itr.next();
if (o instanceof SAMLAttributeStatement) {
SAMLAttributeStatement att = (SAMLAttributeStatement) o;
Iterator attItr = att.getAttributes();
while (attItr.hasNext()) {
SAMLAttribute a = (SAMLAttribute) attItr.next();
if ((a.getNamespace().equals(namespace)) && (a.getName().equals(name))) {
Iterator vals = a.getValues();
while (vals.hasNext()) {
String val = gov.nih.nci.cagrid.common.Utils.clean((String) vals.next());
if (val != null) {
return val;
}
}
}
}
}
}
return null;
}
示例7: getAttributeValue
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public static String getAttributeValue(SAMLAssertion saml, String namespace, String name) {
Iterator itr = saml.getStatements();
while (itr.hasNext()) {
Object o = itr.next();
if (o instanceof SAMLAttributeStatement) {
SAMLAttributeStatement att = (SAMLAttributeStatement) o;
Iterator attItr = att.getAttributes();
while (attItr.hasNext()) {
SAMLAttribute a = (SAMLAttribute) attItr.next();
if ((a.getNamespace().equals(namespace)) && (a.getName().equals(name))) {
Iterator vals = a.getValues();
while (vals.hasNext()) {
String val = gov.nih.nci.cagrid.common.Utils.clean((String) vals.next());
if (val != null) {
return val;
}
}
}
}
}
}
return null;
}
示例8: unmarshal
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
@Override
public AssertionType unmarshal(Object assertionElement) throws Exception {
SAMLUtils.canonicalizeAssertion((Element) assertionElement);
// Element assertionElement = JAXBUtils.marshalToElement(assertion, SAMLUtils.ASSERTION_QNAME);
// SAMLUtils.canonicalizeAssertion(assertionElement);
SAMLAssertion samlAssertion = new SAMLAssertion((Element) assertionElement);
// Must regenerate internal DOM!
samlAssertion.toString();
// SAMLAssertion domToSAMLAssertion = SAMLUtils.domToSAMLAssertion((Element) assertionElement);
AssertionType assertion = JAXBUtils.unmarshal(AssertionType.class, samlAssertion.toString());
assertion.setSamlAssertion(samlAssertion);
return assertion;
}
示例9: getAttribute
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
private String getAttribute(SAMLAssertion saml, String namespace, String name) throws InvalidAssertionException {
Iterator itr = saml.getStatements();
while (itr.hasNext()) {
Object o = itr.next();
if (o instanceof SAMLAttributeStatement) {
SAMLAttributeStatement att = (SAMLAttributeStatement) o;
Iterator attItr = att.getAttributes();
while (attItr.hasNext()) {
SAMLAttribute a = (SAMLAttribute) attItr.next();
if ((a.getNamespace().equals(namespace)) && (a.getName().equals(name))) {
Iterator vals = a.getValues();
while (vals.hasNext()) {
String val = Utils.clean((String) vals.next());
if (val != null) {
return val;
}
}
}
}
}
}
InvalidAssertionException fault = FaultHelper.createFaultException(InvalidAssertionException.class, "The assertion does not contain the required attribute, " + namespace + ":" + name);
throw fault;
}
示例10: getAttributeValue
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public static String getAttributeValue(SAMLAssertion saml,
String namespace, String name) {
Iterator itr = saml.getStatements();
while (itr.hasNext()) {
Object o = itr.next();
if (o instanceof SAMLAttributeStatement) {
SAMLAttributeStatement att = (SAMLAttributeStatement) o;
Iterator attItr = att.getAttributes();
while (attItr.hasNext()) {
SAMLAttribute a = (SAMLAttribute) attItr.next();
if ((a.getNamespace().equals(namespace))
&& (a.getName().equals(name))) {
Iterator vals = a.getValues();
while (vals.hasNext()) {
String val = Utils.clean((String) vals.next());
if (val != null) {
return val;
}
}
}
}
}
}
return null;
}
示例11: authenticate
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public static SAMLAssertion authenticate(String authenticationServiceURL, String username, String password) throws MalformedURIException, RemoteException {
Credential credential = new Credential();
BasicAuthenticationCredential bac = new BasicAuthenticationCredential();
bac.setUserId(username);
bac.setPassword(password);
credential.setBasicAuthenticationCredential(bac);
AuthenticationClient authClient = new AuthenticationClient(authenticationServiceURL, credential);
SAMLAssertion saml = authClient.authenticate();
return saml;
}
示例12: authenticate
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
/*********************
* This method is used to get the globus credential for given dorian url, authentication service url, user id and string.
* @param dorianURL
* @param authenticationServiceURL
* @param userId
* @param password
* @return globus credential of the user.
* @throws Exception
*/
public static GlobusCredential authenticate(String dorianURL,
String authenticationServiceURL, String userId, String password)
throws Exception
{
// Create credential
BasicAuthentication auth = new BasicAuthentication();
auth.setUserId(userId);
auth.setPassword(password);
// Authenticate to the IdP (DorianIdP) using credential
AuthenticationClient authClient = new AuthenticationClient(
authenticationServiceURL);
SAMLAssertion saml = authClient.authenticate(auth);
// Requested Grid Credential lifetime (12 hours)
CertificateLifetime lifetime = new CertificateLifetime();
lifetime.setHours(12);
// Request PKI/Grid Credential
GridUserClient dorian = new GridUserClient(dorianURL);
GlobusCredential credential = dorian.requestUserCertificate(saml,
lifetime);
return credential;
}
示例13: authenticate
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public GlobusCredential authenticate(String username, String password, String authenticationServiceURL) throws CGMMInputException, CGMMConfigurationException, CGMMGridDorianException, CGMMGridAuthenticationServiceException, CGMMAuthenticationURLException
{
if(StringUtilities.isBlank(username) || StringUtilities.isBlank(password)){
throw new CGMMInputException(CGMMMessages.EXCEPTION_EMPTY_USER_PASSWORD);
}
if(StringUtilities.isBlank(authenticationServiceURL) ){
throw new CGMMInputException(CGMMMessages.EXCEPTION_INVALID_AUTHENTICATION_URL);
}
if (null == cgmmProperties) throw new CGMMConfigurationException(CGMMMessages.EXCEPTION_CGMM_PROPERTIES);
// Obtain the implementation for the AuthenticationServiceHelper
// Interface
AuthenticationServiceHelper authenticationServiceHelper = (AuthenticationServiceHelper)ObjectFactory.getObject(CGMMConstants.AUTHENTICATION_SERVICE_HELPER);
// Authenticate the user credentials and retrieve
SAMLAssertion samlAssertion = authenticationServiceHelper.authenticate( authenticationServiceURL , username, password);
// Obtain the implementation for the DorianHelper Interface
DorianHelper dorianHelper = (DorianHelper) ObjectFactory.getObject(CGMMConstants.DORIAN_HELPER);
// Obtained the GlobusCredential for the Authenticated User
globusCredential = dorianHelper.obtainProxy(samlAssertion, this.getDorianInformation(authenticationServiceURL));
// Obtain the implementation for the ProxyValidator Interface
ProxyValidator proxyValidator = (ProxyValidator)ObjectFactory.getObject(CGMMConstants.PROXY_VALIDATOR);
// Validate the Proxy
proxyValidator.validate(globusCredential);
return globusCredential;
}
示例14: authenticate
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
/**
* Authenticate the user credentials and retrieve samlAssertion for authentication Service
* Obtain the GlobusCredential for the Authenticated User from Dorian
* Validate the Proxy or GlobusCredential
* Delegate the Globus Credentials
* Adding the serialized Delegated Credentials Reference and Grid Identity to the attributes map
* Create the Principal from the grid identity
* Create a new Authentication Object using the Principal
*/
@SuppressWarnings("unchecked")
public Authentication authenticate(Credentials credentials)
throws AuthenticationException {
if (null == webSSOProperties) {
throw new AuthenticationConfigurationException(
"Error Initializing Authentication Manager properties");
}
UsernamePasswordAuthenticationServiceURLCredentials userNameCredentials=(UsernamePasswordAuthenticationServiceURLCredentials)credentials;
SAMLAssertion samlAssertion = authenticationServiceHelper.authenticate(
userNameCredentials.getAuthenticationServiceURL(),userNameCredentials.getCredential());
DorianInformation dorianInformation = this.getDorianInformation(userNameCredentials.getDorianName());
GlobusCredential globusCredential = dorianHelper.obtainProxy(samlAssertion, dorianInformation);
proxyValidator.validate(globusCredential);
String serializedDelegatedCredentialReference = gridCredentialDelegator
.delegateGridCredential(globusCredential, this.getHostIdentities());
Map<String, Object> attributesMap = (Map<String, Object>)samlToAttributeMapper.convertSAMLtoHashMap(samlAssertion);
attributesMap.put(WebSSOConstants.CAGRID_SSO_DELEGATION_SERVICE_EPR, serializedDelegatedCredentialReference);
attributesMap.put(WebSSOConstants.CAGRID_SSO_GRID_IDENTITY, globusCredential.getIdentity());
String principal = this.constructPrincipal(attributesMap);
Principal p = new SimplePrincipal(principal,attributesMap);
MutableAuthentication mutableAuthentication = new MutableAuthentication(p);
return mutableAuthentication;
}
示例15: requestUserCertificate
import gov.nih.nci.cagrid.opensaml.SAMLAssertion; //导入依赖的package包/类
public static GlobusCredential requestUserCertificate(String authenticationServiceURL, String dorianURL,
Credential cred, CertificateLifetime lifetime, int delegationPathLength) throws InvalidCredentialFault,
InsufficientAttributeFault, AuthenticationProviderFault, RemoteException, MalformedURIException {
AuthenticationClient client = new AuthenticationClient(authenticationServiceURL, cred);
SAMLAssertion saml = client.authenticate();
GridUserClient dorian = new GridUserClient(dorianURL);
GlobusCredential proxy = dorian.requestUserCertificate(saml, lifetime);
return proxy;
}