@Override public XDIAddress getOwnerXDIAddress() { return GraphUtil.getOwnerXDIAddress(this.getGraph()); }
/** * Factory method that finds or creates an XDI send link contract for a graph. * @return The XDI send link contract. */ public static SendLinkContract findSendLinkContract(Graph graph, boolean create) { XDIAddress ownerXDIAddress = GraphUtil.getOwnerXDIAddress(graph); if (ownerXDIAddress == null) return null; RelationshipLinkContract relationshipLinkContract = RelationshipLinkContract.findRelationshipLinkContract(graph, ownerXDIAddress, XDILinkContractConstants.XDI_ADD_SEND, null, null, create); if (relationshipLinkContract == null) return null; return fromXdiEntity(relationshipLinkContract.getXdiEntity()); } }
/** * Factory method that finds or creates an XDI root link contract for a graph. * @return The XDI root link contract. */ public static RootLinkContract findRootLinkContract(Graph graph, boolean create) { XDIAddress ownerXDIAddress = GraphUtil.getOwnerXDIAddress(graph); if (ownerXDIAddress == null) return null; RelationshipLinkContract relationshipLinkContract = RelationshipLinkContract.findRelationshipLinkContract(graph, ownerXDIAddress, ownerXDIAddress, null, null, create); if (relationshipLinkContract == null) return null; return fromXdiEntity(relationshipLinkContract.getXdiEntity()); } }
/** * Factory method that finds or creates an XDI public link contract for a graph. * @return The XDI public link contract. */ public static PublicLinkContract findPublicLinkContract(Graph graph, boolean create) { XDIAddress ownerXDIAddress = GraphUtil.getOwnerXDIAddress(graph); if (ownerXDIAddress == null) return null; RelationshipLinkContract relationshipLinkContract = RelationshipLinkContract.findRelationshipLinkContract(graph, ownerXDIAddress, XDILinkContractConstants.XDI_ADD_PUBLIC, null, null, create); if (relationshipLinkContract == null) return null; return fromXdiEntity(relationshipLinkContract.getXdiEntity()); } }
/** * Factory method that finds or creates an XDI connect link contract for a graph. * @return The XDI connect link contract. */ public static ConnectLinkContract findConnectLinkContract(Graph graph, boolean create) { XDIAddress ownerXDIAddress = GraphUtil.getOwnerXDIAddress(graph); if (ownerXDIAddress == null) return null; RelationshipLinkContract relationshipLinkContract = RelationshipLinkContract.findRelationshipLinkContract(graph, ownerXDIAddress, XDILinkContractConstants.XDI_ADD_CONNECT, null, null, create); if (relationshipLinkContract == null) return null; return fromXdiEntity(relationshipLinkContract.getXdiEntity()); } }
@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 testConnectLinkContract() throws Exception { Graph graph = MemoryGraphFactory.getInstance().openGraph(); GraphUtil.setOwnerXDIAddress(graph, XDIAddress.create("=markus")); assertEquals(GraphUtil.getOwnerXDIAddress(graph), XDIAddress.create("=markus")); ConnectLinkContract l = ConnectLinkContract.findConnectLinkContract(graph, true); assertNotNull(l); assertEquals(l.getXdiEntity().getXDIAddress(), XDIAddress.create("(=markus/$connect)$contract")); assertNotNull(ConnectLinkContract.findConnectLinkContract(graph, false)); assertTrue(LinkContract.fromXdiEntity(l.getXdiEntity()) instanceof ConnectLinkContract); assertEquals(l.getRequestingAuthority(), XDILinkContractConstants.XDI_ADD_CONNECT); assertEquals(l.getAuthorizingAuthority(), XDIAddress.create("=markus")); assertNull(l.getTemplateAuthorityAndId()); graph.close(); }
public void testPublicLinkContract() throws Exception { Graph graph = MemoryGraphFactory.getInstance().openGraph(); GraphUtil.setOwnerXDIAddress(graph, XDIAddress.create("=markus")); assertEquals(GraphUtil.getOwnerXDIAddress(graph), XDIAddress.create("=markus")); PublicLinkContract l = PublicLinkContract.findPublicLinkContract(graph, true); assertNotNull(l); assertEquals(l.getXdiEntity().getXDIAddress(), XDIAddress.create("(=markus/$public)$contract")); assertNotNull(PublicLinkContract.findPublicLinkContract(graph, false)); assertTrue(LinkContract.fromXdiEntity(l.getXdiEntity()) instanceof PublicLinkContract); assertEquals(l.getRequestingAuthority(), XDILinkContractConstants.XDI_ADD_PUBLIC); assertEquals(l.getAuthorizingAuthority(), XDIAddress.create("=markus")); assertNull(l.getTemplateAuthorityAndId()); graph.close(); }
public void testRootLinkContract() throws Exception { Graph graph = MemoryGraphFactory.getInstance().openGraph(); GraphUtil.setOwnerXDIAddress(graph, XDIAddress.create("=markus")); assertEquals(GraphUtil.getOwnerXDIAddress(graph), XDIAddress.create("=markus")); RootLinkContract l = RootLinkContract.findRootLinkContract(graph, true); assertNotNull(l); assertEquals(l.getXdiEntity().getXDIAddress(), XDIAddress.create("(=markus/=markus)$contract")); assertNotNull(RootLinkContract.findRootLinkContract(graph, false)); assertTrue(LinkContract.fromXdiEntity(l.getXdiEntity()) instanceof RootLinkContract); assertEquals(l.getRequestingAuthority(), XDIAddress.create("=markus")); assertEquals(l.getAuthorizingAuthority(), XDIAddress.create("=markus")); assertNull(l.getTemplateAuthorityAndId()); graph.close(); }