use of iso.std.iso_iec._24727.tech.schema.DIDStructureType in project open-ecard by ecsec.
the class MiddlewareSAL method didUpdate.
@Override
public DIDUpdateResponse didUpdate(DIDUpdate request) {
DIDUpdateResponse response = WSHelper.makeResponse(DIDUpdateResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
byte[] application = cardStateEntry.getImplicitlySelectedApplicationIdentifier();
DIDUpdateDataType didUpdateData = request.getDIDUpdateData();
Assert.assertIncorrectParameter(didUpdateData, "The parameter DIDUpdateData is empty.");
String didName = SALUtils.getDIDName(request);
DIDStructureType didStruct = cardStateEntry.getDIDStructure(didName, application);
if (didStruct == null) {
String msg = String.format("DID %s does not exist.", didName);
throw new NamedEntityNotFoundException(msg);
}
Result updateResult;
String protocolURI = didUpdateData.getProtocol();
if ("urn:oid:1.3.162.15480.3.0.9".equals(protocolURI)) {
updateResult = updatePin(didUpdateData, cardStateEntry, didStruct);
} else {
String msg = String.format("Protocol %s is not supported by this SAL.", protocolURI);
throw new UnknownProtocolException(msg);
}
// create did authenticate response
response.setResult(updateResult);
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.DIDStructureType in project open-ecard by ecsec.
the class TinySAL method cardApplicationStartSession.
/**
* This CardApplicationStartSession function starts a session between the client application and the card application.
* See BSI-TR-03112-4, version 1.1.2, section 3.2.3.
*
* @param request CardApplicationStartSession
* @return CardApplicationStartSessionResponse
*/
@Publish
@Override
public CardApplicationStartSessionResponse cardApplicationStartSession(CardApplicationStartSession request) {
CardApplicationStartSessionResponse response = WSHelper.makeResponse(CardApplicationStartSessionResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
byte[] cardApplicationID = connectionHandle.getCardApplication();
String didName = SALUtils.getDIDName(request);
Assert.assertIncorrectParameter(didName, "The parameter didName is empty.");
DIDAuthenticationDataType didAuthenticationProtocolData = request.getAuthenticationProtocolData();
Assert.assertIncorrectParameter(didAuthenticationProtocolData, "The parameter didAuthenticationProtocolData is empty.");
DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
Assert.securityConditionApplication(cardStateEntry, cardApplicationID, ConnectionServiceActionName.CARD_APPLICATION_START_SESSION);
String protocolURI = didStructure.getDIDMarker().getProtocol();
SALProtocol protocol = getProtocol(connectionHandle, request.getDIDScope(), protocolURI);
if (protocol.hasNextStep(FunctionType.CardApplicationStartSession)) {
response = protocol.cardApplicationStartSession(request);
removeFinishedProtocol(connectionHandle, protocolURI, protocol);
} else {
throw new InappropriateProtocolForActionException("CardApplicationStartSession", protocol.toString());
}
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.DIDStructureType in project open-ecard by ecsec.
the class TinySAL method didUpdate.
/**
* The DIDUpdate function creates a new key (marker) for the DID addressed with DIDName.
* See BSI-TR-03112-4, version 1.1.2, section 3.6.4.
*
* @param request DIDUpdate
* @return DIDUpdateResponse
*/
// TODO: discuss whether we should publish this @Publish
@Override
public DIDUpdateResponse didUpdate(DIDUpdate request) {
DIDUpdateResponse response = WSHelper.makeResponse(DIDUpdateResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
byte[] cardApplicationID = connectionHandle.getCardApplication();
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
String didName = request.getDIDName();
Assert.assertIncorrectParameter(didName, "The parameter DIDName is empty.");
DIDUpdateDataType didUpdateData = request.getDIDUpdateData();
Assert.assertIncorrectParameter(didUpdateData, "The parameter DIDUpdateData is empty.");
DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
Assert.securityConditionDID(cardStateEntry, cardApplicationID, didName, DifferentialIdentityServiceActionName.DID_UPDATE);
String protocolURI = didStructure.getDIDMarker().getProtocol();
SALProtocol protocol = getProtocol(connectionHandle, null, protocolURI);
if (protocol.hasNextStep(FunctionType.DIDUpdate)) {
response = protocol.didUpdate(request);
removeFinishedProtocol(connectionHandle, protocolURI, protocol);
} else {
throw new InappropriateProtocolForActionException("DIDUpdate", protocol.toString());
}
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.DIDStructureType in project open-ecard by ecsec.
the class TinySAL method didDelete.
/**
* The DIDDelete function deletes the DID addressed with DIDName.
* See BSI-TR-03112-4, version 1.1.2, section 3.6.5.
*
* @param request DIDDelete
* @return DIDDeleteResponse
*/
@Override
public DIDDeleteResponse didDelete(DIDDelete request) {
DIDDeleteResponse response = WSHelper.makeResponse(DIDDeleteResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
byte[] cardApplicationID = connectionHandle.getCardApplication();
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
String didName = request.getDIDName();
Assert.assertIncorrectParameter(didName, "The parameter DIDName is empty.");
DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
Assert.securityConditionDID(cardStateEntry, cardApplicationID, didName, DifferentialIdentityServiceActionName.DID_DELETE);
String protocolURI = didStructure.getDIDMarker().getProtocol();
SALProtocol protocol = getProtocol(connectionHandle, null, protocolURI);
if (protocol.hasNextStep(FunctionType.DIDDelete)) {
response = protocol.didDelete(request);
removeFinishedProtocol(connectionHandle, protocolURI, protocol);
} else {
throw new InappropriateProtocolForActionException("DIDDelete", protocol.toString());
}
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.DIDStructureType in project open-ecard by ecsec.
the class TinySAL method decipher.
/**
* The Decipher function decrypts a given cipher text. The detailed behaviour of this function depends on
* the protocol of the DID.
* See BSI-TR-03112-4, version 1.1.2, section 3.5.2.
*
* @param request Decipher
* @return DecipherResponse
*/
@Override
public DecipherResponse decipher(Decipher request) {
DecipherResponse response = WSHelper.makeResponse(DecipherResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
byte[] applicationID = cardStateEntry.getCurrentCardApplication().getApplicationIdentifier();
String didName = SALUtils.getDIDName(request);
byte[] cipherText = request.getCipherText();
Assert.assertIncorrectParameter(cipherText, "The parameter CipherText is empty.");
DIDScopeType didScope = request.getDIDScope();
if (didScope == null) {
didScope = DIDScopeType.LOCAL;
}
if (didScope.equals(DIDScopeType.LOCAL)) {
byte[] necessaryCardApp = cardStateEntry.getInfo().getApplicationIdByDidName(didName, didScope);
if (!Arrays.equals(necessaryCardApp, applicationID)) {
throw new SecurityConditionNotSatisfiedException("Wrong application selected.");
}
}
DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, didScope);
Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
String protocolURI = didStructure.getDIDMarker().getProtocol();
SALProtocol protocol = getProtocol(connectionHandle, request.getDIDScope(), protocolURI);
if (protocol.hasNextStep(FunctionType.Decipher)) {
response = protocol.decipher(request);
removeFinishedProtocol(connectionHandle, protocolURI, protocol);
} else {
throw new InappropriateProtocolForActionException("Decipher", protocol.toString());
}
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
Aggregations