summaryrefslogtreecommitdiff
path: root/eaaf_core
diff options
context:
space:
mode:
authorThomas <thomas.lenz@egiz.gv.at>2019-12-04 22:54:51 +0100
committerThomas <thomas.lenz@egiz.gv.at>2019-12-04 22:54:51 +0100
commit95b21a826e5d81fdeabcf4673a9e87047edaec9d (patch)
treed8d55da492dd86041c31d68651afa21c80313362 /eaaf_core
parent759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f (diff)
downloadEAAF-Components-95b21a826e5d81fdeabcf4673a9e87047edaec9d.tar.gz
EAAF-Components-95b21a826e5d81fdeabcf4673a9e87047edaec9d.tar.bz2
EAAF-Components-95b21a826e5d81fdeabcf4673a9e87047edaec9d.zip
to some more code quality tasks
Diffstat (limited to 'eaaf_core')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/api/gui/IVelocityGuiFormBuilder.java4
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java15
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java18
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java23
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java6
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/ModuleRegistration.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BpkAttributeBuilder.java6
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java15
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DomUtils.java11
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/EaafDomEntityResolver.java3
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java2
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java101
14 files changed, 147 insertions, 63 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/api/gui/IVelocityGuiFormBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/api/gui/IVelocityGuiFormBuilder.java
index e06140bf..5a7ce49d 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/api/gui/IVelocityGuiFormBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/api/gui/IVelocityGuiFormBuilder.java
@@ -15,7 +15,7 @@ public interface IVelocityGuiFormBuilder extends IGuiFormBuilder {
* @param config GUI builder configuration
* @return
*/
- public VelocityContext generateVelocityContextFromConfiguration(
+ VelocityContext generateVelocityContextFromConfiguration(
IVelocityGuiBuilderConfiguration config);
@@ -27,7 +27,7 @@ public interface IVelocityGuiFormBuilder extends IGuiFormBuilder {
* invoking method
* @throws GuiBuildException In case of an error
*/
- public InputStream getTemplateInputStream(IVelocityGuiBuilderConfiguration config)
+ InputStream getTemplateInputStream(IVelocityGuiBuilderConfiguration config)
throws GuiBuildException;
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java
index a02498b7..1c1de7c8 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java
@@ -497,15 +497,12 @@ public class AuthenticationData implements IAuthData, Serializable {
}
- if (object != null) {
- if (!Serializable.class.isInstance(object)) {
- log.warn(
- "Generic data can only store objects which implements the 'Seralizable' interface");
- throw new EaafStorageException(
- "Generic data can only store objects which implements the 'Seralizable' interface",
- null);
-
- }
+ if (object != null && !Serializable.class.isInstance(object)) {
+ log.warn(
+ "Generic data can only store objects which implements the 'Seralizable' interface");
+ throw new EaafStorageException(
+ "Generic data can only store objects which implements the 'Seralizable' interface",
+ null);
}
if (genericDataStorate.containsKey(key)) {
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java
index 7a967d3f..241b43c9 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java
@@ -161,12 +161,12 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa
// force new authentication authentication process
if (pendingReq.forceAuth()) {
- startAuthenticationProcess(httpReq, httpResp, (RequestImpl) pendingReq);
+ startAuthenticationProcess(httpReq, (RequestImpl) pendingReq);
return false;
// perform SSO-Consents evaluation if it it required
} else if (isValidSsoSession && pendingReq.isNeedUserConsent()) {
- sendSingleSignOnConsentsEvaluation(httpReq, httpResp, (RequestImpl) pendingReq);
+ sendSingleSignOnConsentsEvaluation((RequestImpl) pendingReq);
return false;
@@ -193,7 +193,7 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa
} else {
// Start authentication!
- startAuthenticationProcess(httpReq, httpResp, (RequestImpl) pendingReq);
+ startAuthenticationProcess(httpReq, (RequestImpl) pendingReq);
return false;
}
@@ -230,14 +230,13 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa
* Populate process execution context and start process engine.
*
* @param httpReq http request
- * @param httpResp http response
* @param pendingReq current pending request
* @throws ServletException In case of a servlet error
* @throws IOException In case of an IO error
* @throws EaafException In case of EAAF processing error
*/
private void startAuthenticationProcess(final HttpServletRequest httpReq,
- final HttpServletResponse httpResp, final RequestImpl pendingReq) throws EaafException {
+ final RequestImpl pendingReq) throws EaafException {
log.info("Starting authentication ...");
revisionsLogger.logEvent(pendingReq, EVENT_AUTHENTICATION_PROCESS_STARTED);
@@ -253,9 +252,9 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa
if (httpReq.getAttribute("javax.servlet.request.X509Certificate") != null) {
log.debug("Find SSL-client-certificate on request --> Add it to context");
executionContext.put(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE,
- ((X509Certificate[]) httpReq.getAttribute("javax.servlet.request.X509Certificate")));
+ (X509Certificate[]) httpReq.getAttribute("javax.servlet.request.X509Certificate"));
pendingReq.setRawDataToTransaction(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE,
- (httpReq.getAttribute("javax.servlet.request.X509Certificate")));
+ httpReq.getAttribute("javax.servlet.request.X509Certificate"));
}
@@ -313,15 +312,12 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa
/**
* Starting a user consent evaluation.
*
- * @param request http request
- * @param response http response
* @param pendingReq current pending request
* @throws ServletException In case of a servlet error
* @throws IOException In case of an IO error
* @throws EaafException In case of a EAAF processing error
*/
- private void sendSingleSignOnConsentsEvaluation(final HttpServletRequest request,
- final HttpServletResponse response, final RequestImpl pendingReq) throws EaafException {
+ private void sendSingleSignOnConsentsEvaluation(final RequestImpl pendingReq) throws EaafException {
log.debug("Starting SSO user-consents evaluation ...");
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
index 491fdf4a..b12658f5 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
@@ -190,17 +190,17 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
// ####################################################
// set QAA level
- setQaaLevel(internalAuthData, authProcessData, pendingReq);
+ setQaaLevel(internalAuthData, authProcessData);
// ####################################################
// set isForeigner flag
- setFlagForeigner(internalAuthData, authProcessData, pendingReq);
+ setFlagForeigner(internalAuthData, authProcessData);
// ####################################################
// set citizen country-code
- setCitizenCountryCode(internalAuthData, authProcessData, pendingReq);
+ setCitizenCountryCode(internalAuthData, authProcessData);
// set generic authProcessData to authdata
@@ -228,10 +228,9 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
*
* @param authData Current authentication data
* @param authProcessData Authentication information holder from current pending request
- * @param pendingReq Current pending request
*/
private void setCitizenCountryCode(final AuthenticationData authData,
- final IAuthProcessDataContainer authProcessData, final IRequest pendingReq) {
+ final IAuthProcessDataContainer authProcessData) {
includedToGenericAuthData.remove(PVPAttributeDefinitions.EID_ISSUING_NATION_NAME);
final String pvpCccAttr = authProcessData
.getGenericDataFromSession(PVPAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class);
@@ -241,7 +240,8 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
} else {
if (authData.isForeigner()) {
- // TODO!!!!
+ //TODO:
+ log.warn("Foreign citizen country NOT set yet!");
} else {
authData.setCiticenCountryCode(basicConfig.getBasicConfiguration(
@@ -261,8 +261,7 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
* @param pendingReq current pending request
*/
private void setQaaLevel(@NonNull final AuthenticationData authData,
- @NonNull final IAuthProcessDataContainer authProcessData,
- @NonNull final IRequest pendingReq) {
+ @NonNull final IAuthProcessDataContainer authProcessData) {
includedToGenericAuthData.remove(PVPAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME);
String currentLoA = null;
if (StringUtils.isNotEmpty(authProcessData.getQAALevel())) {
@@ -295,7 +294,7 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
private void setFlagForeigner(final AuthenticationData authData,
- final IAuthProcessDataContainer authProcessData, final IRequest pendingReq) {
+ final IAuthProcessDataContainer authProcessData) {
// TODO: change to new eIDAS-token attribute identifier
if (authProcessData
.getGenericDataFromSession(PVPAttributeDefinitions.EID_STORK_TOKEN_NAME) != null) {
@@ -424,17 +423,17 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
// ####################################################
// set QAA level
- setQaaLevel(authData, authProcessData, pendingReq);
+ setQaaLevel(authData, authProcessData);
// ####################################################
// set isForeigner flag
- setFlagForeigner(authData, authProcessData, pendingReq);
+ setFlagForeigner(authData, authProcessData);
// ####################################################
// set citizen country-code
- setCitizenCountryCode(authData, authProcessData, pendingReq);
+ setCitizenCountryCode(authData, authProcessData);
// ####################################################
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java
index 765a6669..60c08253 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java
@@ -170,8 +170,8 @@ public class BpkBuilder {
bpk = baseId;
}
- if ((StringUtils.isEmpty(bpk) || StringUtils.isEmpty(sourceCountry)
- || StringUtils.isEmpty(destinationCountry))) {
+ if (StringUtils.isEmpty(bpk) || StringUtils.isEmpty(sourceCountry)
+ || StringUtils.isEmpty(destinationCountry)) {
throw new EaafBuilderException("builder.00",
new Object[] {"eIDAS-ID",
"Unvollständige Parameterangaben: identificationValue=" + bpk + ", Zielland="
@@ -199,7 +199,7 @@ public class BpkBuilder {
throws EaafBuilderException {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
if (target.startsWith(EAAFConstants.URN_PREFIX_CDID)) {
- target = target.substring((EAAFConstants.URN_PREFIX_CDID).length());
+ target = target.substring(EAAFConstants.URN_PREFIX_CDID.length());
}
final String input =
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/ModuleRegistration.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/ModuleRegistration.java
index b04b000e..27aeab03 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/ModuleRegistration.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/ModuleRegistration.java
@@ -137,7 +137,7 @@ public class ModuleRegistration {
Collections.sort(priorizedModules, (thisAuthModule, otherAuthModule) -> {
final int thisOrder = thisAuthModule.getPriority();
final int otherOrder = otherAuthModule.getPriority();
- return (thisOrder < otherOrder ? 1 : (thisOrder == otherOrder ? 0 : -1));
+ return thisOrder < otherOrder ? 1 : thisOrder == otherOrder ? 0 : -1;
});
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BpkAttributeBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BpkAttributeBuilder.java
index 2908ebdf..56eb5634 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BpkAttributeBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BpkAttributeBuilder.java
@@ -81,11 +81,11 @@ public class BpkAttributeBuilder implements IPvpAttributeBuilder {
protected String removeBpkTypePrefix(@Nonnull final String type) {
Assert.isTrue(type != null, "bPKType is 'NULL'");
if (type.startsWith(EAAFConstants.URN_PREFIX_WBPK)) {
- return type.substring((EAAFConstants.URN_PREFIX_WBPK).length());
+ return type.substring(EAAFConstants.URN_PREFIX_WBPK.length());
} else if (type.startsWith(EAAFConstants.URN_PREFIX_CDID)) {
- return type.substring((EAAFConstants.URN_PREFIX_CDID).length());
+ return type.substring(EAAFConstants.URN_PREFIX_CDID.length());
} else if (type.startsWith(EAAFConstants.URN_PREFIX_EIDAS)) {
- return type.substring((EAAFConstants.URN_PREFIX_EIDAS).length());
+ return type.substring(EAAFConstants.URN_PREFIX_EIDAS.length());
} else {
return type;
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
index 7c42f506..b15dfeba 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
@@ -115,7 +115,6 @@ public abstract class AbstractController {
+ "(Errorcode=9199" + " | Description="
+ StringEscapeUtils.escapeHtml4(StringEscapeUtils.escapeEcmaScript(exception.getMessage()))
+ ")");
- return;
}
@@ -134,7 +133,6 @@ public abstract class AbstractController {
log.error("Internel Server Error.", exception);
resp.setContentType(EAAFConstants.CONTENTTYPE_HTML_UTF8);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- return;
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
index ac0876c4..88dae874 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
@@ -445,15 +445,12 @@ public abstract class RequestImpl implements IRequest, Serializable {
}
- if (object != null) {
- if (!Serializable.class.isInstance(object)) {
- log.warn(
- "Generic request-data can only store objects which implements the 'Seralizable' interface");
- throw new EaafStorageException(
- "Generic request-data can only store objects which implements the 'Seralizable' interface",
- null);
-
- }
+ if (object != null && !Serializable.class.isInstance(object)) {
+ log.warn(
+ "Generic request-data can only store objects which implements the 'Seralizable' interface");
+ throw new EaafStorageException(
+ "Generic request-data can only store objects which implements the 'Seralizable' interface",
+ null);
}
if (genericDataStorage.containsKey(key)) {
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
index 0c4946af..fefcf331 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
@@ -366,7 +366,7 @@ public class ProcessEngineImpl implements ProcessEngine {
pi.setNextId(t.getTo().getId());
// inspect current task
- if (t.getTo() instanceof TaskInfo && (((TaskInfo) t.getTo()).isAsync())) {
+ if (t.getTo() instanceof TaskInfo && ((TaskInfo) t.getTo()).isAsync()) {
// immediately return in case of asynchonous task
log.debug("Suspending process instance '{}' for asynchronous task '{}'.", pi.getId(),
t.getTo().getId());
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DomUtils.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DomUtils.java
index 818523d0..aafea776 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DomUtils.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/DomUtils.java
@@ -412,7 +412,7 @@ public class DomUtils {
final String xmlContent = new String(buffer, "UTF-8");
log.debug("SAXException in:\n" + xmlContent);
}
- throw (e);
+ throw e;
}
return parser.getDocument();
@@ -925,10 +925,8 @@ public class DomUtils {
final Attr attr = (Attr) n;
final Element owner = attr.getOwnerElement();
- if (owner == null) {
- if (!isNamespaceDeclaration(attr)) {
- return false;
- }
+ if (owner == null && !isNamespaceDeclaration(attr)) {
+ return false;
}
if (!nodeSet.contains(owner) && !isNamespaceDeclaration(attr)) {
@@ -1054,6 +1052,7 @@ public class DomUtils {
}
default: {
+ log.trace("Node type: {} not supported", currentNode.getNodeType());
// All other nodes will be ignored
}
}
@@ -1103,7 +1102,7 @@ public class DomUtils {
* <code>null</code> or empty or no element is included in the list.
*/
public static Element getElementFromNodeList(final NodeList nl) {
- if ((nl == null) || (nl.getLength() == 0)) {
+ if (nl == null || nl.getLength() == 0) {
return null;
}
for (int i = 0; i < nl.getLength(); i++) {
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/EaafDomEntityResolver.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/EaafDomEntityResolver.java
index c2700214..6139e914 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/EaafDomEntityResolver.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/utils/EaafDomEntityResolver.java
@@ -25,8 +25,6 @@ import java.io.InputStream;
import at.gv.egiz.eaaf.core.api.data.XMLNamespaceConstants;
import org.apache.xerces.util.URI;
import org.apache.xerces.util.URI.MalformedURIException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@@ -46,7 +44,6 @@ import org.xml.sax.InputSource;
*
*/
public class EaafDomEntityResolver implements EntityResolver {
- private static final Logger log = LoggerFactory.getLogger(EaafDomEntityResolver.class);
/**
* Resolve an entity.
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java
index 586d464e..b91eaf21 100644
--- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java
@@ -25,7 +25,7 @@ public class AuthenticationDataBuilderTest {
@Autowired
private DummyConfiguration authConfig;
- private static final String DUMMY_IDL_2 =
+ public static final String DUMMY_IDL_2 =
"PHNhbWw6QXNzZXJ0aW9uIEFzc2VydGlvbklEPSJlbGdhdGVzdC5lZ2l6Lmd2LmF0LUFzc2VydGlvbklEWFhYxZB6Z8O8"
+ "cl9YWFhUw7x6ZWvDp2kiIElzc3VlSW5zdGFudD0iMjAxOS0wMy0wNFQxNTo1MzowNCswMTowMCIgSXNzdWVyPSJodH"
+ "RwOi8vcG9ydGFsLmJtaS5ndi5hdC9yZWYvc3pyL2lzc3VlciIgTWFqb3JWZXJzaW9uPSIxIiBNaW5vclZlcnNpb249"
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java
new file mode 100644
index 00000000..db97f4ca
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java
@@ -0,0 +1,101 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.PublicKey;
+import java.security.interfaces.RSAPublicKey;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.springframework.util.Base64Utils;
+
+import at.gv.egiz.eaaf.core.exceptions.EaafParserException;
+import at.gv.egiz.eaaf.core.impl.idp.auth.data.IdentityLink;
+import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class IdentityLinkTest {
+
+ private IdentityLink idl = null;
+
+ /**
+ * jUnit test set-up.
+ * @throws EaafParserException In case of an error
+ * @throws UnsupportedEncodingException In case of an unsupported encoding
+ */
+ @Before
+ public void testInit() throws EaafParserException, UnsupportedEncodingException {
+ idl = (IdentityLink) new SimpleIdentityLinkAssertionParser(
+ new ByteArrayInputStream(Base64Utils.decode(AuthenticationDataBuilderTest.DUMMY_IDL_2.getBytes("UTF-8")))).parseIdentityLink();
+
+ }
+
+ @Test
+ public void checkElement() {
+ Assert.assertNotNull("DateOfBirth", idl.getDateOfBirth());
+ Assert.assertNotNull("FamilyName", idl.getFamilyName());
+ Assert.assertNotNull("GivenNamae", idl.getGivenName());
+ Assert.assertNotNull("baseIdType", idl.getIdentificationType());
+ Assert.assertNotNull("baseid", idl.getIdentificationValue());
+ Assert.assertNotNull("IssuerInstant", idl.getIssueInstant());
+ Assert.assertNotNull("name", idl.getName());
+ Assert.assertNotNull("prPerson", idl.getPrPerson());
+ Assert.assertNotNull("Assertion element", idl.getSamlAssertion());
+ Assert.assertNotNull("Assertion serialized", idl.getSerializedSamlAssertion());
+ Assert.assertNotNull("Transform ref", idl.getDsigReferenceTransforms());
+ Assert.assertEquals("Transform Size not match", 1, idl.getDsigReferenceTransforms().length);
+
+ }
+
+ @Test
+ public void checkPubKeys() {
+ PublicKey[] publicKey = new RSAPublicKey[2];
+ publicKey[0] = generatePubKey();
+ publicKey[1] = generatePubKey();
+
+ idl.setPublicKey(publicKey );
+
+ Assert.assertNotNull("PubKey", idl.getPublicKey());
+ Assert.assertEquals("PubKeys not match", publicKey.length, idl.getPublicKey().length);
+
+ }
+
+ private PublicKey generatePubKey() {
+ return new RSAPublicKey() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public BigInteger getModulus() {
+ return new BigInteger(RandomStringUtils.randomNumeric(10));
+ }
+
+ @Override
+ public String getFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getEncoded() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getAlgorithm() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigInteger getPublicExponent() {
+ return new BigInteger(RandomStringUtils.randomNumeric(2));
+ }
+ };
+ }
+}