1 19 package org.openharmonise.him.harmonise.authentication; 20 21 import java.net.*; 22 import java.rmi.*; 23 24 import javax.xml.rpc.*; 25 26 import org.openharmonise.commons.xml.namespace.*; 27 import org.openharmonise.him.*; 28 import org.openharmonise.him.harmonise.*; 29 import org.openharmonise.vfs.*; 30 import org.openharmonise.vfs.authentication.AuthInfo; 31 import org.openharmonise.vfs.authentication.VFSUser; 32 import org.openharmonise.vfs.metadata.*; 33 import org.openharmonise.vfs.metadata.value.*; 34 import org.openharmonise.vfs.servers.*; 35 36 37 44 public class HarmoniseUser implements VFSUser { 45 46 49 private String m_sUserPath = null; 50 51 54 private AbstractVirtualFileSystem m_vfs = null; 55 56 59 private boolean m_bSuperUserStatusChecked = false; 60 61 64 private boolean m_bIsSuperUser = false; 65 66 72 public HarmoniseUser(AbstractVirtualFileSystem vfs, String sUserPath) { 73 super(); 74 this.m_vfs = vfs; 75 this.m_sUserPath = sUserPath; 76 } 77 78 83 public String getRolePath() { 84 String sRolePath = null; 85 86 VirtualFile vfUser = this.m_vfs.getVirtualFile(m_sUserPath).getResource(); 87 88 PropertyInstance rbsPropInst = vfUser.getProperty(NamespaceType.OHRM_RBS.getURI(), "ROLE"); 89 if(rbsPropInst.getValues().size()>0) { 90 ValueValue value = (ValueValue) rbsPropInst.getValues().get(0); 91 sRolePath = value.getValue(); 92 } 93 94 return sRolePath; 95 } 96 97 102 public boolean isSuperUser() { 103 if(!this.m_bSuperUserStatusChecked) { 104 Server server = null; 105 server = ServerList.getInstance().getHarmoniseServer(); 106 URI uri = server.getURI(); 107 108 String sURI = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + "/webdav/services/HarmoniseService"; 109 URL url = null; 110 try { 111 url = new URL(sURI); 112 } catch (MalformedURLException e2) { 113 e2.printStackTrace(); 114 } 115 116 AuthInfo auth = server.getVFS().getAuthentication(); 117 118 try { 119 if( UserConfigClient.isSuperUser(url, auth.getUsername(), auth.getPassword()) ) { 120 this.m_bIsSuperUser=true; 121 } 122 } catch (RemoteException e) { 123 e.printStackTrace(); 124 } catch (ServiceException e) { 125 e.printStackTrace(); 126 } 127 this.m_bSuperUserStatusChecked = true; 128 return this.m_bIsSuperUser; 129 } else { 130 return this.m_bIsSuperUser; 131 } 132 } 133 134 } 135 | Popular Tags |