@Override public XDIArc getOwnerPeerRootXDIArc() { return GraphUtil.getOwnerPeerRootXDIArc(this.getGraph()); }
public static XDIAddress getOwnerXDIAddress(Graph graph) { XDIArc ownerPeerRootXDIArc = getOwnerPeerRootXDIArc(graph); if (ownerPeerRootXDIArc == null) return null; return XdiPeerRoot.getXDIAddressOfPeerRootXDIArc(ownerPeerRootXDIArc); }
@Override public RSAPrivateKey getPrivateKey(XDIAddress signerXDIAddress) throws GeneralSecurityException { if (signerXDIAddress == null) throw new NullPointerException(); // graph MessagingContainerMount messagingContainerMount; try { messagingContainerMount = this.getMessagingContainerRegistry().lookup(XdiPeerRoot.createPeerRootXDIArc(signerXDIAddress)); } catch (Exception ex) { throw new GeneralSecurityException("Messaging target not found for " + signerXDIAddress + ": " + ex.getMessage(), ex); } if (log.isDebugEnabled()) log.debug("Messaging target mount: " + messagingContainerMount); if (messagingContainerMount == null) return null; MessagingContainer messagingContainer = messagingContainerMount.getMessagingContainer(); Graph graph = ((GraphMessagingContainer) messagingContainer).getGraph(); // TODO: what if this is another messaging container? // signer entity XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(graph).getXdiEntity(signerXDIAddress, false); signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference(); if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(graph)); if (signerXdiEntity == null) return null; // find private key RSAPrivateKey privateKey = rsaPrivateKeyFromPrivateKeyString(Keys.getSignaturePrivateKey(signerXdiEntity)); // done return privateKey; }
@Override public SecretKey getSecretKey(XDIAddress signerXDIAddress) throws GeneralSecurityException { // signer address if (signerXDIAddress == null) { signerXDIAddress = GraphUtil.getOwnerXDIAddress(this.getSecretKeyGraph()); } // signer entity XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(this.getSecretKeyGraph()).getXdiEntity(signerXDIAddress, false); signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference(); if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(this.getSecretKeyGraph())); if (signerXdiEntity == null) return null; // find secret key SecretKey secretKey = aesSecretKeyFromSecretKeyString(Keys.getSecretKey(signerXdiEntity)); // done return secretKey; }
@Override public SecretKey getSecretKey(XDIAddress signerXDIAddress) throws GeneralSecurityException { // signer address if (signerXDIAddress == null) { signerXDIAddress = GraphUtil.getOwnerXDIAddress(this.getSecretKeyGraph()); } // signer entity XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(this.getSecretKeyGraph()).getXdiEntity(signerXDIAddress, false); signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference(); if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(this.getSecretKeyGraph())); if (signerXdiEntity == null) return null; // find secret key SecretKey secretKey = aesSecretKeyFromSecretKeyString(Keys.getSecretKey(signerXdiEntity)); // done return secretKey; }
@Override public RSAPrivateKey getPrivateKey(XDIAddress signerXDIAddress) throws GeneralSecurityException { // signer address if (signerXDIAddress == null) { signerXDIAddress = GraphUtil.getOwnerXDIAddress(this.getPrivateKeyGraph()); } // signer entity XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(this.getPrivateKeyGraph()).getXdiEntity(signerXDIAddress, false); signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference(); if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(this.getPrivateKeyGraph())); if (signerXdiEntity == null) return null; // find private key RSAPrivateKey privateKey = rsaPrivateKeyFromPrivateKeyString(Keys.getSignaturePrivateKey(signerXdiEntity)); // done return privateKey; }
@Override public RSAPublicKey getPublicKey(XDIAddress signerXDIAddress) throws GeneralSecurityException { // signer address if (signerXDIAddress == null) { signerXDIAddress = GraphUtil.getOwnerXDIAddress(this.getPublicKeyGraph()); } // signer entity XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(this.getPublicKeyGraph()).getXdiEntity(signerXDIAddress, false); signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference(); if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(this.getPublicKeyGraph())); if (signerXdiEntity == null) return null; // find public key RSAPublicKey publicKey = rsaPublicKeyFromPublicKeyString(Keys.getSignaturePublicKey(signerXdiEntity)); // done return publicKey; }
public void testGetOwnerXDIAddress() throws Exception { Graph graph = MemoryGraphFactory.getInstance().parseGraph(TEST_GRAPH_DEREFERENCE); assertEquals(GraphUtil.getOwnerPeerRootXDIArc(graph), XDIArc.fromComponent(TEST_CONTEXTNODE_1111)); graph.close(); }