net.geant.edugain.base
Class AuthorizationResponse

java.lang.Object
  extended by net.geant.edugain.base.Response
      extended by net.geant.edugain.base.AuthorizationResponse
All Implemented Interfaces:
java.io.Serializable

public class AuthorizationResponse
extends Response
implements java.io.Serializable

A response containing an authorisation decision according to a previously issued AuthZReq. It must contain a boolean value specifying the decision and may include data to be used by the resource for whatever purpose (personalisation, for example) and/or an explanation about the returned decision, according to service and privacy policies.

This class extends Response.

Version:
0.7
Author:
Jaime Perez
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList<org.opensaml.SAMLAction> actions
          A list of actions that the user is authorized to perform.
protected  java.net.URI resource
          The URI of the resource the authorisation is resolved for.
protected  java.lang.String subjectHandle
          A reference to the identification string obtained upon the last successful authentication of the subject requesting access to the resource.
 
Fields inherited from class net.geant.edugain.base.Response
additionalData, consumerId, EDUGAIN_NAMESPACE_RESULT_ACCEPTED, EDUGAIN_NAMESPACE_RESULT_CONNECT_TO, EDUGAIN_NAMESPACE_RESULT_DENY, EDUGAIN_NAMESPACE_RESULT_EXPIRED_MESSAGE, EDUGAIN_NAMESPACE_RESULT_FAULT, EDUGAIN_NAMESPACE_RESULT_INCOMPATIBLE_VERSIONS, EDUGAIN_NAMESPACE_RESULT_INSUFFICIENT_DATA, EDUGAIN_NAMESPACE_RESULT_INVALID_CREDENTIALS, EDUGAIN_NAMESPACE_RESULT_MALFORMED_MESSAGE, EDUGAIN_NAMESPACE_RESULT_REDIRECT_USER_TO, EDUGAIN_NAMESPACE_RESULT_TRUST_ERROR, EDUGAIN_NAMESPACE_RESULT_UNKNOWN_HOMESITE, errorMessage, errorReason, inResponseTo, interfaces, issued, log, notBefore, notOnOrAfter, producerId, responseID, result, resultMessage, samlObject, strictMode, validator
 
Constructor Summary
AuthorizationResponse()
          Creates a new instance of AuthorizationResponse
AuthorizationResponse(org.w3c.dom.Element element)
          Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an Element.
AuthorizationResponse(org.w3c.dom.Element element, boolean strict)
          Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an Element.
AuthorizationResponse(java.io.InputStream stream)
          Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an InputStream.
AuthorizationResponse(java.io.InputStream stream, boolean strict)
          Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an InputStream.
AuthorizationResponse(org.opensaml.saml2.core.Response rsp)
          Creates a new instance of AuthorizationResponse, filling the fields with the Response data received.
AuthorizationResponse(org.opensaml.SAMLResponse rsp)
          Creates a new instance of AuthorizationResponse, filling the fields with the SAMLResponse data received.
AuthorizationResponse(org.opensaml.SAMLResponse rsp, boolean strict)
          Creates a new instance of AuthorizationResponse, filling the fields with the SAMLResponse data received.
 
Method Summary
 void addAction(org.opensaml.SAMLAction action)
          Adds the specified action to the current list.
 void addAction(java.lang.String namespace, java.lang.String name)
          Adds the specified action to the current list.
 void fromSAML(org.opensaml.saml2.core.Response response)
          Fill this AuthorizationResponse with a SAML 2 Response
 void fromSAML(org.opensaml.SAMLResponse response)
          Fill this AuthorizationResponse with a SAMLResponse.
 java.util.ArrayList<org.opensaml.SAMLAction> getActions()
          Gets the list of actions accepted for this response.
 java.net.URI getResource()
          Gets the resource for this AuthorizationResponse.
 java.lang.String getSubjectHandle()
          Gets the subject handle for this AuthorizationResponse.
 void removeAction(java.lang.String action)
          Removes the specified action from the current list.
 void setResource(java.lang.String r)
          Sets the resource for this AuthorizationResponse.
 void setResource(java.net.URI r)
          Sets the resource for this AuthorizationResponse.
 void setSubjectHandle(java.lang.String handle)
          Sets the subject handle for this AuthorizationResponse.
 java.lang.Object toSAML()
          Converts this response object into a SAML response.
private  org.opensaml.SAMLResponse toSAML1(int minor)
          Map the current AuthorizationResponse to a SAML 1.X response.
private  org.opensaml.saml2.core.Response toSAML2(int minor)
          Map the current AuthorizationResponse to a SAML 2.X response.
 
Methods inherited from class net.geant.edugain.base.Response
addInterface, fromSAML, generateResponseID, getAdditionalData, getConsumerId, getInResponseTo, getInterfaces, getIssued, getNotBefore, getNotOnOrAfter, getProducerId, getResponseID, getResult, getResultMessage, isStrict, setAdditionalData, setConsumerId, setInResponseTo, setInterfaces, setIssued, setNotBefore, setNotOnOrAfter, setProducerId, setResponseID, setResult, setResultMessage, setStrict, setValidator, toBase64, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resource

