+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.example;\r
-\r
-import java.security.Principal;\r
-\r
-import org.onap.aaf.cadi.PropAccess;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.locator.DNSLocator;\r
-import org.onap.aaf.cadi.lur.LocalPermission;\r
-\r
-public class JU_X509Test {\r
- public static void main(String args[]) {\r
- // Link or reuse to your Logging mechanism\r
- \r
- PropAccess myAccess = new PropAccess();\r
- \r
- // \r
- try {\r
- AAFConHttp con = new AAFConHttp(myAccess, \r
- new DNSLocator(myAccess,"https","mithrilcsp.sbc.com","8100"));\r
- \r
- // AAFLur has pool of DME clients as needed, and Caches Client lookups\r
- AAFLurPerm aafLur = con.newLur();\r
- \r
- // Note: If you need both Authn and Authz construct the following:\r
-// AAFAuthn<?> aafAuthn = con.newAuthn(aafLur);\r
- \r
- // con.x509Alias("aaf.att"); // alias in keystore\r
-\r
- try {\r
- \r
- // Normally, you obtain Principal from Authentication System.\r
-// // For J2EE, you can ask the HttpServletRequest for getUserPrincipal()\r
-// // If you use CADI as Authenticator, it will get you these Principals from\r
-// // CSP or BasicAuth mechanisms.\r
-// String id = "cluster_admin@gridcore.att.com";\r
-//\r
-// // If Validate succeeds, you will get a Null, otherwise, you will a String for the reason.\r
- Future<String> fs = \r
- con.client("2.0").read("/authz/perms/com.att.aaf.ca","application/Perms+json");\r
- if(fs.get(3000)) {\r
- System.out.println(fs.value);\r
- } else {\r
- System.out.println("Error: " + fs.code() + ':' + fs.body());\r
- }\r
- \r
- // Check on Perms with LUR\r
- if(aafLur.fish(new Principal() {\r
- @Override\r
- public String getName() {\r
- return "m12345@aaf.att.com";\r
- }\r
- }, new LocalPermission("com.att.aaf.ca|aaf|request"))) {\r
- System.out.println("Has Perm");\r
- } else {\r
- System.out.println("Does NOT Have Perm");\r
- }\r
- } finally {\r
- aafLur.destroy();\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-}\r