diff options
Diffstat (limited to 'src/main/java/at/gv/util/client/szr')
-rw-r--r-- | src/main/java/at/gv/util/client/szr/IRoleGenerationStrategy.java | 15 | ||||
-rw-r--r-- | src/main/java/at/gv/util/client/szr/PVP2XHTTPHeaderHandler.java (renamed from src/main/java/at/gv/util/client/szr/SZRHTTPHeaderHandler.java) | 68 | ||||
-rw-r--r-- | src/main/java/at/gv/util/client/szr/SZRClient.java | 4 |
3 files changed, 76 insertions, 11 deletions
diff --git a/src/main/java/at/gv/util/client/szr/IRoleGenerationStrategy.java b/src/main/java/at/gv/util/client/szr/IRoleGenerationStrategy.java new file mode 100644 index 0000000..d411f21 --- /dev/null +++ b/src/main/java/at/gv/util/client/szr/IRoleGenerationStrategy.java @@ -0,0 +1,15 @@ +package at.gv.util.client.szr; + +import at.gv.util.ex.EgovUtilException; + +public interface IRoleGenerationStrategy { + + /** + * Generates a request specific role string + * @param roleString Role from configuration + * + * @return Dynamic generated role + * @throws EgovUtilException + */ + public String generateRoleString(String roleString) throws EgovUtilException; +} diff --git a/src/main/java/at/gv/util/client/szr/SZRHTTPHeaderHandler.java b/src/main/java/at/gv/util/client/szr/PVP2XHTTPHeaderHandler.java index bde6b7b..f4fc11b 100644 --- a/src/main/java/at/gv/util/client/szr/SZRHTTPHeaderHandler.java +++ b/src/main/java/at/gv/util/client/szr/PVP2XHTTPHeaderHandler.java @@ -15,22 +15,35 @@ import org.apache.cxf.message.Message; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.gv.util.MiscUtil; +import at.gv.util.ex.EgovUtilException; import at.gv.util.xsd.szr.pvp.Param; import at.gv.util.xsd.szr.pvp.PvpTokenType; import at.gv.util.xsd.szr.pvp.PvpTokenType.Accounting; import at.gv.util.xsd.szr.pvp.PvpTokenType.Accounting.GvCostCenterId; import at.gv.util.xsd.szr.pvp.Role; -public class SZRHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { +public class PVP2XHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { private PvpTokenType pvpTokenType = null; - private Logger log = LoggerFactory.getLogger(SZRHTTPHeaderHandler.class); + private Logger log = LoggerFactory.getLogger(PVP2XHTTPHeaderHandler.class); public static final String PVP_HEADER_COSTCENTERID_DEFAULT = "<default>"; public static final String PVP_HEADER_VALUE_DELIMITER = ","; public static final String PVP_HEADER_ROLE_VALUE_DELIMITER = ";"; + private IRoleGenerationStrategy roleStrategy = null; + + public PVP2XHTTPHeaderHandler() { + + } + + public PVP2XHTTPHeaderHandler(IRoleGenerationStrategy roleGenerationStrategy) { + log.info("PVP2XHTTPHeaderHandler uses RoleGenerationStrategy: " + roleGenerationStrategy.getClass().getName()); + this.roleStrategy = roleGenerationStrategy; + + } + public void close(MessageContext arg0) { } @@ -58,7 +71,24 @@ public class SZRHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { return true; } Map<String, List> headers = (Map<String, List>) smc.get(Message.PROTOCOL_HEADERS); - setHeader(headers, "X-VERSION", pvpTokenType.getVersion()); + //PVP 2.x header + //setHeader(headers, "X-PVP-VERSION", pvpTokenType.getVersion()); + setHeader(headers, "X-PVP-EGOVTOKEN-VERSION", pvpTokenType.getVersion()); + setHeader(headers, "X-PVP-USERID", pvpTokenType.getAuthenticate().getUserPrincipal().getUserId()); + setHeader(headers, "X-PVP-GID", pvpTokenType.getAuthenticate().getUserPrincipal().getGvGid()); + setHeader(headers, "X-PVP-PARTICIPANT-ID", pvpTokenType.getAuthenticate().getParticipantId()); + setHeader(headers, "X-PVP-OU-GV-OU-ID", pvpTokenType.getAuthenticate().getUserPrincipal().getGvOuId()); + setHeader(headers, "X-PVP-OU", pvpTokenType.getAuthenticate().getUserPrincipal().getOu()); + setHeader(headers, "X-PVP-FUNCTION", pvpTokenType.getAuthenticate().getUserPrincipal().getGvFunction()); + setHeader(headers, "X-PVP-SECCLASS", String.valueOf(pvpTokenType.getAuthenticate().getUserPrincipal().getGvSecClass().intValue())); + setHeader(headers, "X-PVP-PRINCIPAL-NAME", pvpTokenType.getAuthenticate().getUserPrincipal().getCn()); + setHeader(headers, "X-PVP-BINDING", "http"); + setHeader(headers, "X-PVP-OU-OKZ", "AT:OVS"); + + + //PVP 1.x header + //setHeader(headers, "X-VERSION", pvpTokenType.getVersion()); + setHeader(headers, "X-VERSION", "1.8"); setHeader(headers, "X-AUTHENTICATE-UserID", pvpTokenType.getAuthenticate().getUserPrincipal().getUserId()); setHeader(headers, "X-AUTHENTICATE-GVGID", pvpTokenType.getAuthenticate().getUserPrincipal().getGvGid()); setHeader(headers, "X-AUTHENTICATE-PARTICIPANTID", pvpTokenType.getAuthenticate().getParticipantId()); @@ -89,12 +119,29 @@ public class SZRHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { else roleString = roleString + PVP_HEADER_ROLE_VALUE_DELIMITER + roleElement; } - } - setHeader(headers, "X-AUTHORIZE-ROLES", roleString); + } + + if (roleStrategy != null) { + log.trace("Generate dynamic role ... "); + try { + String dynRoleString = roleStrategy.generateRoleString(roleString); + setHeader(headers, "X-PVP-ROLES", dynRoleString); + setHeader(headers, "X-AUTHORIZE-ROLES", dynRoleString); + + } catch (EgovUtilException e) { + throw new RuntimeException("Can NOT generate dynamic VDDS role by using: " + roleStrategy.getClass().getName(), e); + + } + + } + + + + //set optional headers - String costCenterId = null; - String invoiceRecptId = null; + String costCenterId = StringUtils.EMPTY; + String invoiceRecptId = StringUtils.EMPTY; Accounting accounting = pvpTokenType.getAccounting(); if (accounting != null) { @@ -107,7 +154,7 @@ public class SZRHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { value = value + el.getValue(); - if (costCenterId == null) + if (costCenterId.isEmpty()) costCenterId = value; else costCenterId = PVP_HEADER_VALUE_DELIMITER + value; @@ -116,6 +163,9 @@ public class SZRHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { } } + setHeader(headers, "X-PVP-COST-CENTER-ID", costCenterId); + setHeader(headers, "X-PVP-INVOICE-RECPT-ID", invoiceRecptId); + setHeader(headers, "X-ACCOUNTING-CostCenterId", costCenterId); setHeader(headers, "X-ACCOUNTING-InvoiceRecptId", invoiceRecptId); @@ -129,7 +179,7 @@ public class SZRHTTPHeaderHandler implements SOAPHandler<SOAPMessageContext> { } private void setHeader(Map<String, List> headers, String name, String value) { if (MiscUtil.isEmpty(value)) - headers.put(name, null); + headers.put(name, Collections.singletonList(StringUtils.EMPTY)); else headers.put(name, Collections.singletonList(value)); diff --git a/src/main/java/at/gv/util/client/szr/SZRClient.java b/src/main/java/at/gv/util/client/szr/SZRClient.java index ad54d2f..67813bd 100644 --- a/src/main/java/at/gv/util/client/szr/SZRClient.java +++ b/src/main/java/at/gv/util/client/szr/SZRClient.java @@ -104,7 +104,7 @@ public class SZRClient { } - public String transformBPK(PersonInfoType personInfo, String inputBpk, String inputTarget, String target, String vkz) throws SZRException, EgovUtilException { + public FremdBPKType transformBPK(PersonInfoType personInfo, String inputBpk, String inputTarget, String target, String vkz) throws SZRException, EgovUtilException { MiscUtil.assertNotNull(personInfo, "personInfo"); MiscUtil.assertNotNull(target, "target"); String targetPrefix = "urn:publicid:gv.at:cdid+"; @@ -135,7 +135,7 @@ public class SZRClient { if (response == null) { return null; } - return response.get(0).getFremdBPK(); + return response.get(0); } @SuppressWarnings({ "rawtypes", "unchecked" }) |