2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
21 package org.onap.aaf.stillNeed;
23 import java.security.Principal;
25 import org.onap.aaf.cadi.PropAccess;
26 import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;
27 import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm;
28 import org.onap.aaf.cadi.client.Future;
29 import org.onap.aaf.cadi.locator.DNSLocator;
30 import org.onap.aaf.cadi.lur.LocalPermission;
32 //TODO Needs running service to TEST
34 public class X509Test {
35 public static void main(String args[]) {
36 // Link or reuse to your Logging mechanism
38 PropAccess myAccess = new PropAccess();
42 AAFConHttp con = new AAFConHttp(myAccess,
43 new DNSLocator(myAccess,"https","mithrilcsp.sbc.com","8100"));
45 // AAFLur has pool of DME clients as needed, and Caches Client lookups
46 AAFLurPerm aafLur = con.newLur();
48 // Note: If you need both Authn and Authz construct the following:
49 // AAFAuthn<?> aafAuthn = con.newAuthn(aafLur);
51 // con.x509Alias("aaf.att"); // alias in keystore
55 // Normally, you obtain Principal from Authentication System.
56 // // For J2EE, you can ask the HttpServletRequest for getUserPrincipal()
57 // // If you use CADI as Authenticator, it will get you these Principals from
58 // // CSP or BasicAuth mechanisms.
59 // String id = "cluster_admin@gridcore.att.com";
61 // // If Validate succeeds, you will get a Null, otherwise, you will a String for the reason.
63 con.client("2.0").read("/authz/perms/com.att.aaf.ca","application/Perms+json");
65 System.out.println(fs.value);
67 System.out.println("Error: " + fs.code() + ':' + fs.body());
70 // Check on Perms with LUR
71 if(aafLur.fish(new Principal() {
73 public String getName() {
74 return "m12345@aaf.att.com";
76 }, new LocalPermission("org.osaaf.aaf.ca|aaf|request"))) {
77 System.out.println("Has Perm");
79 System.out.println("Does NOT Have Perm");
84 } catch (Exception e) {