use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class AssertionManagerClient method getAssertion.
/**
* Returns the <code>Assertion</code> based on the
* <code>AssertionIDReference</code>.
*
* @param idRef The <code>AssertionIDReference</code> which references to an
* Assertion.
* @param token User session that is allowed to obtain the assertion.
* This token must have top level administrator role.
* @return the Assertion referenced by the
* <code>AssertionIDReference</code>.
* @throws SAMLException If an error occurred during the process; or
* the assertion could not be found.
*/
public Assertion getAssertion(AssertionIDReference idRef, Object token) throws SAMLException {
if (useLocal) {
return (assertionManager.getAssertion(idRef, token));
}
String assertion = null;
try {
SessionProvider sessionProvider = SessionManager.getProvider();
Object[] args = { idRef.getAssertionIDReference(), sessionProvider.getSessionID(token) };
assertion = (String) stub.send("getAssertionByIdRefToken", args, null, null);
return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
} catch (Exception re) {
if (SAMLUtils.debug.warningEnabled()) {
SAMLUtils.debug.warning("AMC:getAssertion: " + idRef, re);
}
throw (new SAMLException(re.getMessage()));
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class AssertionManagerClient method createAssertion.
/**
* Returns an assertion that contains an authentication statement.
* @param token User session that contains authentication
* information which is needed to create the authentication
* statement.
* @return the created assertion.
* @throws SAMLException if the assertion cannot be created.
*/
public Assertion createAssertion(Object token) throws SAMLException {
if (useLocal) {
return (assertionManager.createAssertion(token));
}
String assertion = null;
try {
SessionProvider sessionProvider = SessionManager.getProvider();
Object[] args = { sessionProvider.getSessionID(token) };
assertion = (String) stub.send("createAssertion", args, null, null);
return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
} catch (Exception re) {
if (SAMLUtils.debug.warningEnabled()) {
SAMLUtils.debug.warning("AMC:createAssertion(SSO)", re);
}
throw (new SAMLException(re.getMessage()));
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class AssertionManagerClient method createAssertion.
/**
* Returns an assertion that contains an authentication and attribute
* statement.
* @param token User session that contains authentication
* information which is needed to create the authentication
* statement for the assertion.
* @param attributes A list of attribute objects which are used to create
* the attribute statement.
* @return The created assertion.
* @throws SAMLException If the Assertion cannot be created.
*/
public Assertion createAssertion(Object token, List attributes) throws SAMLException {
if (useLocal) {
return (assertionManager.createAssertion(token, attributes));
}
// Check for null or empty attributes
if (attributes == null || attributes.isEmpty())
return (createAssertion(token));
String assertion = null;
try {
List attrs = new LinkedList();
for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
Attribute attribute = (Attribute) iter.next();
attrs.add(attribute.toString(true, true));
}
SessionProvider sessionProvider = SessionManager.getProvider();
Object[] args = { sessionProvider.getSessionID(token), attrs };
assertion = (String) stub.send("createAssertion2", args, null, null);
return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
} catch (Exception re) {
if (SAMLUtils.debug.warningEnabled()) {
SAMLUtils.debug.warning("AMC:createAssertion(SSO, attrs)", re);
}
throw (new SAMLException(re.getMessage()));
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class MultiProtocolUtils method usedInProtocol.
/**
* Returns true if the session is used in the specified federation protocol.
* @param request HttpServlet object
* @param protocol Protocol of the caller. Value is one of the following:
* <code>SingleLogoutManager.IDFF</code>
* <code>SingleLogoutManager.SAML2</code>
* <code>SingleLogoutManager.WS_FED</code>
* @return true if the session is used in this federation protocol,
* false otherwise.
*/
public static boolean usedInProtocol(HttpServletRequest request, String protocol) {
try {
SessionProvider provider = SessionManager.getProvider();
Object session = provider.getSession(request);
return usedInProtocol(session, protocol);
} catch (SessionException ex) {
SingleLogoutManager.debug.message("MPUtils.usedInProtocol?", ex);
return false;
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class MultiProtocolUtils method usedInProtocol.
/**
* Returns true if the session is used in the specified federation protocol.
* @param session Session object
* @param protocol Protocol of the caller. Value is one of the following:
* <code>SingleLogoutManager.IDFF</code>
* <code>SingleLogoutManager.SAML2</code>
* <code>SingleLogoutManager.WS_FED</code>
* @return true if the session is used in this federation protocol,
* false otherwise.
*/
public static boolean usedInProtocol(Object session, String protocol) {
SingleLogoutManager.debug.message("MultiProtocolUtils.usedInProtocol");
if ((session == null) || (protocol == null)) {
return false;
}
if (SingleLogoutManager.debug.messageEnabled()) {
SingleLogoutManager.debug.message("MultiProtocolUtils.usedInProto:" + " protocol=" + protocol + ", session=" + session);
}
try {
SessionProvider provider = SessionManager.getProvider();
String[] vals = provider.getProperty(session, SingleLogoutManager.FEDERATION_PROTOCOLS);
if (SingleLogoutManager.debug.messageEnabled()) {
SingleLogoutManager.debug.message("MultiProtocolUtils.usedInProtocol: protocols=" + vals);
}
if ((vals != null) && (vals.length != 0)) {
for (int i = 0; i < vals.length; i++) {
if (protocol.equals(vals[i])) {
return true;
}
}
}
return false;
} catch (SessionException ex) {
SingleLogoutManager.debug.message("MPUtils.usedInProtocol", ex);
} catch (UnsupportedOperationException ex) {
SingleLogoutManager.debug.message("MPUtils.usedInProtocol", ex);
}
return false;
}
Aggregations