Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade language level to 1.6 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class DgwsRequestContextDefault implements DgwsRequestContext, EndpointIn
put("system", IdCardType.SYSTEM);
}};

@Override
public IdCardUserLog getIdCardUserLog() {
String cpr = getUserLogAttributeValue("medcom:UserCivilRegistrationNumber");
String givenName = getUserLogAttributeValue("medcom:UserGivenName");
Expand All @@ -55,7 +56,8 @@ public IdCardUserLog getIdCardUserLog() {
String authorisationCode = getUserLogAttributeValue("medcom:UserAuthorizationCode");
return new IdCardUserLog(cpr, givenName, surname, emailAddress, role, occupation, authorisationCode);
}


@Override
public IdCardSystemLog getIdCardSystemLog() {
String itSystemName = getSystemLogAttributeValue("medcom:ITSystemName");
Attribute careProviderIdAttribute = findAttribute("SystemLog", "medcom:CareProviderID");
Expand All @@ -65,7 +67,8 @@ public IdCardSystemLog getIdCardSystemLog() {
String careProviderName = getSystemLogAttributeValue("medcom:CareProviderName");
return new IdCardSystemLog(StringUtils.trim(itSystemName), careProviderIdType, StringUtils.trim(careProviderId), StringUtils.trim(careProviderName));
}


@Override
public IdCardData getIdCardData() {
AttributeStatement idCardData = findAttributeStatement(securityThreadLocal.get().getAssertion().getAttributeStatement(), "IDCardData");
int authenticationLevel = Integer.parseInt(findAttribute(idCardData, "sosi:AuthenticationLevel").getAttributeValue());
Expand All @@ -75,12 +78,14 @@ public IdCardData getIdCardData() {
}

@Deprecated
@Override
public String getIdCardCpr() {
return getUserLogAttributeValue("medcom:UserCivilRegistrationNumber");
}

public AttributeStatement findAttributeStatement(List<AttributeStatement> statements, final String attributeStatementId) {
return CollectionUtils.find(statements, new Predicate<AttributeStatement>() {
@Override
public boolean evaluate(AttributeStatement attributeStatement) {
return attributeStatement.getId().equals(attributeStatementId);
}
Expand All @@ -89,6 +94,7 @@ public boolean evaluate(AttributeStatement attributeStatement) {

public Attribute findAttribute(AttributeStatement statement, final String attributeName) {
return CollectionUtils.find(statement.getAttribute(), new Predicate<Attribute>() {
@Override
public boolean evaluate(Attribute attribute) {
return attribute.getName().equals(attributeName);
}
Expand All @@ -102,7 +108,8 @@ public Attribute findAttribute(String attributeStatementId, String attributeName
}
return findAttribute(statement, attributeName);
}


@Override
public String getUserLogAttributeValue(final String attributeName) {

final Attribute attribute = findAttribute("UserLog", attributeName);
Expand Down Expand Up @@ -135,7 +142,8 @@ void setSecurityThreadLocal(SoapHeader soapHeader) throws Exception {
Security securityHeader = findValueOfType(headerElements, Security.class);
setSecurityThreadLocal(securityHeader);
}


@Override
public boolean handleRequest(MessageContext messageContext, Object o) throws Exception {
if (messageContext.getRequest() instanceof SoapMessage) {
SoapHeader soapHeader = ((SoapMessage) messageContext.getRequest()).getSoapHeader();
Expand All @@ -144,14 +152,17 @@ public boolean handleRequest(MessageContext messageContext, Object o) throws Exc
return true;
}

@Override
public boolean handleResponse(MessageContext messageContext, Object o) throws Exception {
return true;
}

@Override
public boolean handleFault(MessageContext messageContext, Object o) throws Exception {
return true;
}

@Override
public void afterCompletion(MessageContext messageContext, Object o, Exception e) throws Exception {
securityThreadLocal.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SecurityCheckerImpl implements SecurityChecker {
@Autowired
DgwsRequestContext dgwsRequestContext;

@Override
public void validateHeader(String whitelist, int minAuthLevel, Security securityHeader) {
if (isNotEmpty(whitelist)) {
IdCardData idCardData = dgwsRequestContext.getIdCardData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class DgwsConfiguration implements ImportAware, EmbeddedValueResolverAwar
Boolean skipSosi = false;
private StringValueResolver resolver;

@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
final Map<String, Object> meta = importMetadata.getAnnotationAttributes(EnableDgwsProtection.class.getName());
if (meta.containsKey("test")) {
Expand All @@ -37,6 +38,7 @@ public SOSISecurityInterceptor sosiSecurityInterceptor() {
return interceptor;
}

@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.resolver = resolver;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public class SOSISecurityClientInterceptor implements ClientInterceptor, Initial
private SOSIFederation federation;
private CredentialVault vault;

public boolean handleFault(MessageContext arg0) throws WebServiceClientException {
@Override
public boolean handleFault(MessageContext arg0) throws WebServiceClientException {
return true;
}

@SuppressWarnings("serial")
@Override
@SuppressWarnings("serial")
public boolean handleRequest(MessageContext ctx) throws WebServiceClientException {
IDCard card = (IDCard) ctx.getProperty(ID_CARD);
if (card == null) card = SOSIContext.getCard();
Expand Down Expand Up @@ -82,11 +84,13 @@ public boolean handleRequest(MessageContext ctx) throws WebServiceClientExceptio
return true;
}

public boolean handleResponse(MessageContext arg0) throws WebServiceClientException {
@Override
public boolean handleResponse(MessageContext arg0) throws WebServiceClientException {
return true;
}

public void afterPropertiesSet() throws Exception {
@Override
public void afterPropertiesSet() throws Exception {
Properties props = SignatureUtil.setupCryptoProviderForJVM();
vault = new EmptyCredentialVault();
federation = new SOSIFederation(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public SOSIFactory getFactory() {
return factory;
}

public boolean handleRequest(MessageContext ctx, Object arg1) throws Exception {
@Override
public boolean handleRequest(MessageContext ctx, Object arg1) throws Exception {
SOSIContext.setCard(null);

String headerStr = sourceToString(getSource(ctx.getRequest()));
Expand Down Expand Up @@ -162,12 +163,14 @@ private String getOperation(Object ep) {
}
}

public boolean handleFault(MessageContext ctx, Object arg1) throws Exception {
@Override
public boolean handleFault(MessageContext ctx, Object arg1) throws Exception {
return handleResponse(ctx, arg1);
}


public boolean handleResponse(MessageContext ctx, Object arg1) throws Exception {
@Override
public boolean handleResponse(MessageContext ctx, Object arg1) throws Exception {
SOSIContext.setCard(null);
SOSIContext.setMessageId(null);

Expand Down Expand Up @@ -267,7 +270,8 @@ public String sourceToString(Source source) throws TransformerException {
return writer.toString();
}

public void afterPropertiesSet() throws Exception {
@Override
public void afterPropertiesSet() throws Exception {
transformerFactory = new MyTransformerFactory();
}
private static class MyTransformerFactory extends TransformerObjectSupport {
Expand All @@ -279,6 +283,7 @@ public Transformer createNonIndentingTransformer() throws TransformerConfigurati
}
}

@Override
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@ public class SecurityHelperImpl implements SecurityHelper {
@Autowired
Unmarshaller unmarshaller;

@Override
public String getCpr(SoapHeader soapHeader) {
return getAttributeValue(soapHeader, "UserLog", "medcom:UserCivilRegistrationNumber");
}

@Override
public String getAttributeValue(SoapHeader soapHeader, final String attributeStatementId, final String attributeName) {
Security security = extractSecurity(soapHeader);

AttributeStatement attributeStatement = CollectionUtils.find(
security.getAssertion().getAttributeStatement(),
new Predicate<AttributeStatement>() {
@Override
public boolean evaluate(AttributeStatement element) {
return element.getId().equals(attributeStatementId);
}
});
Attribute attribute = CollectionUtils.find(
attributeStatement.getAttribute(),
new Predicate<Attribute>() {
@Override
public boolean evaluate(Attribute object) {
return object.getName().equals(attributeName);
}
Expand All @@ -49,6 +53,7 @@ public boolean evaluate(Attribute object) {
return attribute.getAttributeValue();
}

@Override
public Security extractSecurity(SoapHeader soapHeader) {
List elements = new ArrayList();
Iterator<SoapHeaderElement> it = soapHeader.examineAllHeaderElements();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@ public ProtectedTargetProxy(ProtectedTarget target) {
this.target = target;
}

@Override
@Protected(whitelist = "Test Whitelist")
public String hitMe() {
return target.hitMe();
}

@Override
@Protected(whitelist = "Test Whitelist")
public String hitMe(SoapHeader header) {
return target.hitMe(header);
}

@Override
@Protected
public String publicHitMe(SoapHeader soapHeader) {
return target.publicHitMe(soapHeader);
}

@Override
@Protected(minAuthLevel=2)
public String hitMeAuth(SoapHeader soapHeader) {
return target.hitMeAuth(soapHeader);
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<version>3.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Expand Down