All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.edu.icm.unity.saml.idp.ctx.SAMLAuthnContext Maven / Gradle / Ivy

There is a newer version: 4.0.4
Show newest version
/*
 * Copyright (c) 2007, 2008 ICM Uniwersytet Warszawski All rights reserved.
 * See LICENCE file for licencing information.
 *
 * Created on Aug 21, 2007
 * Author: K. Benedyczak 
 */

package pl.edu.icm.unity.saml.idp.ctx;

import eu.unicore.samly2.messages.SAMLVerifiableElement;
import pl.edu.icm.unity.saml.idp.SAMLIdPConfiguration;
import xmlbeans.org.oasis.saml2.protocol.AuthnRequestDocument;
import xmlbeans.org.oasis.saml2.protocol.AuthnRequestType;

import java.time.Duration;
import java.time.Instant;

/**
 * SAML Context for authN request protocol.
 * 
 * @author K. Benedyczak
 */
public class SAMLAuthnContext extends SAMLAssertionResponseContext
{
	private String relayState;
	private Instant creationTs;
	private final SAMLVerifiableElement verifiableElement;
	
	public SAMLAuthnContext(AuthnRequestDocument reqDoc, SAMLIdPConfiguration samlConfiguration,
			SAMLVerifiableElement verifiableElement)
	{
		super(reqDoc, reqDoc.getAuthnRequest(), samlConfiguration);
		this.verifiableElement = verifiableElement;
		creationTs = Instant.now();
	}

	public String getRelayState()
	{
		return relayState;
	}

	public void setRelayState(String relayState)
	{
		this.relayState = relayState;
	}

	public boolean isExpired()
	{
		Duration timeout = samlConfiguration.getAuthenticationTimeoutDuration();
		return creationTs.plus(timeout).isAfter(Instant.now());
	}
	
	public String getResponseDestination()
	{
		return getSamlConfiguration().getReturnAddressForRequester(getRequest());
	}

	public SAMLVerifiableElement getVerifiableElement()
	{
		return verifiableElement;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy