Skip to content
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 @@ -99,9 +99,9 @@ public interface PINManagementGUIFacade extends BKUGUIFacade {
public static final String STATUS_UNKNOWN = "status.unknown";

// public enum STATUS { ACTIV, NOT_ACTIV, BLOCKED, UNKNOWN };
public enum DIALOG { VERIFY, ACTIVATE, CHANGE, UNBLOCK };
public enum DIALOG { VERIFY, ACTIVATE, CHANGE, UNBLOCK }

public enum PIN_MANAGEMENT_DIALOG_TYPE {DIALOGUE_UNDEFINED, DIALOGUE_PIN_MANAGEMENT, DIALOGUE_PIN};
public enum PIN_MANAGEMENT_DIALOG_TYPE {DIALOGUE_UNDEFINED, DIALOGUE_PIN_MANAGEMENT, DIALOGUE_PIN}
/**
* list pins
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import java.io.IOException;
import java.io.OutputStream;
//import java.net.MalformedURLException;
//import java.net.URL;
import java.util.Map;
import java.util.Map.Entry;

Expand Down Expand Up @@ -70,22 +68,18 @@ public void init() throws ServletException {
}
String url = MoccaParameterBean.getInitParameter("expiredPageUrl", getServletConfig(), getServletContext());
if (url != null) {
// try {
// expiredPageUrl = new URL(url).toString();
// log.info("Init expiredPageUrl to: {}.", expiredPageUrl);
// } catch (MalformedURLException e) {
// log.error("Failed to set expiredUrlPage '{}': {}.", url, e);
// }
expiredPageUrl = url;
log.info("Init expiredPageUrl to: {}.", expiredPageUrl);
}
}

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req, resp);
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, java.io.IOException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
//import at.buergerkarte.namespaces.cardchannel.service.ScriptType;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class RuleChecker implements AccessChecker {

private final Logger log = LoggerFactory.getLogger(RuleChecker.class);

public static enum PEER_TYPE {
public enum PEER_TYPE {
HOST, IP, URL
};
}

protected String id;
protected AuthenticationClass authenticationClass;
Expand Down Expand Up @@ -163,26 +163,9 @@ protected boolean matchPeerId(String peerUrl) {
try {
URL url = new URL(peerUrl);
if (peerType == PEER_TYPE.HOST) {
try {
String host = url.getHost();
String hostName = InetAddress.getByName(host)
.getCanonicalHostName();
Matcher matcher = peerIdPattern.matcher(hostName);
return matcher.matches();
} catch (UnknownHostException e) {
log.error("Cannot resolve hostname.", e);
return false;
}
return matchByCanonicalHostName(url);
} else {
try {
String hostAddr = InetAddress.getByName(url.getHost())
.getHostAddress();
Matcher matcher = peerIdPattern.matcher(hostAddr);
return matcher.matches();
} catch (UnknownHostException e) {
log.error("Cannot resolve host address.", e);
return false;
}
return matchByHostAddress(url);
}
} catch (MalformedURLException e) {
log.error("Cannot parse url.", e);
Expand All @@ -191,6 +174,30 @@ protected boolean matchPeerId(String peerUrl) {
}
}

private boolean matchByCanonicalHostName(URL url) {
try {
String hostName = InetAddress.getByName(url.getHost())
.getCanonicalHostName();
Matcher matcher = peerIdPattern.matcher(hostName);
return matcher.matches();
} catch (UnknownHostException e) {
log.error("Cannot resolve hostname.", e);
return false;
}
}

private boolean matchByHostAddress(URL url) {
try {
String hostAddr = InetAddress.getByName(url.getHost())
.getHostAddress();
Matcher matcher = peerIdPattern.matcher(hostAddr);
return matcher.matches();
} catch (UnknownHostException e) {
log.error("Cannot resolve host address.", e);
return false;
}
}

@Override
public RuleResult check(AccessCheckerContext checkCtx) {
log.debug("Processing rule: {}.", id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void setConcreteFactories(
/**
* Get an instance of the <code>SLCommandFactory</code>.
*/
public synchronized static SLCommandFactory getInstance() {
public static synchronized SLCommandFactory getInstance() {
return SLCommandFactoryInstance.INSTANCE;
}

Expand Down
42 changes: 21 additions & 21 deletions bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
*/


package at.gv.egiz.bku.slcommands;
package at.gv.egiz.bku.slcommands;

import javax.xml.transform.Result;
import javax.xml.transform.Templates;
public interface SLResult {
public static enum SLResultType {BINARY, XML};
public SLResultType getResultType();
/**
* The MIME Type of the Result.
*
* @return may result null if unknown.
*/
public String getMimeType();
public void writeTo(Result aResult, boolean fragment);
/**
*

public interface SLResult {

public enum SLResultType {BINARY, XML}

public SLResultType getResultType();

/**
* The MIME Type of the Result.
*
* @return may result null if unknown.
*/
public String getMimeType();

public void writeTo(Result aResult, boolean fragment);

/**
*
* @param result
* @param templates may be null.
* @param fragment TODO
*/
*/
public void writeTo(Result result, Templates templates, boolean fragment);

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void setUrlDereferencer(URLDereferencer urlDereferencer) {
this.urlDereferencer = urlDereferencer;
}

@Override
public InputStream getHashDataInput() throws IOException {

InputStream hashDataInputStream = urlDereferencer.dereference(urlReference).getStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
/*
* Copyright 2011 by Graz University of Technology, Austria
* MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint
* initiative of the Federal Chancellery Austria and Graz University of Technology.
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
*/


/*
* Copyright 2011 by Graz University of Technology, Austria
* MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint
* initiative of the Federal Chancellery Austria and Graz University of Technology.
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
package at.gv.egiz.bku.accesscontroller;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import at.gv.egiz.bku.accesscontroller.RuleChecker.PEER_TYPE;
Expand Down Expand Up @@ -108,4 +109,52 @@ public void testPeerId() {
assertTrue(rr.matchFound());
}

@Test
public void testMatchPeerIdReturnsFalseIfGivenInvalidUrl(){
RuleChecker ruleChecker = new RuleChecker("1");
ruleChecker.setPeerId("a", PEER_TYPE.HOST);

assertFalse(ruleChecker.matchPeerId("asdf"));
}

@Test
public void testMatchPeerId(){
RuleChecker ruleChecker = new RuleChecker("1");
ruleChecker.setPeerId("a", PEER_TYPE.HOST);

assertFalse(ruleChecker.matchPeerId("http://me:secret@127.0.0.1:80/myPath"));

ruleChecker.setPeerId("127.0.0.1:80", PEER_TYPE.HOST);
assertFalse(ruleChecker.matchPeerId("http://me:secret@127.0.0.1:80/myPath"));

ruleChecker.setPeerId("orf.at", PEER_TYPE.HOST);
assertTrue(ruleChecker.matchPeerId("http://me:secret@orf.at/myPath"));

ruleChecker.setPeerId("a", PEER_TYPE.IP);
assertFalse(ruleChecker.matchPeerId("http://me:secret@127.0.0.1:80/myPath"));

ruleChecker.setPeerId("127.0.0.1:80", PEER_TYPE.IP);
assertFalse(ruleChecker.matchPeerId("http://me:secret@127.0.0.1:80/myPath"));

ruleChecker.setPeerId("127.0.0.1", PEER_TYPE.IP);
assertTrue(ruleChecker.matchPeerId("http://me:secret@127.0.0.1:80/myPath"));

ruleChecker.setPeerId("orf.at", PEER_TYPE.IP);
assertFalse(ruleChecker.matchPeerId("http://me:secret@orf.at/myPath"));
}

@Ignore("Address resolution would slow down Unit tests too much. " +
"Mocking libraries not integrated in the project yet." +
"Therefore ignored.")
@Test
public void testMatchPeerIdCatchesUnknownHostException(){
RuleChecker ruleChecker = new RuleChecker("1");
ruleChecker.setPeerId("a", PEER_TYPE.HOST);

assertFalse(ruleChecker.matchPeerId("http://me:secret@127.0_01:80/myPath"));

ruleChecker.setPeerId("orf.at", PEER_TYPE.IP);
assertFalse(ruleChecker.matchPeerId("http://me:secret@or f.at/myPath"));
}

}
2 changes: 1 addition & 1 deletion smcc/src/main/java/at/gv/egiz/smcc/PinInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class PinInfo {

public enum STATE {UNKNOWN, ACTIV, NOT_ACTIV, BLOCKED};
public enum STATE {UNKNOWN, ACTIV, NOT_ACTIV, BLOCKED}

/**
* the number of remaining retries is unknown or irrelevant (blocked, not active states)
Expand Down
4 changes: 1 addition & 3 deletions smcc/src/main/java/at/gv/egiz/smcc/SEIdentityCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ private ResponseAPDU readFromCard(CardChannel channel, byte offsetHi,
(byte) 0x00, (byte) 0xB0, offsetHi, offsetLo, numBytes };

CommandAPDU command = new CommandAPDU(apdu);
ResponseAPDU resp = channel.transmit(command);

return resp;
return channel.transmit(command);

}

Expand Down
3 changes: 1 addition & 2 deletions smcc/src/main/java/at/gv/egiz/smcc/util/MSCMDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ public static String decodeString(byte[] data, int offset) throws UnsupportedEnc
utf8Data[i] = data[offset + 2 + i];
}

String str = new String(utf8Data, "UTF-8");
return str;
return new String(utf8Data, "UTF-8");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void setSequence(BigInteger value) {
*/
public BigInteger getRc() {
if (rc == null) {
return new BigInteger("0");
return BigInteger.valueOf(0);
} else {
return rc;
}
Expand Down
Loading