protected java.net.URI resource
The URI of the resource the authorisation is resolved for.


actions

protected java.util.ArrayList<org.opensaml.SAMLAction> actions
A list of actions that the user is authorized to perform.


subjectHandle

protected java.lang.String subjectHandle
A reference to the identification string obtained upon the last successful authentication of the subject requesting access to the resource.

Constructor Detail

AuthorizationResponse

public AuthorizationResponse()
                      throws BaseException
Creates a new instance of AuthorizationResponse

Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(java.io.InputStream stream)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an InputStream.

Parameters:
stream - The InputStream.
Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(java.io.InputStream stream,
                             boolean strict)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an InputStream.

Parameters:
stream - The InputStream.
strict - Whether to use strict mode or not.
Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(org.w3c.dom.Element element)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an Element.

Parameters:
element - The Element.
Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(org.w3c.dom.Element element,
                             boolean strict)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the SAML document from an Element.

Parameters:
element - The Element.
strict - Whether to use strict mode or not.
Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(org.opensaml.SAMLResponse rsp)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the SAMLResponse data received.

Parameters:
rsp - The original SAML response.
Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(org.opensaml.SAMLResponse rsp,
                             boolean strict)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the SAMLResponse data received.

Parameters:
rsp - The original SAML response.
strict - Whether to use strict mode or not.
Throws:
BaseException

AuthorizationResponse

public AuthorizationResponse(org.opensaml.saml2.core.Response rsp)
                      throws BaseException
Creates a new instance of AuthorizationResponse, filling the fields with the Response data received.

Parameters:
rsp - The original SAML 2 response.
Throws:
BaseException
Method Detail

getResource

public java.net.URI getResource()
Gets the resource for this AuthorizationResponse.

Returns:
The resource field.

setResource

public void setResource(java.net.URI r)
Sets the resource for this AuthorizationResponse.

Parameters:
r - The resource field to use.

setResource

public void setResource(java.lang.String r)
                 throws BaseException
Sets the resource for this AuthorizationResponse.

Parameters:
r - A string representation of an URI.
Throws:
BaseException

addAction

public void addAction(java.lang.String namespace,
                      java.lang.String name)
               throws BaseException
Adds the specified action to the current list.

Parameters:
namespace - The namespace of the action
name - The name of the action
Throws:
BaseException

addAction

public void addAction(org.opensaml.SAMLAction action)
               throws BaseException
Adds the specified action to the current list.

Parameters:
action - The action to add.
Throws:
BaseException

getActions

public java.util.ArrayList<org.opensaml.SAMLAction> getActions()
Gets the list of actions accepted for this response.

Returns:
The list of actions.

removeAction

public void removeAction(java.lang.String action)
Removes the specified action from the current list.

Parameters:
action - The action to remove.

getSubjectHandle

public java.lang.String getSubjectHandle()
Gets the subject handle for this AuthorizationResponse.

Returns:
The subject handle field.

setSubjectHandle

public void setSubjectHandle(java.lang.String handle)
                      throws BaseException
Sets the subject handle for this AuthorizationResponse.

Parameters:
handle - The subject handle.
Throws:
BaseException

fromSAML

public void fromSAML(org.opensaml.SAMLResponse response)
              throws BaseException
Fill this AuthorizationResponse with a SAMLResponse.

Specified by:
fromSAML in class Response
Parameters:
response - The SAML response.
Throws:
BaseException

fromSAML

public void fromSAML(org.opensaml.saml2.core.Response response)
              throws BaseException
Fill this AuthorizationResponse with a SAML 2 Response

Specified by:
fromSAML in class Response
Throws:
BaseException

toSAML

public java.lang.Object toSAML()
                        throws BaseException
Converts this response object into a SAML response. Please consider that this method returns an OpenSAML1 or an OpenSAML2 Response object depending on the SAML version eduGAIN is configured to use.

Specified by:
toSAML in class Response
Returns:
A SAMLResponse or a Response, depending on the SAML version eduGAIN is configured to use.
Throws:
BaseException

toSAML1

private org.opensaml.SAMLResponse toSAML1(int minor)
                                   throws BaseException
Map the current AuthorizationResponse to a SAML 1.X response.

Parameters:
minor - The minor version number (can be 0 or 1).
Returns:
The SAMLResponse that corresponds with this AuthorizationResponse.
Throws:
BaseException

toSAML2

private org.opensaml.saml2.core.Response toSAML2(int minor)
                                          throws BaseException
Map the current AuthorizationResponse to a SAML 2.X response.

Parameters:
minor - The minor version number (can be 0 or 1).
Returns:
The Response that corresponds with this AuthorizationResponse.
Throws:
BaseException