package at.gv.egovernment.moa.id.protocols.stork2; import at.gv.egovernment.moa.id.moduls.IRequest; import at.gv.egovernment.moa.logging.Logger; import eu.stork.peps.auth.commons.IPersonalAttributeList; import eu.stork.peps.auth.commons.PersonalAttributeList; import eu.stork.peps.auth.commons.STORKAttrQueryResponse; import eu.stork.peps.auth.commons.STORKAuthnResponse; import java.io.Serializable; /** * Implements MOA request and stores StorkAuthn/Attr-Request related data. * * @author bsuzic */ public class MOASTORKResponse implements IRequest, Serializable { /** * The Constant serialVersionUID. */ private static final long serialVersionUID = -5798803155055518747L; /** * The stork authn request. */ private STORKAuthnResponse storkAuthnResponse; /** * The stork attr query request. */ private STORKAttrQueryResponse storkAttrQueryResponse; /** * The action. */ String action = null; /** * The token */ private byte[] storkAuthnResponseToken = null; /** * The request id. */ private String requestID; /** * The module. */ String module = null; /** * The target. */ private String target = null; /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#requestedModule() */ public String requestedModule() { return this.module; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#requestedAction() */ public String requestedAction() { return action; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#getRequestID() */ public String getRequestID() { return this.requestID; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#getTarget() */ public String getTarget() { return this.target; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#isSSOSupported() */ public boolean isSSOSupported() { return false; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#forceAuth() */ public boolean forceAuth() { return false; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#setModule(java.lang.String) */ public void setModule(String module) { this.module = module; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#setRequestID(java.lang.String) */ public void setRequestID(String id) { this.requestID = id; } /** * Sets the sTORK authn response. * * @param request the new sTORK authn response */ public void setSTORKAuthnResponse(STORKAuthnResponse request) { this.storkAuthnResponse = request; } /** * Sets the sTORK authn response token * * @param request the new sTORK authn response token */ public void setSTORKAuthnResponseToken(byte[] token) { this.storkAuthnResponseToken = token; } /** * Gets the sTORK authn response token . * * @param request the new sTORK authn response */ public byte[] getSTORKAuthnResponseToken() { return this.storkAuthnResponseToken; } /** * Sets the sTORK attr response. * * @param request the new sTORK attr response */ public void setSTORKAttrResponse(STORKAttrQueryResponse request) { this.storkAttrQueryResponse = request; } /** * Checks if the container holds an AttrQuery * * @return true, if is attr response */ public boolean isAttrResponse() { return null != storkAttrQueryResponse; } /** * Checks if the container holds an AuthnRequest * * @return true, if is authn response */ public boolean isAuthnResponse() { return null != storkAuthnResponse; } /** * Gets the AuthnResponse. * * @return the stork authn response */ public STORKAuthnResponse getStorkAuthnResponse() { return this.storkAuthnResponse; } /** * Gets the AttrQueryResponse. * * @return the stork attr query response */ public STORKAttrQueryResponse getStorkAttrQueryResponse() { return this.storkAttrQueryResponse; } /** * Gets the personal attribute list. * * @return the personal attribute list */ public IPersonalAttributeList getPersonalAttributeList() { if (isAttrResponse()) return this.storkAttrQueryResponse.getPersonalAttributeList(); else return this.storkAuthnResponse.getPersonalAttributeList(); } /** * Sets the personal attribute list. * * @param populateAttributes the new personal attribute list */ public void setPersonalAttributeList(PersonalAttributeList populateAttributes) { if (isAttrResponse()) this.storkAttrQueryResponse.setPersonalAttributeList(populateAttributes); else this.storkAuthnResponse.setPersonalAttributeList(populateAttributes); } /** * Sets the country. * * @param spCountry the new country */ public void setCountry(String spCountry) { if (isAttrResponse()) this.storkAttrQueryResponse.setCountry(spCountry); else this.storkAuthnResponse.setCountry(spCountry); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#getOAURL() */ public String getOAURL() { if (isAuthnResponse()) return storkAuthnResponse.getAudienceRestriction(); else if (isAttrResponse()) return storkAttrQueryResponse.getAudienceRestriction(); else { Logger.error("There is no authentication or attribute request contained in MOASTORKRequest."); return null; } } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#isPassiv() */ public boolean isPassiv() { return false; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.moduls.IRequest#setAction(java.lang.String) */ public void setAction(String action) { this.action = action; } }